From 6ba6ce39a328ddccb18cd75d95bbbf0cff426e28 Mon Sep 17 00:00:00 2001 From: okikio Date: Thu, 10 Dec 2020 18:51:49 -0500 Subject: [PATCH] build(all): :package: support typescript declaration files, fix bugs with typescript v4 Change package.json commands from ultra-runner to npm in all packages except the root. To build file use ultra build, etc... read up on ultra-runner for more details. --- dts.tsconfig.json | 21 + package.json | 18 +- packages/animate/dts.tsconfig.json | 10 + packages/animate/package.json | 17 +- packages/animate/tests/test.ts | 84 ---- packages/emitter/dts.tsconfig.json | 10 + packages/emitter/package.json | 13 +- packages/manager/dts.tsconfig.json | 10 + packages/manager/package.json | 13 +- .../build-src/ts/services/Splashscreen.ts | 4 +- .../build-src/ts/transitions/BigTransition.ts | 4 +- .../native/build-src/ts/transitions/Fade.ts | 2 +- packages/native/docs/js/main.js | 4 +- packages/native/docs/js/main.js.map | 4 +- packages/native/dts.tsconfig.json | 10 + packages/native/lib/api.js | 4 +- packages/native/lib/api.js.map | 4 +- packages/native/lib/api.modern.js | 4 +- packages/native/lib/api.modern.js.map | 4 +- packages/native/lib/api.node.js | 4 +- packages/native/lib/api.node.js.map | 4 +- packages/native/lib/types/api.d.ts | 12 + packages/native/lib/types/app.d.ts | 163 ++++++++ packages/native/lib/types/config.d.ts | 55 +++ packages/native/lib/types/emitter.d.ts | 1 + packages/native/lib/types/history.d.ts | 97 +++++ packages/native/lib/types/manager.d.ts | 113 ++++++ packages/native/lib/types/page.d.ts | 122 ++++++ packages/native/lib/types/pjax.d.ts | 240 +++++++++++ packages/native/lib/types/route.d.ts | 87 ++++ packages/native/lib/types/service.d.ts | 103 +++++ packages/native/lib/types/transition.d.ts | 77 ++++ packages/native/lib/types/url.d.ts | 45 ++ packages/native/package.json | 14 +- packages/native/src/transition.ts | 6 +- packages/native/tests/test.ts | 24 -- pnpm-lock.yaml | 384 +++++++++--------- 37 files changed, 1445 insertions(+), 346 deletions(-) create mode 100644 dts.tsconfig.json create mode 100644 packages/animate/dts.tsconfig.json delete mode 100644 packages/animate/tests/test.ts create mode 100644 packages/emitter/dts.tsconfig.json create mode 100644 packages/manager/dts.tsconfig.json create mode 100644 packages/native/dts.tsconfig.json create mode 100644 packages/native/lib/types/api.d.ts create mode 100644 packages/native/lib/types/app.d.ts create mode 100644 packages/native/lib/types/config.d.ts create mode 100644 packages/native/lib/types/emitter.d.ts create mode 100644 packages/native/lib/types/history.d.ts create mode 100644 packages/native/lib/types/manager.d.ts create mode 100644 packages/native/lib/types/page.d.ts create mode 100644 packages/native/lib/types/pjax.d.ts create mode 100644 packages/native/lib/types/route.d.ts create mode 100644 packages/native/lib/types/service.d.ts create mode 100644 packages/native/lib/types/transition.d.ts create mode 100644 packages/native/lib/types/url.d.ts delete mode 100644 packages/native/tests/test.ts diff --git a/dts.tsconfig.json b/dts.tsconfig.json new file mode 100644 index 0000000..fcfb516 --- /dev/null +++ b/dts.tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "moduleResolution": "node", + "target": "ES2020", + "module": "ES2020", + "sourceMap": false, + "declaration": true, + "incremental": true, + "declarationDir": "lib/types", + "emitDeclarationOnly": true, + "isolatedModules": true, + "esModuleInterop": true + }, + "include": [ + "**/src/**/*" + ], + "exclude": [ + "node_modules", + "**/tests/**/*" + ] +} diff --git a/package.json b/package.json index 88d6564..1e56f74 100644 --- a/package.json +++ b/package.json @@ -6,20 +6,21 @@ "packages/*" ], "scripts": { - "build": "ultra -r build", - "docs:build": "ultra -r docs:build", - "docs:watch": "pnpm run --parallel -r docs:watch", + "build": "ultra --parallel -r build", + "docs:build": "pnpm --parallel -r docs:build", + "docs:watch": "ultra --parallel -r docs:watch", + "dts": "ultra -r --parallel --filter \"packages/*\" dts", "test": "ultra -r test", - "test:watch": "pnpm run --parallel -r test:watch", - "prepublishOnly": "ultra -r pre-release", - "release": "ultra prepublish && lerna version && pnpm -r publish --tag latest" + "test:watch": "ultra --parallel -r test:watch", + "pre-release": "ultra -r pre-release", + "release": "npm run pre-release && lerna version && pnpm -r publish --tag latest" }, "devDependencies": { "@commitlint/cli": "^11.0.0", "@commitlint/config-conventional": "^11.0.0", - "@types/jest": "^26.0.16", + "@types/jest": "^26.0.18", "browser-sync": "^2.26.13", - "esbuild": "^0.8.20", + "esbuild": "^0.8.21", "esbuild-jest": "^0.3.0", "gulp": "^4.0.2", "jest": "^26.6.3", @@ -27,6 +28,7 @@ "lerna": "^3.22.1", "merge-stream": "^2.0.0", "pnpm": "^5.13.5", + "typescript": "^4.1.2", "ultra-runner": "^3.6.0" } } diff --git a/packages/animate/dts.tsconfig.json b/packages/animate/dts.tsconfig.json new file mode 100644 index 0000000..e577d2b --- /dev/null +++ b/packages/animate/dts.tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../dts.tsconfig.json", + "include": [ + "**/src/**/*" + ], + "exclude": [ + "node_modules", + "**/tests/**/*" + ] +} diff --git a/packages/animate/package.json b/packages/animate/package.json index 035fee2..fa7a93e 100644 --- a/packages/animate/package.json +++ b/packages/animate/package.json @@ -5,11 +5,12 @@ "publishConfig": { "access": "public", "main": "lib/api.js", - "types": "lib/api.d.ts", + "types": "lib/types/api.d.ts", "browser": "lib/api.js", "node": "lib/api.node.js", "unpkg": "lib/api.js", - "module": "lib/api.modern.js" + "module": "lib/api.modern.js", + "exports": "lib/api.modern.js" }, "main": "src/api.ts", "source": "src/api.ts", @@ -23,9 +24,8 @@ "scripts": { "build": "node ./build", "watch": "node ./build --watch", - "test": "jest --maxWorkers=1", - "test:watch": "jest --maxWorkers=1 --watch --verbose false", - "pre-release": "npm run build && ultra docs:build", + "dts": "tsc --project dts.tsconfig.json", + "pre-release": "npm run build && npm run dts && npm run docs:build", "docs:build": "gulp build", "docs:watch": "gulp default --watch" }, @@ -53,18 +53,19 @@ }, "homepage": "https://github.com/okikio/native#readme", "devDependencies": { - "@types/jest": "^26.0.16", + "@types/jest": "^26.0.18", "browser-sync": "^2.26.13", - "esbuild": "^0.8.20", + "esbuild": "^0.8.21", "esbuild-jest": "^0.3.0", "eslint": "^7.15.0", "gulp": "^4.0.2", - "gulp-esbuild": "^0.3.2", + "gulp-esbuild": "^0.3.4", "gulp-pug": "^4.0.1", "gulp-sass": "^4.1.0", "jest": "^26.6.3", "jest-chain": "^1.1.5", "merge-stream": "^2.0.0", + "typescript": "^4.1.2", "ultra-runner": "^3.6.0" }, "dependencies": { diff --git a/packages/animate/tests/test.ts b/packages/animate/tests/test.ts deleted file mode 100644 index 2209550..0000000 --- a/packages/animate/tests/test.ts +++ /dev/null @@ -1,84 +0,0 @@ -/// -import { Animate } from "../src/api"; -import "jest-chain"; - -/* - Find: @(returns|type) \{([\w_-{,<[\]\s>]+)\} - Replace: @$1 $2 -*/ - -describe("Animate", () => { - let animation: Animate; - - // beforeEach(() => { - // animation = new Animate({ - // target: ".div", - // keyframes(index: number, total: number, element: HTMLElement) { - // return [ - // { transform: "translateX(0px)", opacity: 0 }, - // { transform: "translateX(300px)", opacity: ((index + 1) / total) } - // ] - // }, - // transform: ["translateX(0px)", "translateX(300px)"], - // easing: "out-cubic", - // opacity(index: number, total: number, element: HTMLElement) { - // return [0, ((index + 1) / total)]; - // }, - // duration(index: number) { - // return (index + 1) * 500; - // }, - // onfinish(element: HTMLElement, index: number, total: number) { - // element.style.opacity = `${((index + 1) / total)}`; - // element.style.transform = "translateX(300px)"; - // }, - // loop: 5, - // speed: 1, - // direction: "alternate", - // delay(index: number) { - // return index * 200; - // }, - // autoplay: true, - // endDelay: 500 - // }); - // }); - - describe("#constructor()", () => { - test("argument and options", () => { - let div = { - document: true - }; - console.log(div); - // expect(animation).toBeInstanceOf(Animate); - // expect(animation.getOptions()).toEqual({ - // target: ".div", - // keyframes(index: number, total: number, element: HTMLElement) { - // return [ - // { transform: "translateX(0px)", opacity: 0 }, - // { transform: "translateX(300px)", opacity: ((index + 1) / total) } - // ] - // }, - // transform: ["translateX(0px)", "translateX(300px)"], - // easing: "out-cubic", - // opacity(index: number, total: number, element: HTMLElement) { - // return [0, ((index + 1) / total)]; - // }, - // duration(index: number) { - // return (index + 1) * 500; - // }, - // onfinish(element: HTMLElement, index: number, total: number) { - // element.style.opacity = `${((index + 1) / total)}`; - // element.style.transform = "translateX(300px)"; - // }, - // loop: 5, - // speed: 1, - // direction: "alternate", - // delay(index: number) { - // return index * 200; - // }, - // autoplay: true, - // endDelay: 500 - // }); - }); - }); - -}); diff --git a/packages/emitter/dts.tsconfig.json b/packages/emitter/dts.tsconfig.json new file mode 100644 index 0000000..e577d2b --- /dev/null +++ b/packages/emitter/dts.tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../dts.tsconfig.json", + "include": [ + "**/src/**/*" + ], + "exclude": [ + "node_modules", + "**/tests/**/*" + ] +} diff --git a/packages/emitter/package.json b/packages/emitter/package.json index b32777a..376e492 100644 --- a/packages/emitter/package.json +++ b/packages/emitter/package.json @@ -5,11 +5,12 @@ "publishConfig": { "access": "public", "main": "lib/api.js", - "types": "lib/api.d.ts", + "types": "lib/types/api.d.ts", "browser": "lib/api.js", "node": "lib/api.node.js", "unpkg": "lib/api.js", - "module": "lib/api.modern.js" + "module": "lib/api.modern.js", + "exports": "lib/api.modern.js" }, "main": "src/api.ts", "source": "src/api.ts", @@ -25,7 +26,8 @@ "watch": "node ./build --watch", "test": "jest --maxWorkers=1", "test:watch": "jest --maxWorkers=1 --watch --verbose false", - "pre-release": "npm run build && npm test" + "dts": "tsc --project dts.tsconfig.json", + "pre-release": "npm run build && npm test && npm run dts" }, "repository": { "type": "git", @@ -50,13 +52,14 @@ }, "homepage": "https://github.com/okikio/native#readme", "devDependencies": { - "@types/jest": "^26.0.16", + "@types/jest": "^26.0.18", "chokidar": "^3.4.3", - "esbuild": "^0.8.20", + "esbuild": "^0.8.21", "esbuild-jest": "^0.3.0", "eslint": "^7.15.0", "jest": "^26.6.3", "jest-chain": "^1.1.5", + "typescript": "^4.1.2", "ultra-runner": "^3.6.0" }, "dependencies": { diff --git a/packages/manager/dts.tsconfig.json b/packages/manager/dts.tsconfig.json new file mode 100644 index 0000000..e577d2b --- /dev/null +++ b/packages/manager/dts.tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../dts.tsconfig.json", + "include": [ + "**/src/**/*" + ], + "exclude": [ + "node_modules", + "**/tests/**/*" + ] +} diff --git a/packages/manager/package.json b/packages/manager/package.json index c286784..e8c4e72 100644 --- a/packages/manager/package.json +++ b/packages/manager/package.json @@ -5,11 +5,12 @@ "publishConfig": { "access": "public", "main": "lib/api.js", - "types": "lib/api.d.ts", + "types": "lib/types/api.d.ts", "browser": "lib/api.js", "node": "lib/api.node.js", "unpkg": "lib/api.js", - "module": "lib/api.modern.js" + "module": "lib/api.modern.js", + "exports": "lib/api.modern.js" }, "main": "src/api.ts", "source": "src/api.ts", @@ -25,7 +26,8 @@ "watch": "node ./build --watch", "test": "jest --maxWorkers=1", "test:watch": "jest --maxWorkers=1 --watch --verbose false", - "pre-release": "npm run build && npm test" + "dts": "tsc --project dts.tsconfig.json", + "pre-release": "npm run build && npm test && npm run dts" }, "repository": { "type": "git", @@ -51,14 +53,15 @@ }, "homepage": "https://github.com/okikio/native#readme", "devDependencies": { - "@types/jest": "^26.0.16", + "@types/jest": "^26.0.18", "chokidar": "^3.4.3", - "esbuild": "^0.8.20", + "esbuild": "^0.8.21", "esbuild-jest": "^0.3.0", "eslint": "^7.15.0", "jest": "^26.6.3", "jest-chain": "^1.1.5", "node-fetch": "^2.6.1", + "typescript": "^4.1.2", "ultra-runner": "^3.6.0" }, "gitHead": "ad422076cdb57d570426f786886129d5bca2f90f" diff --git a/packages/native/build-src/ts/services/Splashscreen.ts b/packages/native/build-src/ts/services/Splashscreen.ts index 2f68394..9ce46b1 100644 --- a/packages/native/build-src/ts/services/Splashscreen.ts +++ b/packages/native/build-src/ts/services/Splashscreen.ts @@ -27,14 +27,14 @@ export class Splashscreen extends Service { } public async hide() { - await new Promise(resolve => { + await new Promise(resolve => { window.setTimeout(() => { this.emitter.emit("BEFORE_SPLASHSCREEN_HIDE"); resolve(); }, this.minimalDuration); }); - await new Promise(async resolve => { + await new Promise(async resolve => { animate({ target: this.innerEl, opacity: [1, 0], diff --git a/packages/native/build-src/ts/transitions/BigTransition.ts b/packages/native/build-src/ts/transitions/BigTransition.ts index c390e93..fa06bfd 100644 --- a/packages/native/build-src/ts/transitions/BigTransition.ts +++ b/packages/native/build-src/ts/transitions/BigTransition.ts @@ -23,7 +23,7 @@ export const BigTransition: ITransition = { // behavior: 'smooth' // 👈 // }); - return new Promise(async resolve => { + return new Promise(async resolve => { animate({ target: fromWrapper, opacity: [1, 0], @@ -86,7 +86,7 @@ export const BigTransition: ITransition = { window.scroll(scroll.x, scroll.y); - return new Promise(async resolve => { + return new Promise(async resolve => { animate({ target: toWrapper, opacity: [0, 1], diff --git a/packages/native/build-src/ts/transitions/Fade.ts b/packages/native/build-src/ts/transitions/Fade.ts index 2a769f8..8dc9e75 100644 --- a/packages/native/build-src/ts/transitions/Fade.ts +++ b/packages/native/build-src/ts/transitions/Fade.ts @@ -9,7 +9,7 @@ export const Fade: ITransition = { out({ from }: ITransitionData) { let { duration } = this; let fromWrapper = from.wrapper; - return new Promise(async resolve => { + return new Promise(async resolve => { await animate({ target: fromWrapper, opacity: [1, 0], diff --git a/packages/native/docs/js/main.js b/packages/native/docs/js/main.js index 4eadb5f..1eeb648 100644 --- a/packages/native/docs/js/main.js +++ b/packages/native/docs/js/main.js @@ -1,3 +1,3 @@ -var pt={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},M=class{constructor(t){this.config=Object.assign({...pt},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var h=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},x=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},I=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},v=class extends h{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),m=r=>`${r.pathname}${r.hash}`,W=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),C=(r,t)=>{let e=p(r),i=p(t);return W(e)===W(i)};var S=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),k=(r={url:m(p()),index:0,transition:"default",data:{scroll:S(),trigger:"HistoryManager"}})=>r,F=class{constructor(){this.pointer=-1;this.states=[];let t=k();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=k(t),n=this.length;this.states.push({...i}),this.pointer=n;let a={index:this.pointer,states:[...this.states]};return ct(e,i,a),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}},ct=(r,t,e)=>{let i=m(p(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 ut=new DOMParser,A=class extends I{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=ut.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=this.config.getConfig("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}},D=class extends v{constructor(t){super(t);this.loading=new h;this.maxPages=5;let e=p().pathname;this.set(e,new A),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,a;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?a=this.loading.get(i):(a=this.request(i),this.loading.set(i,a));let o=await a;if(this.loading.delete(i),n=new A(e,o),this.set(i,n),this.size>this.maxPages){let s=p(),l=this.keys(),u=C(s,l[0])?l[1]:l[0],f=this.get(u);f.unregister(),f=void 0,l=void 0,s=void 0,u=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let a=new Error(n.statusText||""+n.status);throw a}catch(n){throw window.clearTimeout(i),n}}};var J=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),L=class extends h{constructor(t="event"){super();this.name=t}},P=class extends h{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof L?e:(this.set(t,new L(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(J({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,a,o=typeof t=="object"&&!Array.isArray(t),s=o?e:i;return o||(a=e),Object.keys(t).forEach(l=>{o?(n=l,a=t[l]):n=t[l],this.newListener(n,a,s)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof L&&e){let a=J({name:t,callback:e,scope:i});n.forEach((o,s)=>{if(o.callback===a.callback&&o.scope===a.scope)return n.delete(s)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,a,o=typeof t=="object"&&!Array.isArray(t),s=o?e:i;return o||(a=e),Object.keys(t).forEach(l=>{o?(n=l,a=t[l]):n=t[l],typeof a=="function"?this.removeListener(n,a,s):this.delete(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 L&&n.forEach(a=>{let{callback:o,scope:s}=a;o.apply(s,e)})},this),this)}};var g=class extends I{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},_=class extends v{constructor(t){super(t)}init(){return x(this,"init",this.app),this}boot(){return x(this,"boot",this.app),this}stop(){return x(this,"stop",this.app),this}};var K=class extends g{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,a=!t||!i,o=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,s=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,u=typeof t.getAttribute("download")=="string",f=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),w=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),y=f&&w,O=m(p())===m(p(i));return!(a||n||o||s||l||u||y||O)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},a=this.HistoryManager.current,o=a.url;if(C(o,t))return;let s;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:u}=l,f=a.index,w=f-u;e=this.getDirection(w);let y=this.HistoryManager.get(this.HistoryManager.pointer);s=y.transition,n=y.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=u,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{s=this.getTransitionName(e)||"default",n=S();let l=k({url:t,transition:s,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:o,href:t,trigger:e,transitionName:s,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:a={x:0,y:0}}){try{let o=await this.PageManager.load(t);await o.build();let s;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:o,trigger:i});try{try{s=await this.PageManager.load(e),await s.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:s,oldPage:o,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:o,newPage:s,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:o,newPage:s,trigger:i,scroll:a});l.scrollable||(/back|popstate|forward/.test(i)||(a=z()),window.scroll(a.x,a.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:o,newPage:s,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(o){this.forceOnError?this.force(e):console.error(o)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}catch(a){console.warn("[PJAX] prefetch error,",a)}}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)}},z=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return S(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return S(0,0)},q=class extends h{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof A)||!(e.newPage instanceof A))throw`[Page] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:e.newPage,oldPage:e.oldPage}}`;let a=e.oldPage.wrapper,o=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(a instanceof Node)||!(o instanceof Node))throw`[Wrapper] the wrapper from the ${o instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&(i==null||i.init(e)),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(s=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:s});l.then&&l.then(s)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(s=>{a.insertAdjacentElement("beforebegin",o),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=z()),s()}),await new Promise(s=>{a.remove(),a=void 0,o=void 0,this.emitter.emit("CONTENT_REPLACED"),s()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(s=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:s});l.then&&l.then(s)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var j=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof M?t:new M(t),this.emitter=new P,this.history=new F,this.pages=new D(this),this.transitions=new q(this),this.services=new _(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 U=class extends g{constructor(t=[]){super();this.routes=new h;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:a}=i;return{from:this.parsePath(n),to:this.parsePath(a)}}route(){let t=this.HistoryManager,e=m(p((t.length>1?t.previous:t.current).url)),i=m(p());this.routes.forEach((n,a)=>{let o=a.from,s=a.to;if(typeof o=="boolean"&&typeof s=="boolean")throw`[Router] path ({ from: ${o}, to: ${s} }) 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 l=o,u=s;o instanceof RegExp&&o.test(e)&&(l=o.exec(e)),s instanceof RegExp&&s.test(i)&&(u=s.exec(i)),(Array.isArray(u)&&Array.isArray(l)||Array.isArray(u)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof u=="boolean"&&u)&&n({from:l,to:u,path:{from:e,to:i}})})}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 ht=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],mt=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?ht(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],Q=(r,t)=>typeof r=="function"?r(...t):r,Z=(r,t)=>{let e,i,n={},a=Object.keys(r);for(let o=0,s=a.length;o/^(ease|in|out)/.test(r)?gt[r]:r,dt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},tt=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new P;let{options:e,...i}=t;this.options=Object.assign({},dt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:a,speed:o,easing:s,endDelay:l,duration:u,direction:f,fillMode:w,onfinish:y,target:O,keyframes:ot,autoplay:at,...lt}=this.options;this.mainElement=document.createElement("span"),this.targets=mt(O),this.properties=lt;let R;for(let d=0,T=this.targets.length;d0||(R=Z(R,[d,T,E]));let B=b.delay+b.duration*b.iterations+b.endDelay;this.duration{y(E,d,T)},this.animations.set(E,Y)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(o),at?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},c=(r={})=>new tt(r);var V=class extends g{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.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=>{c({target:this.innerEl,opacity:[1,0],autoplay:!0,duration:500,onfinish(e){e.style.opacity="0"}}),this.emitter.emit("START_SPLASHSCREEN_HIDE"),await this.show(),t()})}async show(){await c({target:this.rootElement,transform:["translateY(0%)","translateY(100%)"],duration:1200,easing:"in-out-cubic"}),this.rootElement.style.transform="translateY(100%)",this.rootElement.style.visibility="hidden",this.rootElement.style.pointerEvents="none"}},G=class extends g{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(){return await c({target:this.elements,keyframes:[{transform:"translateY(200px)",opacity:0},{transform:"translateY(0px)",opacity:1}],delay(t){return 300*(t+1)},onfinish(t){requestAnimationFrame(()=>{t.style.transform="translateY(0px)",t.style.opacity="1"})},easing:"out-cubic",duration:650})}},et={name:"default",duration:500,scrollable:!0,out({from:r}){let{duration:t}=this,e=r.wrapper;return new Promise(async i=>{await c({target:e,opacity:[1,0],duration:t,onfinish(n){requestAnimationFrame(()=>{n.style.opacity="0"})}}),i()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return requestAnimationFrame(()=>{i.style.transform="translateX(0%)"}),window.scroll(t.x,t.y),c({target:i,opacity:[0,1],duration:e,onfinish(n){requestAnimationFrame(()=>{n.style.opacity="1",n.style={}})}})}},it={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}){let{durationPerAnimation:t,delay:e}=this,i=r.wrapper;return new Promise(async n=>{c({target:i,opacity:[1,0],duration:t,onfinish(s){s.style.opacity="0"}}),this.mainElement.style.opacity="1",this.mainElement.style.visibility="visible",await c({target:this.horizontalElements,keyframes:[{transform:"scaleX(0)"},{transform:"scaleX(1)"}],delay(s){return e*(s+1)},onfinish(s){s.style.transform="scaleX(1)"},easing:"out-cubic",duration:500});let a=500;this.spinnerElement.style.visibility="visible";let o=await c({target:this.spinnerElement,opacity:[0,1],duration:a,onfinish(s){s.style.opacity="1"}});await c({options:o,opacity:[1,0],onfinish(s){s.style.opacity="0"},delay:1500}),this.spinnerElement.style.visibility="hidden",n()})},in({to:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;return n.style.transform="translateX(0%)",window.scroll(t.x,t.y),new Promise(async a=>{c({target:n,opacity:[0,1],onfinish(o){o.style.opacity="1"},duration:e}),await c({target:this.horizontalElements,keyframes:[{transform:"scaleX(1)"},{transform:"scaleX(0)"}],delay(o){return i*(o+1)},onfinish(o){o.style.transform="scaleX(0)"},easing:"out-cubic",duration:500}),this.mainElement.style.opacity="0",this.mainElement.style.visibility="hidden",a()})}},H={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 c({target:i,keyframes:[{transform:"translateX(0%)",opacity:1},{transform:`translateX(${e==="left"?"-":""}25%)`,opacity:0}],duration:t,easing:"in-quint",onfinish:n=>{requestAnimationFrame(()=>{n.style.opacity="0",n.style.transform=`translateX(${e==="left"?"-":""}25%)`})}})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),c({target:i,keyframes:[{transform:`translateX(${this.direction==="right"?"-":""}25%)`,opacity:0},{transform:"translateX(0%)",opacity:1}],duration:e,easing:"out-quint",onfinish(n){requestAnimationFrame(()=>{n.style.opacity="1",n.style.transform="translateX(0%)"})}})}},rt={...H,name:"slide-left",direction:"left"},nt={...H,name:"slide-right",direction:"right"},X=new j,st,$,bt;X.add("service",new G).add("service",st=new V).setService("router",$=new U).add("service",bt=new K).setTransition("default",et).add("transition",it).add("transition",H).add("transition",rt).add("transition",nt);try{$=X.get("service","router");let r=document.querySelectorAll(".navbar .nav-link");for(let t of r){let e=t;$.add({path:e.getAttribute("data-path")||e.pathname,method(){let i=e.classList.contains("active");i||e.classList.add("active");for(let n of r)n!==e&&n.classList.remove("active")}})}X.boot()}catch(r){st.show(),console.warn("[App] boot failed,",r)} +var pt={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},M=class{constructor(t){this.config=Object.assign({...pt},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var h=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},v=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},x=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},I=class extends h{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),m=r=>`${r.pathname}${r.hash}`,W=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),C=(r,t)=>{let e=p(r),i=p(t);return W(e)===W(i)};var S=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),k=(r={url:m(p()),index:0,transition:"default",data:{scroll:S(),trigger:"HistoryManager"}})=>r,F=class{constructor(){this.pointer=-1;this.states=[];let t=k();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=k(t),n=this.length;this.states.push({...i}),this.pointer=n;let a={index:this.pointer,states:[...this.states]};return ct(e,i,a),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}},ct=(r,t,e)=>{let i=m(p(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 ut=new DOMParser,A=class extends x{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=ut.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=this.config.getConfig("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}},D=class extends I{constructor(t){super(t);this.loading=new h;this.maxPages=5;let e=p().pathname;this.set(e,new A),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,a;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?a=this.loading.get(i):(a=this.request(i),this.loading.set(i,a));let o=await a;if(this.loading.delete(i),n=new A(e,o),this.set(i,n),this.size>this.maxPages){let s=p(),l=this.keys(),u=C(s,l[0])?l[1]:l[0],f=this.get(u);f.unregister(),f=void 0,l=void 0,s=void 0,u=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let a=new Error(n.statusText||""+n.status);throw a}catch(n){throw window.clearTimeout(i),n}}};var J=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),L=class extends h{constructor(t="event"){super();this.name=t}},P=class extends h{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof L?e:(this.set(t,new L(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(J({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,a,o=typeof t=="object"&&!Array.isArray(t),s=o?e:i;return o||(a=e),Object.keys(t).forEach(l=>{o?(n=l,a=t[l]):n=t[l],this.newListener(n,a,s)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof L&&e){let a=J({name:t,callback:e,scope:i});n.forEach((o,s)=>{if(o.callback===a.callback&&o.scope===a.scope)return n.delete(s)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,a,o=typeof t=="object"&&!Array.isArray(t),s=o?e:i;return o||(a=e),Object.keys(t).forEach(l=>{o?(n=l,a=t[l]):n=t[l],typeof a=="function"?this.removeListener(n,a,s):this.delete(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 L&&n.forEach(a=>{let{callback:o,scope:s}=a;o.apply(s,e)})},this),this)}};var g=class extends x{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},_=class extends I{constructor(t){super(t)}init(){return v(this,"init",this.app),this}boot(){return v(this,"boot",this.app),this}stop(){return v(this,"stop",this.app),this}};var K=class extends g{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,a=!t||!i,o=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,s=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,u=typeof t.getAttribute("download")=="string",f=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),w=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),y=f&&w,O=m(p())===m(p(i));return!(a||n||o||s||l||u||y||O)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},a=this.HistoryManager.current,o=a.url;if(C(o,t))return;let s;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:u}=l,f=a.index,w=f-u;e=this.getDirection(w);let y=this.HistoryManager.get(this.HistoryManager.pointer);s=y.transition,n=y.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=u,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{s=this.getTransitionName(e)||"default",n=S();let l=k({url:t,transition:s,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:o,href:t,trigger:e,transitionName:s,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:a={x:0,y:0}}){try{let o=await this.PageManager.load(t);await o.build();let s;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:o,trigger:i});try{try{s=await this.PageManager.load(e),await s.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:s,oldPage:o,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:o,newPage:s,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:o,newPage:s,trigger:i,scroll:a});l.scrollable||(/back|popstate|forward/.test(i)||(a=z()),window.scroll(a.x,a.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:o,newPage:s,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(o){this.forceOnError?this.force(e):console.error(o)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}catch(a){console.warn("[PJAX] prefetch error,",a)}}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)}},z=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return S(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return S(0,0)},q=class extends h{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof A)||!(e.newPage instanceof A))throw`[Page] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:e.newPage,oldPage:e.oldPage}}`;let a=e.oldPage.wrapper,o=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(a instanceof Node)||!(o instanceof Node))throw`[Wrapper] the wrapper from the ${o instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&(i==null||i.init(e)),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(s=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:s});l.then&&l.then(s)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(s=>{a.insertAdjacentElement("beforebegin",o),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=z()),s()}),await new Promise(s=>{a.remove(),a=void 0,o=void 0,this.emitter.emit("CONTENT_REPLACED"),s()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(async s=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:s});l.then&&l.then(s)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var j=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof M?t:new M(t),this.emitter=new P,this.history=new F,this.pages=new D(this),this.transitions=new q(this),this.services=new _(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 U=class extends g{constructor(t=[]){super();this.routes=new h;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:a}=i;return{from:this.parsePath(n),to:this.parsePath(a)}}route(){let t=this.HistoryManager,e=m(p((t.length>1?t.previous:t.current).url)),i=m(p());this.routes.forEach((n,a)=>{let o=a.from,s=a.to;if(typeof o=="boolean"&&typeof s=="boolean")throw`[Router] path ({ from: ${o}, to: ${s} }) 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 l=o,u=s;o instanceof RegExp&&o.test(e)&&(l=o.exec(e)),s instanceof RegExp&&s.test(i)&&(u=s.exec(i)),(Array.isArray(u)&&Array.isArray(l)||Array.isArray(u)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof u=="boolean"&&u)&&n({from:l,to:u,path:{from:e,to:i}})})}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 ht=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],mt=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?ht(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],Q=(r,t)=>typeof r=="function"?r(...t):r,Z=(r,t)=>{let e,i,n={},a=Object.keys(r);for(let o=0,s=a.length;o/^(ease|in|out)/.test(r)?gt[r]:r,dt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},tt=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new P;let{options:e,...i}=t;this.options=Object.assign({},dt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:a,speed:o,easing:s,endDelay:l,duration:u,direction:f,fillMode:w,onfinish:y,target:O,keyframes:ot,autoplay:at,...lt}=this.options;this.mainElement=document.createElement("span"),this.targets=mt(O),this.properties=lt;let R;for(let d=0,T=this.targets.length;d0||(R=Z(R,[d,T,E]));let B=b.delay+b.duration*b.iterations+b.endDelay;this.duration{y(E,d,T)},this.animations.set(E,Y)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(o),at?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},c=(r={})=>new tt(r);var V=class extends g{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.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=>{c({target:this.innerEl,opacity:[1,0],autoplay:!0,duration:500,onfinish(e){e.style.opacity="0"}}),this.emitter.emit("START_SPLASHSCREEN_HIDE"),await this.show(),t()})}async show(){await c({target:this.rootElement,transform:["translateY(0%)","translateY(100%)"],duration:1200,easing:"in-out-cubic"}),this.rootElement.style.transform="translateY(100%)",this.rootElement.style.visibility="hidden",this.rootElement.style.pointerEvents="none"}},G=class extends g{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(){return await c({target:this.elements,keyframes:[{transform:"translateY(200px)",opacity:0},{transform:"translateY(0px)",opacity:1}],delay(t){return 300*(t+1)},onfinish(t){requestAnimationFrame(()=>{t.style.transform="translateY(0px)",t.style.opacity="1"})},easing:"out-cubic",duration:650})}},et={name:"default",duration:500,scrollable:!0,out({from:r}){let{duration:t}=this,e=r.wrapper;return new Promise(async i=>{await c({target:e,opacity:[1,0],duration:t,onfinish(n){requestAnimationFrame(()=>{n.style.opacity="0"})}}),i()})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return requestAnimationFrame(()=>{i.style.transform="translateX(0%)"}),window.scroll(t.x,t.y),c({target:i,opacity:[0,1],duration:e,onfinish(n){requestAnimationFrame(()=>{n.style.opacity="1",n.style={}})}})}},it={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}){let{durationPerAnimation:t,delay:e}=this,i=r.wrapper;return new Promise(async n=>{c({target:i,opacity:[1,0],duration:t,onfinish(s){s.style.opacity="0"}}),this.mainElement.style.opacity="1",this.mainElement.style.visibility="visible",await c({target:this.horizontalElements,keyframes:[{transform:"scaleX(0)"},{transform:"scaleX(1)"}],delay(s){return e*(s+1)},onfinish(s){s.style.transform="scaleX(1)"},easing:"out-cubic",duration:500});let a=500;this.spinnerElement.style.visibility="visible";let o=await c({target:this.spinnerElement,opacity:[0,1],duration:a,onfinish(s){s.style.opacity="1"}});await c({options:o,opacity:[1,0],onfinish(s){s.style.opacity="0"},delay:1500}),this.spinnerElement.style.visibility="hidden",n()})},in({to:r,scroll:t}){let{durationPerAnimation:e,delay:i}=this,n=r.wrapper;return n.style.transform="translateX(0%)",window.scroll(t.x,t.y),new Promise(async a=>{c({target:n,opacity:[0,1],onfinish(o){o.style.opacity="1"},duration:e}),await c({target:this.horizontalElements,keyframes:[{transform:"scaleX(1)"},{transform:"scaleX(0)"}],delay(o){return i*(o+1)},onfinish(o){o.style.transform="scaleX(0)"},easing:"out-cubic",duration:500}),this.mainElement.style.opacity="0",this.mainElement.style.visibility="hidden",a()})}},H={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 c({target:i,keyframes:[{transform:"translateX(0%)",opacity:1},{transform:`translateX(${e==="left"?"-":""}25%)`,opacity:0}],duration:t,easing:"in-quint",onfinish:n=>{requestAnimationFrame(()=>{n.style.opacity="0",n.style.transform=`translateX(${e==="left"?"-":""}25%)`})}})},in({to:r,scroll:t}){let{duration:e}=this,i=r.wrapper;return window.scroll(t.x,t.y),c({target:i,keyframes:[{transform:`translateX(${this.direction==="right"?"-":""}25%)`,opacity:0},{transform:"translateX(0%)",opacity:1}],duration:e,easing:"out-quint",onfinish(n){requestAnimationFrame(()=>{n.style.opacity="1",n.style.transform="translateX(0%)"})}})}},rt={...H,name:"slide-left",direction:"left"},nt={...H,name:"slide-right",direction:"right"},X=new j,st,$,bt;X.add("service",new G).add("service",st=new V).setService("router",$=new U).add("service",bt=new K).setTransition("default",et).add("transition",it).add("transition",H).add("transition",rt).add("transition",nt);try{$=X.get("service","router");let r=document.querySelectorAll(".navbar .nav-link");for(let t of r){let e=t;$.add({path:e.getAttribute("data-path")||e.pathname,method(){let i=e.classList.contains("active");i||e.classList.add("active");for(let n of r)n!==e&&n.classList.remove("active")}})}X.boot()}catch(r){st.show(),console.warn("[App] boot failed,",r)} //# sourceMappingURL=main.js.map diff --git a/packages/native/docs/js/main.js.map b/packages/native/docs/js/main.js.map index 7e8b0ce..dedf6c8 100644 --- a/packages/native/docs/js/main.js.map +++ b/packages/native/docs/js/main.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["src/config.ts", "../manager/src/api.ts", "src/manager.ts", "src/url.ts", "src/url.ts", "src/history.ts", "src/page.ts", "../emitter/src/api.ts", "src/service.ts", "src/pjax.ts", "src/transition.ts", "src/app.ts", "src/route.ts", "../animate/src/api.ts", "build-src/ts/services/Splashscreen.ts", "build-src/ts/services/IntroAnimation.ts", "build-src/ts/transitions/Fade.ts", "build-src/ts/transitions/BigTransition.ts", "build-src/ts/transitions/Slide.ts", "build-src/ts/main.ts"], - "sourcesContent": ["// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise((done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n", "import { Service, animate } from \"../../../src/api\";\r\n\r\nexport class Splashscreen extends Service {\r\n public rootElement: HTMLElement;\r\n public innerEl: HTMLElement;\r\n public bgEl: HTMLElement;\r\n public minimalDuration: number = 1000; // ms\r\n\r\n public init() {\r\n super.init();\r\n\r\n // Elements\r\n this.rootElement = document.getElementById('splashscreen');\r\n if (this.rootElement) {\r\n this.innerEl = this.rootElement.querySelector('.splashscreen-inner');\r\n this.bgEl = this.rootElement.querySelector('.splashscreen-bg');\r\n }\r\n\r\n this.rootElement.style.visibility = \"visible\";\r\n this.rootElement.style.pointerEvents = \"auto\";\r\n }\r\n\r\n public boot() {\r\n if (this.rootElement) {\r\n this.hide();\r\n }\r\n }\r\n\r\n public async hide() {\r\n await new Promise(resolve => {\r\n window.setTimeout(() => {\r\n this.emitter.emit(\"BEFORE_SPLASHSCREEN_HIDE\");\r\n resolve();\r\n }, this.minimalDuration);\r\n });\r\n\r\n await new Promise(async resolve => {\r\n animate({\r\n target: this.innerEl,\r\n opacity: [1, 0],\r\n autoplay: true,\r\n duration: 500,\r\n onfinish(el) {\r\n el.style.opacity = \"0\";\r\n }\r\n });\r\n\r\n this.emitter.emit(\"START_SPLASHSCREEN_HIDE\");\r\n\r\n await this.show();\r\n resolve();\r\n });\r\n }\r\n\r\n public async show() {\r\n await animate({\r\n target: this.rootElement,\r\n transform: [\"translateY(0%)\", \"translateY(100%)\"],\r\n duration: 1200,\r\n easing: \"in-out-cubic\" // in-out-cubic\r\n });\r\n\r\n this.rootElement.style.transform = \"translateY(100%)\";\r\n this.rootElement.style.visibility = \"hidden\";\r\n this.rootElement.style.pointerEvents = \"none\";\r\n }\r\n}\r\n", "import { Service, animate } from \"../../../src/api\";\r\n\r\nexport class IntroAnimation extends Service {\r\n public elements: Array;\r\n public rootElement: HTMLElement;\r\n\r\n public init() {\r\n super.init();\r\n\r\n // Elements\r\n this.elements = [...document.querySelectorAll('.intro-animation')];\r\n }\r\n\r\n public newPage() {\r\n this.init();\r\n this.prepareToShow();\r\n }\r\n\r\n public initEvents() {\r\n this.emitter.on(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.newPage, this);\r\n this.emitter.on(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\r\n }\r\n\r\n public stopEvents() {\r\n this.emitter.off(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.newPage, this);\r\n this.emitter.off(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\r\n }\r\n\r\n public stop() {\r\n requestAnimationFrame(() => {\r\n for (let el of this.elements) {\r\n (el as HTMLElement).style.transform = \"translateY(0px)\";\r\n (el as HTMLElement).style.opacity = '1';\r\n }\r\n });\r\n\r\n super.stop();\r\n }\r\n\r\n public prepareToShow() {\r\n requestAnimationFrame(() => {\r\n for (let el of this.elements) {\r\n (el as HTMLElement).style.transform = \"translateY(200px)\";\r\n (el as HTMLElement).style.opacity = '0';\r\n }\r\n });\r\n }\r\n\r\n public async show() {\r\n return await animate({\r\n target: (this.elements as HTMLElement[]),\r\n keyframes: [\r\n { transform: \"translateY(200px)\", opacity: 0 },\r\n { transform: \"translateY(0px)\", opacity: 1 },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return 300 * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; opacity: string; }; }) {\r\n requestAnimationFrame(() => {\r\n el.style.transform = \"translateY(0px)\";\r\n el.style.opacity = \"1\";\r\n });\r\n },\r\n easing: \"out-cubic\",\r\n duration: 650\r\n });\r\n }\r\n}\r\n// import { Block, IBlockInit, animate } from \"../../../src/api\";\r\n\r\n// //== Blocks\r\n// export class InViewBlock extends Block {\r\n// public observer: IntersectionObserver;\r\n// public observerOptions: { root: any; rootMargin: string; threshold?: number, thresholds?: Array; };\r\n// public imgs: HTMLElement[];\r\n// public direction: string;\r\n// public xPercent: number;\r\n// public inView: boolean = false;\r\n\r\n// public init(value: IBlockInit) {\r\n// super.init(value);\r\n\r\n// // Values\r\n// this.observerOptions = {\r\n// root: null,\r\n// rootMargin: '0px',\r\n// thresholds: Array.from(Array(20), (_nul, x) => (x + 1) / 20)\r\n// };\r\n\r\n// // Create observer\r\n// this.observer = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {\r\n// this.onIntersectionCallback(entries);\r\n// }, this.observerOptions);\r\n\r\n// // Prepare values\r\n// this.imgs = [];\r\n// this.direction = \"right\";\r\n// this.xPercent = 30;\r\n\r\n// if (this.rootElement.hasAttribute('data-direction')) {\r\n// this.direction = this.rootElement.getAttribute('data-direction');\r\n// }\r\n\r\n// if (this.direction === 'left') {\r\n// this.xPercent = -this.xPercent;\r\n// }\r\n\r\n// // Find elements\r\n// this.imgs = [...this.rootElement.querySelectorAll('img')];\r\n\r\n// // Add block rootElement in the observer\r\n// this.observe();\r\n// }\r\n\r\n// public observe() {\r\n// this.observer.observe(this.rootElement);\r\n// }\r\n\r\n// public unobserve() {\r\n// this.observer.unobserve(this.rootElement);\r\n// }\r\n\r\n// public onScreen() {\r\n// animate({\r\n// target: this.rootElement,\r\n// transform: [`translateX(${this.xPercent}%)`, \"translateX(0%)\"],\r\n// opacity: [0, 1],\r\n// duration: 1500,\r\n// delay: 0.15,\r\n// easing: \"out-quint\",\r\n// onfinish(el) {\r\n// requestAnimationFrame(() => {\r\n// el.style.transform = \"translateX(0%)\";\r\n// el.style.opacity = \"1\";\r\n// });\r\n// },\r\n// });\r\n// }\r\n\r\n// public offScreen() {\r\n// requestAnimationFrame(() => {\r\n// this.rootElement.style.transform = `translateX(${this.xPercent}%)`;\r\n// this.rootElement.style.opacity = \"0\";\r\n// });\r\n// }\r\n\r\n// public onIntersectionCallback(entries: IntersectionObserverEntry[]) {\r\n// for (let entry of entries) {\r\n// if (entry.intersectionRatio > 0) {\r\n// this.onScreen();\r\n// } else {\r\n// this.offScreen();\r\n// }\r\n// }\r\n// }\r\n\r\n// public stopEvents() {\r\n// this.unobserve();\r\n// }\r\n// }\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transition\r\nexport const Fade: ITransition = {\r\n name: \"default\",\r\n duration: 500,\r\n scrollable: true,\r\n\r\n out({ from }: ITransitionData) {\r\n let { duration } = this;\r\n let fromWrapper = from.wrapper;\r\n return new Promise(async resolve => {\r\n await animate({\r\n target: fromWrapper,\r\n opacity: [1, 0],\r\n duration,\r\n onfinish(el: { style: { opacity: string } }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = \"0\";\r\n });\r\n }\r\n });\r\n resolve();\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { duration } = this;\r\n let toWrapper = to.wrapper;\r\n requestAnimationFrame(() => {\r\n toWrapper.style.transform = \"translateX(0%)\";\r\n });\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return animate({\r\n target: toWrapper,\r\n opacity: [0, 1],\r\n duration,\r\n onfinish(el: { style: { opacity?: string } }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = \"1\";\r\n el.style = {};\r\n });\r\n }\r\n });\r\n }\r\n};\r\n// export class Fade extends Transition {\r\n// public name = \"default\";\r\n// public duration = 500;\r\n\r\n// out({ from }: ITransitionData) {\r\n// let { duration } = this;\r\n// let fromWrapper = from.wrapper;\r\n// return new Promise(async resolve => {\r\n// await animate({\r\n// target: fromWrapper,\r\n// opacity: [1, 0],\r\n// duration,\r\n// onfinish(el: { style: { opacity: string } }) {\r\n// requestAnimationFrame(() => {\r\n// el.style.opacity = \"0\";\r\n// });\r\n// }\r\n// });\r\n// resolve();\r\n// });\r\n// }\r\n\r\n// in({ to }: ITransitionData) {\r\n// let { duration } = this;\r\n// let toWrapper = to.wrapper;\r\n// requestAnimationFrame(() => {\r\n// toWrapper.style.transform = \"translateX(0%)\";\r\n// });\r\n\r\n// return animate({\r\n// target: toWrapper,\r\n// opacity: [0, 1],\r\n// duration,\r\n// onfinish(el: { style: { opacity?: string } }) {\r\n// requestAnimationFrame(() => {\r\n// el.style.opacity = \"1\";\r\n// el.style = {};\r\n// });\r\n// }\r\n// });\r\n// }\r\n// }\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transitions\r\nexport const BigTransition: ITransition = {\r\n name: \"big\",\r\n delay: 200,\r\n durationPerAnimation: 700,\r\n scrollable: true,\r\n\r\n init() {\r\n this.mainElement = document.getElementById('big-transition');\r\n this.spinnerElement = this.mainElement.querySelector('.spinner');\r\n this.horizontalElements = [...this.mainElement.querySelector('#big-transition-horizontal').querySelectorAll('div')];\r\n this.maxLength = this.horizontalElements.length;\r\n // console.log(this.mainElement);\r\n },\r\n\r\n out({ from }: ITransitionData) {\r\n let { durationPerAnimation: duration, delay } = this;\r\n let fromWrapper = from.wrapper;\r\n // window.scroll({\r\n // top: 0,\r\n // behavior: 'smooth' // \uD83D\uDC48\r\n // });\r\n\r\n return new Promise(async resolve => {\r\n animate({\r\n target: fromWrapper,\r\n opacity: [1, 0],\r\n duration,\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = '0';\r\n }\r\n });\r\n\r\n this.mainElement.style.opacity = \"1\";\r\n this.mainElement.style.visibility = \"visible\";\r\n\r\n await animate({\r\n target: this.horizontalElements,\r\n keyframes: [\r\n { transform: \"scaleX(0)\" },\r\n { transform: \"scaleX(1)\" },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return delay * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; }; }) {\r\n el.style.transform = `scaleX(1)`;\r\n },\r\n easing: \"out-cubic\",\r\n duration: 500\r\n });\r\n\r\n let loaderDuration = 500;\r\n this.spinnerElement.style.visibility = \"visible\";\r\n\r\n let options = await animate({\r\n target: this.spinnerElement,\r\n opacity: [0, 1],\r\n duration: loaderDuration,\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `1`;\r\n },\r\n });\r\n\r\n await animate({\r\n options,\r\n opacity: [1, 0],\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `0`;\r\n },\r\n delay: 1500\r\n });\r\n\r\n this.spinnerElement.style.visibility = \"hidden\";\r\n resolve();\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { durationPerAnimation: duration, delay } = this;\r\n let toWrapper = to.wrapper;\r\n toWrapper.style.transform = \"translateX(0%)\";\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return new Promise(async resolve => {\r\n animate({\r\n target: toWrapper,\r\n opacity: [0, 1],\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `1`;\r\n },\r\n duration\r\n });\r\n\r\n await animate({\r\n target: this.horizontalElements,\r\n keyframes: [\r\n { transform: \"scaleX(1)\" },\r\n { transform: \"scaleX(0)\" },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return delay * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; }; }) {\r\n el.style.transform = `scaleX(0)`;\r\n },\r\n easing: \"out-cubic\",\r\n duration: 500\r\n });\r\n\r\n this.mainElement.style.opacity = \"0\";\r\n this.mainElement.style.visibility = \"hidden\";\r\n resolve();\r\n });\r\n }\r\n}\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transitions\r\nexport const Slide: ITransition = {\r\n name: \"slide\",\r\n duration: 500,\r\n direction: \"right\",\r\n scrollable: true,\r\n\r\n init(data: ITransition) {\r\n let trigger = (data.trigger as HTMLElement);\r\n if (trigger instanceof Node && trigger.hasAttribute(\"data-direction\")) {\r\n this.direction = trigger.getAttribute(\"data-direction\");\r\n } else {\r\n this.direction = \"right\";\r\n }\r\n },\r\n\r\n out({ from }: ITransitionData) {\r\n let { duration, direction } = this;\r\n let fromWrapper = from.wrapper;\r\n\r\n return animate({\r\n target: fromWrapper,\r\n keyframes: [\r\n { transform: \"translateX(0%)\", opacity: 1 },\r\n { transform: `translateX(${direction === \"left\" ? \"-\" : \"\"}25%)`, opacity: 0 },\r\n ],\r\n duration,\r\n easing: \"in-quint\",\r\n onfinish: (el: { style: { opacity: string; transform: string; }; }) => {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = '0';\r\n el.style.transform = `translateX(${direction === \"left\" ? \"-\" : \"\"}25%)`;\r\n });\r\n }\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { duration } = this;\r\n let toWrapper = to.wrapper;\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return animate({\r\n target: toWrapper,\r\n keyframes: [\r\n { transform: `translateX(${this.direction === \"right\" ? \"-\" : \"\"}25%)`, opacity: 0 },\r\n { transform: \"translateX(0%)\", opacity: 1 },\r\n ],\r\n duration,\r\n easing: \"out-quint\",\r\n onfinish(el: { style: { opacity: string; transform: string; }; }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = '1';\r\n el.style.transform = `translateX(0%)`;\r\n });\r\n }\r\n });\r\n }\r\n};\r\n\r\nexport const SlideLeft: ITransition = {\r\n ...Slide,\r\n\r\n name: \"slide-left\",\r\n direction: \"left\",\r\n};\r\n\r\nexport const SlideRight: ITransition = {\r\n ...Slide,\r\n\r\n name: \"slide-right\",\r\n direction: \"right\",\r\n};\r\n", "import { PJAX, App, Router } from \"../../src/api\";\r\n\r\nimport { Splashscreen } from \"./services/Splashscreen\";\r\nimport { IntroAnimation } from \"./services/IntroAnimation\";\r\n\r\nimport { Fade } from \"./transitions/Fade\";\r\nimport { BigTransition } from \"./transitions/BigTransition\";\r\nimport { Slide, SlideLeft, SlideRight } from \"./transitions/Slide\";\r\n\r\nconst app: App = new App();\r\nlet splashscreen: Splashscreen;\r\nlet router: Router, pjax: PJAX;\r\n\r\napp\r\n .add(\"service\", new IntroAnimation())\r\n .add(\"service\", splashscreen = new Splashscreen())\r\n .setService(\"router\", router = new Router())\r\n .add(\"service\", pjax = new PJAX())\r\n .setTransition(\"default\", Fade)\r\n .add(\"transition\", BigTransition)\r\n .add(\"transition\", Slide)\r\n .add(\"transition\", SlideLeft)\r\n .add(\"transition\", SlideRight);\r\n\r\ntry {\r\n router = app.get(\"service\", \"router\") as Router;\r\n\r\n // This isn't nessceary, but it changes the nav link in focus depending on the page\r\n let navLink = document.querySelectorAll(\".navbar .nav-link\");\r\n for (let item of navLink) {\r\n let navItem = (item as HTMLAnchorElement);\r\n router.add({\r\n path: navItem.getAttribute(\"data-path\") || navItem.pathname,\r\n method() {\r\n let isActive = navItem.classList.contains(\"active\");\r\n if (!isActive) navItem.classList.add(\"active\");\r\n for (let nav of navLink) {\r\n if (nav !== navItem)\r\n nav.classList.remove(\"active\");\r\n }\r\n }\r\n });\r\n }\r\n app.boot();\r\n} catch (err) {\r\n splashscreen.show();\r\n console.warn(\"[App] boot failed,\", err);\r\n}\r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,IACnB,EAAG,MAAM,UAAY,2BAOH,IAC/B,EAEH,KAAM,aACN,UAAW,WAGwB,IAChC,EAEH,KAAM,cACN,UAAW,SCjET,EAAW,GAAI,WAIrB,EACK,IAAI,UAAW,GAAI,IACnB,IAAI,UAAW,GAAe,GAAI,IAClC,WAAW,SAAU,EAAS,GAAI,IAClC,IAAI,UAAW,GAAO,GAAI,IAC1B,cAAc,UAAW,IACzB,IAAI,aAAc,IAClB,IAAI,aAAc,GAClB,IAAI,aAAc,IAClB,IAAI,aAAc,IAEvB,IACI,EAAS,EAAI,IAAI,UAAW,UAG5B,MAAc,SAAS,iBAAiB,qBACxC,YAAiB,IACb,MAAe,EACf,EAAO,IAAI,CACP,KAAM,EAAQ,aAAa,cAAgB,EAAQ,SACnD,SACI,MAAe,EAAQ,UAAU,SAAS,UAC1C,AAAK,GAAU,EAAQ,UAAU,IAAI,UACrC,YAAgB,GACZ,AAAI,IAAQ,GACR,EAAI,UAAU,OAAO,aAKzC,EAAI,gBAEJ,GAAa,OACb,QAAQ,KAAK,qBAAsB", + "sourcesContent": ["// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise(async (done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n", "import { Service, animate } from \"../../../src/api\";\r\n\r\nexport class Splashscreen extends Service {\r\n public rootElement: HTMLElement;\r\n public innerEl: HTMLElement;\r\n public bgEl: HTMLElement;\r\n public minimalDuration: number = 1000; // ms\r\n\r\n public init() {\r\n super.init();\r\n\r\n // Elements\r\n this.rootElement = document.getElementById('splashscreen');\r\n if (this.rootElement) {\r\n this.innerEl = this.rootElement.querySelector('.splashscreen-inner');\r\n this.bgEl = this.rootElement.querySelector('.splashscreen-bg');\r\n }\r\n\r\n this.rootElement.style.visibility = \"visible\";\r\n this.rootElement.style.pointerEvents = \"auto\";\r\n }\r\n\r\n public boot() {\r\n if (this.rootElement) {\r\n this.hide();\r\n }\r\n }\r\n\r\n public async hide() {\r\n await new Promise(resolve => {\r\n window.setTimeout(() => {\r\n this.emitter.emit(\"BEFORE_SPLASHSCREEN_HIDE\");\r\n resolve();\r\n }, this.minimalDuration);\r\n });\r\n\r\n await new Promise(async resolve => {\r\n animate({\r\n target: this.innerEl,\r\n opacity: [1, 0],\r\n autoplay: true,\r\n duration: 500,\r\n onfinish(el) {\r\n el.style.opacity = \"0\";\r\n }\r\n });\r\n\r\n this.emitter.emit(\"START_SPLASHSCREEN_HIDE\");\r\n\r\n await this.show();\r\n resolve();\r\n });\r\n }\r\n\r\n public async show() {\r\n await animate({\r\n target: this.rootElement,\r\n transform: [\"translateY(0%)\", \"translateY(100%)\"],\r\n duration: 1200,\r\n easing: \"in-out-cubic\" // in-out-cubic\r\n });\r\n\r\n this.rootElement.style.transform = \"translateY(100%)\";\r\n this.rootElement.style.visibility = \"hidden\";\r\n this.rootElement.style.pointerEvents = \"none\";\r\n }\r\n}\r\n", "import { Service, animate } from \"../../../src/api\";\r\n\r\nexport class IntroAnimation extends Service {\r\n public elements: Array;\r\n public rootElement: HTMLElement;\r\n\r\n public init() {\r\n super.init();\r\n\r\n // Elements\r\n this.elements = [...document.querySelectorAll('.intro-animation')];\r\n }\r\n\r\n public newPage() {\r\n this.init();\r\n this.prepareToShow();\r\n }\r\n\r\n public initEvents() {\r\n this.emitter.on(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.newPage, this);\r\n this.emitter.on(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\r\n }\r\n\r\n public stopEvents() {\r\n this.emitter.off(\"BEFORE_SPLASHSCREEN_HIDE\", this.prepareToShow, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.newPage, this);\r\n this.emitter.off(\"START_SPLASHSCREEN_HIDE BEFORE_TRANSITION_IN\", this.show, this);\r\n }\r\n\r\n public stop() {\r\n requestAnimationFrame(() => {\r\n for (let el of this.elements) {\r\n (el as HTMLElement).style.transform = \"translateY(0px)\";\r\n (el as HTMLElement).style.opacity = '1';\r\n }\r\n });\r\n\r\n super.stop();\r\n }\r\n\r\n public prepareToShow() {\r\n requestAnimationFrame(() => {\r\n for (let el of this.elements) {\r\n (el as HTMLElement).style.transform = \"translateY(200px)\";\r\n (el as HTMLElement).style.opacity = '0';\r\n }\r\n });\r\n }\r\n\r\n public async show() {\r\n return await animate({\r\n target: (this.elements as HTMLElement[]),\r\n keyframes: [\r\n { transform: \"translateY(200px)\", opacity: 0 },\r\n { transform: \"translateY(0px)\", opacity: 1 },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return 300 * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; opacity: string; }; }) {\r\n requestAnimationFrame(() => {\r\n el.style.transform = \"translateY(0px)\";\r\n el.style.opacity = \"1\";\r\n });\r\n },\r\n easing: \"out-cubic\",\r\n duration: 650\r\n });\r\n }\r\n}\r\n// import { Block, IBlockInit, animate } from \"../../../src/api\";\r\n\r\n// //== Blocks\r\n// export class InViewBlock extends Block {\r\n// public observer: IntersectionObserver;\r\n// public observerOptions: { root: any; rootMargin: string; threshold?: number, thresholds?: Array; };\r\n// public imgs: HTMLElement[];\r\n// public direction: string;\r\n// public xPercent: number;\r\n// public inView: boolean = false;\r\n\r\n// public init(value: IBlockInit) {\r\n// super.init(value);\r\n\r\n// // Values\r\n// this.observerOptions = {\r\n// root: null,\r\n// rootMargin: '0px',\r\n// thresholds: Array.from(Array(20), (_nul, x) => (x + 1) / 20)\r\n// };\r\n\r\n// // Create observer\r\n// this.observer = new IntersectionObserver((entries: IntersectionObserverEntry[]) => {\r\n// this.onIntersectionCallback(entries);\r\n// }, this.observerOptions);\r\n\r\n// // Prepare values\r\n// this.imgs = [];\r\n// this.direction = \"right\";\r\n// this.xPercent = 30;\r\n\r\n// if (this.rootElement.hasAttribute('data-direction')) {\r\n// this.direction = this.rootElement.getAttribute('data-direction');\r\n// }\r\n\r\n// if (this.direction === 'left') {\r\n// this.xPercent = -this.xPercent;\r\n// }\r\n\r\n// // Find elements\r\n// this.imgs = [...this.rootElement.querySelectorAll('img')];\r\n\r\n// // Add block rootElement in the observer\r\n// this.observe();\r\n// }\r\n\r\n// public observe() {\r\n// this.observer.observe(this.rootElement);\r\n// }\r\n\r\n// public unobserve() {\r\n// this.observer.unobserve(this.rootElement);\r\n// }\r\n\r\n// public onScreen() {\r\n// animate({\r\n// target: this.rootElement,\r\n// transform: [`translateX(${this.xPercent}%)`, \"translateX(0%)\"],\r\n// opacity: [0, 1],\r\n// duration: 1500,\r\n// delay: 0.15,\r\n// easing: \"out-quint\",\r\n// onfinish(el) {\r\n// requestAnimationFrame(() => {\r\n// el.style.transform = \"translateX(0%)\";\r\n// el.style.opacity = \"1\";\r\n// });\r\n// },\r\n// });\r\n// }\r\n\r\n// public offScreen() {\r\n// requestAnimationFrame(() => {\r\n// this.rootElement.style.transform = `translateX(${this.xPercent}%)`;\r\n// this.rootElement.style.opacity = \"0\";\r\n// });\r\n// }\r\n\r\n// public onIntersectionCallback(entries: IntersectionObserverEntry[]) {\r\n// for (let entry of entries) {\r\n// if (entry.intersectionRatio > 0) {\r\n// this.onScreen();\r\n// } else {\r\n// this.offScreen();\r\n// }\r\n// }\r\n// }\r\n\r\n// public stopEvents() {\r\n// this.unobserve();\r\n// }\r\n// }\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transition\r\nexport const Fade: ITransition = {\r\n name: \"default\",\r\n duration: 500,\r\n scrollable: true,\r\n\r\n out({ from }: ITransitionData) {\r\n let { duration } = this;\r\n let fromWrapper = from.wrapper;\r\n return new Promise(async resolve => {\r\n await animate({\r\n target: fromWrapper,\r\n opacity: [1, 0],\r\n duration,\r\n onfinish(el: { style: { opacity: string } }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = \"0\";\r\n });\r\n }\r\n });\r\n resolve();\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { duration } = this;\r\n let toWrapper = to.wrapper;\r\n requestAnimationFrame(() => {\r\n toWrapper.style.transform = \"translateX(0%)\";\r\n });\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return animate({\r\n target: toWrapper,\r\n opacity: [0, 1],\r\n duration,\r\n onfinish(el: { style: { opacity?: string } }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = \"1\";\r\n el.style = {};\r\n });\r\n }\r\n });\r\n }\r\n};\r\n// export class Fade extends Transition {\r\n// public name = \"default\";\r\n// public duration = 500;\r\n\r\n// out({ from }: ITransitionData) {\r\n// let { duration } = this;\r\n// let fromWrapper = from.wrapper;\r\n// return new Promise(async resolve => {\r\n// await animate({\r\n// target: fromWrapper,\r\n// opacity: [1, 0],\r\n// duration,\r\n// onfinish(el: { style: { opacity: string } }) {\r\n// requestAnimationFrame(() => {\r\n// el.style.opacity = \"0\";\r\n// });\r\n// }\r\n// });\r\n// resolve();\r\n// });\r\n// }\r\n\r\n// in({ to }: ITransitionData) {\r\n// let { duration } = this;\r\n// let toWrapper = to.wrapper;\r\n// requestAnimationFrame(() => {\r\n// toWrapper.style.transform = \"translateX(0%)\";\r\n// });\r\n\r\n// return animate({\r\n// target: toWrapper,\r\n// opacity: [0, 1],\r\n// duration,\r\n// onfinish(el: { style: { opacity?: string } }) {\r\n// requestAnimationFrame(() => {\r\n// el.style.opacity = \"1\";\r\n// el.style = {};\r\n// });\r\n// }\r\n// });\r\n// }\r\n// }\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transitions\r\nexport const BigTransition: ITransition = {\r\n name: \"big\",\r\n delay: 200,\r\n durationPerAnimation: 700,\r\n scrollable: true,\r\n\r\n init() {\r\n this.mainElement = document.getElementById('big-transition');\r\n this.spinnerElement = this.mainElement.querySelector('.spinner');\r\n this.horizontalElements = [...this.mainElement.querySelector('#big-transition-horizontal').querySelectorAll('div')];\r\n this.maxLength = this.horizontalElements.length;\r\n // console.log(this.mainElement);\r\n },\r\n\r\n out({ from }: ITransitionData) {\r\n let { durationPerAnimation: duration, delay } = this;\r\n let fromWrapper = from.wrapper;\r\n // window.scroll({\r\n // top: 0,\r\n // behavior: 'smooth' // \uD83D\uDC48\r\n // });\r\n\r\n return new Promise(async resolve => {\r\n animate({\r\n target: fromWrapper,\r\n opacity: [1, 0],\r\n duration,\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = '0';\r\n }\r\n });\r\n\r\n this.mainElement.style.opacity = \"1\";\r\n this.mainElement.style.visibility = \"visible\";\r\n\r\n await animate({\r\n target: this.horizontalElements,\r\n keyframes: [\r\n { transform: \"scaleX(0)\" },\r\n { transform: \"scaleX(1)\" },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return delay * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; }; }) {\r\n el.style.transform = `scaleX(1)`;\r\n },\r\n easing: \"out-cubic\",\r\n duration: 500\r\n });\r\n\r\n let loaderDuration = 500;\r\n this.spinnerElement.style.visibility = \"visible\";\r\n\r\n let options = await animate({\r\n target: this.spinnerElement,\r\n opacity: [0, 1],\r\n duration: loaderDuration,\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `1`;\r\n },\r\n });\r\n\r\n await animate({\r\n options,\r\n opacity: [1, 0],\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `0`;\r\n },\r\n delay: 1500\r\n });\r\n\r\n this.spinnerElement.style.visibility = \"hidden\";\r\n resolve();\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { durationPerAnimation: duration, delay } = this;\r\n let toWrapper = to.wrapper;\r\n toWrapper.style.transform = \"translateX(0%)\";\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return new Promise(async resolve => {\r\n animate({\r\n target: toWrapper,\r\n opacity: [0, 1],\r\n onfinish(el: { style: { opacity: string; }; }) {\r\n el.style.opacity = `1`;\r\n },\r\n duration\r\n });\r\n\r\n await animate({\r\n target: this.horizontalElements,\r\n keyframes: [\r\n { transform: \"scaleX(1)\" },\r\n { transform: \"scaleX(0)\" },\r\n ],\r\n // @ts-ignore\r\n delay(i: number) {\r\n return delay * (i + 1);\r\n },\r\n onfinish(el: { style: { transform: string; }; }) {\r\n el.style.transform = `scaleX(0)`;\r\n },\r\n easing: \"out-cubic\",\r\n duration: 500\r\n });\r\n\r\n this.mainElement.style.opacity = \"0\";\r\n this.mainElement.style.visibility = \"hidden\";\r\n resolve();\r\n });\r\n }\r\n}\r\n", "import { ITransition, ITransitionData, animate, hashAction } from \"../../../src/api\";\r\n\r\n//== Transitions\r\nexport const Slide: ITransition = {\r\n name: \"slide\",\r\n duration: 500,\r\n direction: \"right\",\r\n scrollable: true,\r\n\r\n init(data: ITransition) {\r\n let trigger = (data.trigger as HTMLElement);\r\n if (trigger instanceof Node && trigger.hasAttribute(\"data-direction\")) {\r\n this.direction = trigger.getAttribute(\"data-direction\");\r\n } else {\r\n this.direction = \"right\";\r\n }\r\n },\r\n\r\n out({ from }: ITransitionData) {\r\n let { duration, direction } = this;\r\n let fromWrapper = from.wrapper;\r\n\r\n return animate({\r\n target: fromWrapper,\r\n keyframes: [\r\n { transform: \"translateX(0%)\", opacity: 1 },\r\n { transform: `translateX(${direction === \"left\" ? \"-\" : \"\"}25%)`, opacity: 0 },\r\n ],\r\n duration,\r\n easing: \"in-quint\",\r\n onfinish: (el: { style: { opacity: string; transform: string; }; }) => {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = '0';\r\n el.style.transform = `translateX(${direction === \"left\" ? \"-\" : \"\"}25%)`;\r\n });\r\n }\r\n });\r\n },\r\n\r\n in({ to, scroll }: ITransitionData) {\r\n let { duration } = this;\r\n let toWrapper = to.wrapper;\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n\r\n return animate({\r\n target: toWrapper,\r\n keyframes: [\r\n { transform: `translateX(${this.direction === \"right\" ? \"-\" : \"\"}25%)`, opacity: 0 },\r\n { transform: \"translateX(0%)\", opacity: 1 },\r\n ],\r\n duration,\r\n easing: \"out-quint\",\r\n onfinish(el: { style: { opacity: string; transform: string; }; }) {\r\n requestAnimationFrame(() => {\r\n el.style.opacity = '1';\r\n el.style.transform = `translateX(0%)`;\r\n });\r\n }\r\n });\r\n }\r\n};\r\n\r\nexport const SlideLeft: ITransition = {\r\n ...Slide,\r\n\r\n name: \"slide-left\",\r\n direction: \"left\",\r\n};\r\n\r\nexport const SlideRight: ITransition = {\r\n ...Slide,\r\n\r\n name: \"slide-right\",\r\n direction: \"right\",\r\n};\r\n", "import { PJAX, App, Router } from \"../../src/api\";\r\n\r\nimport { Splashscreen } from \"./services/Splashscreen\";\r\nimport { IntroAnimation } from \"./services/IntroAnimation\";\r\n\r\nimport { Fade } from \"./transitions/Fade\";\r\nimport { BigTransition } from \"./transitions/BigTransition\";\r\nimport { Slide, SlideLeft, SlideRight } from \"./transitions/Slide\";\r\n\r\nconst app: App = new App();\r\nlet splashscreen: Splashscreen;\r\nlet router: Router, pjax: PJAX;\r\n\r\napp\r\n .add(\"service\", new IntroAnimation())\r\n .add(\"service\", splashscreen = new Splashscreen())\r\n .setService(\"router\", router = new Router())\r\n .add(\"service\", pjax = new PJAX())\r\n .setTransition(\"default\", Fade)\r\n .add(\"transition\", BigTransition)\r\n .add(\"transition\", Slide)\r\n .add(\"transition\", SlideLeft)\r\n .add(\"transition\", SlideRight);\r\n\r\ntry {\r\n router = app.get(\"service\", \"router\") as Router;\r\n\r\n // This isn't nessceary, but it changes the nav link in focus depending on the page\r\n let navLink = document.querySelectorAll(\".navbar .nav-link\");\r\n for (let item of navLink) {\r\n let navItem = (item as HTMLAnchorElement);\r\n router.add({\r\n path: navItem.getAttribute(\"data-path\") || navItem.pathname,\r\n method() {\r\n let isActive = navItem.classList.contains(\"active\");\r\n if (!isActive) navItem.classList.add(\"active\");\r\n for (let nav of navLink) {\r\n if (nav !== navItem)\r\n nav.classList.remove(\"active\");\r\n }\r\n }\r\n });\r\n }\r\n app.boot();\r\n} catch (err) {\r\n splashscreen.show();\r\n console.warn(\"[App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ClB,EAAG,MAAM,QAAU,IACnB,EAAG,MAAM,UAAY,2BAOH,IAC/B,EAEH,KAAM,aACN,UAAW,WAGwB,IAChC,EAEH,KAAM,cACN,UAAW,SCjET,EAAW,GAAI,WAIrB,EACK,IAAI,UAAW,GAAI,IACnB,IAAI,UAAW,GAAe,GAAI,IAClC,WAAW,SAAU,EAAS,GAAI,IAClC,IAAI,UAAW,GAAO,GAAI,IAC1B,cAAc,UAAW,IACzB,IAAI,aAAc,IAClB,IAAI,aAAc,GAClB,IAAI,aAAc,IAClB,IAAI,aAAc,IAEvB,IACI,EAAS,EAAI,IAAI,UAAW,UAG5B,MAAc,SAAS,iBAAiB,qBACxC,YAAiB,IACb,MAAe,EACf,EAAO,IAAI,CACP,KAAM,EAAQ,aAAa,cAAgB,EAAQ,SACnD,SACI,MAAe,EAAQ,UAAU,SAAS,UAC1C,AAAK,GAAU,EAAQ,UAAU,IAAI,UACrC,YAAgB,GACZ,AAAI,IAAQ,GACR,EAAI,UAAU,OAAO,aAKzC,EAAI,gBAEJ,GAAa,OACb,QAAQ,KAAK,qBAAsB", "names": [] } diff --git a/packages/native/dts.tsconfig.json b/packages/native/dts.tsconfig.json new file mode 100644 index 0000000..e577d2b --- /dev/null +++ b/packages/native/dts.tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../dts.tsconfig.json", + "include": [ + "**/src/**/*" + ], + "exclude": [ + "node_modules", + "**/tests/**/*" + ] +} diff --git a/packages/native/lib/api.js b/packages/native/lib/api.js index 142c88e..2b3c9bf 100644 --- a/packages/native/lib/api.js +++ b/packages/native/lib/api.js @@ -1,3 +1,3 @@ -var native=(()=>{var nt=Object.defineProperty,ct=r=>nt(r,"__esModule",{value:!0}),ut=(r,t)=>{ct(r);for(var e in t)nt(r,e,{get:t[e],enumerable:!0})},ht={};ut(ht,{AdvancedManager:()=>A,Animate:()=>z,App:()=>Y,CONFIG:()=>L,CONFIG_DEFAULTS:()=>G,DefaultAnimationOptions:()=>et,Event:()=>w,EventEmitter:()=>x,HistoryManager:()=>C,Manager:()=>u,ManagerItem:()=>y,PARSER:()=>B,PJAX:()=>W,Page:()=>g,PageManager:()=>k,Router:()=>J,Service:()=>T,ServiceManager:()=>O,TransitionManager:()=>N,animate:()=>st,asyncMethodCall:()=>q,changeState:()=>$,clean:()=>K,computeValue:()=>_,easings:()=>Z,equal:()=>M,getEase:()=>tt,getElements:()=>X,getHash:()=>ot,getHashedPath:()=>h,getTargets:()=>Q,hashAction:()=>H,mapObject:()=>j,methodCall:()=>d,newCoords:()=>E,newListener:()=>D,newState:()=>P,newURL:()=>p});var G={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},L=class{constructor(t){this.config=Object.assign({...G},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},d=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},q=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},y=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},A=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,ot=r=>r.hash.slice(1),K=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),M=(r,t)=>{let e=p(r),i=p(t);return K(e)===K(i)};var E=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),P=(r={url:h(p()),index:0,transition:"default",data:{scroll:E(),trigger:"HistoryManager"}})=>r,C=class{constructor(){this.pointer=-1;this.states=[];let t=P();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=P(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return $(e,i,o),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}},$=(r,t,e)=>{let i=h(p(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 B=new DOMParser,g=class extends y{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=B.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=this.config.getConfig("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}},k=class extends A{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new g),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new g(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=M(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var D=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),w=class extends u{constructor(t="event"){super();this.name=t}},x=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof w?e:(this.set(t,new w(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(D({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof w&&e){let o=D({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 w&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var T=class extends y{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},O=class extends A{constructor(t){super(t)}init(){return d(this,"init",this.app),this}boot(){return d(this,"boot",this.app),this}stop(){return d(this,"stop",this.app),this}};var W=class extends T{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),R=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),v=m&&R,U=h(p())===h(p(i));return!(o||n||s||a||l||c||v||U)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(M(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,R=m-c;e=this.getDirection(R);let v=this.HistoryManager.get(this.HistoryManager.pointer);a=v.transition,n=v.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=E();let l=P({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=H()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},H=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return E(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return E(0,0)},N=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof g)||!(e.newPage instanceof g))throw`[Page] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=H()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var Y=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof L?t:new L(t),this.emitter=new x,this.history=new C,this.pages=new k(this),this.transitions=new N(this),this.services=new O(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 J=class extends T{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 X=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],Q=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?X(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],_=(r,t)=>typeof r=="function"?r(...t):r,j=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?Z[r]:r,et={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},z=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new x;let{options:e,...i}=t;this.options=Object.assign({},et,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:R,onfinish:v,target:U,keyframes:at,autoplay:lt,...pt}=this.options;this.mainElement=document.createElement("span"),this.targets=Q(U),this.properties=pt;let F;for(let f=0,S=this.targets.length;f0||(F=j(F,[f,S,I]));let it=b.delay+b.duration*b.iterations+b.endDelay;this.duration{v(I,f,S)},this.animations.set(I,rt)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),lt?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},st=(r={})=>new z(r);return ht;})(); +var native=(()=>{var nt=Object.defineProperty,ct=r=>nt(r,"__esModule",{value:!0}),ut=(r,t)=>{ct(r);for(var e in t)nt(r,e,{get:t[e],enumerable:!0})},ht={};ut(ht,{AdvancedManager:()=>A,Animate:()=>z,App:()=>Y,CONFIG:()=>L,CONFIG_DEFAULTS:()=>G,DefaultAnimationOptions:()=>et,Event:()=>w,EventEmitter:()=>x,HistoryManager:()=>C,Manager:()=>u,ManagerItem:()=>y,PARSER:()=>B,PJAX:()=>W,Page:()=>g,PageManager:()=>k,Router:()=>J,Service:()=>v,ServiceManager:()=>O,TransitionManager:()=>N,animate:()=>st,asyncMethodCall:()=>q,changeState:()=>$,clean:()=>K,computeValue:()=>_,easings:()=>Z,equal:()=>M,getEase:()=>tt,getElements:()=>X,getHash:()=>ot,getHashedPath:()=>h,getTargets:()=>Q,hashAction:()=>H,mapObject:()=>j,methodCall:()=>d,newCoords:()=>E,newListener:()=>D,newState:()=>P,newURL:()=>p});var G={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},L=class{constructor(t){this.config=Object.assign({...G},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},d=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},q=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},y=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},A=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,ot=r=>r.hash.slice(1),K=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),M=(r,t)=>{let e=p(r),i=p(t);return K(e)===K(i)};var E=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),P=(r={url:h(p()),index:0,transition:"default",data:{scroll:E(),trigger:"HistoryManager"}})=>r,C=class{constructor(){this.pointer=-1;this.states=[];let t=P();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=P(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return $(e,i,o),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}},$=(r,t,e)=>{let i=h(p(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 B=new DOMParser,g=class extends y{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=B.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=this.config.getConfig("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}},k=class extends A{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new g),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new g(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=M(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var D=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),w=class extends u{constructor(t="event"){super();this.name=t}},x=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof w?e:(this.set(t,new w(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(D({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof w&&e){let o=D({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 w&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var v=class extends y{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},O=class extends A{constructor(t){super(t)}init(){return d(this,"init",this.app),this}boot(){return d(this,"boot",this.app),this}stop(){return d(this,"stop",this.app),this}};var W=class extends v{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),R=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),T=m&&R,U=h(p())===h(p(i));return!(o||n||s||a||l||c||T||U)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(M(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,R=m-c;e=this.getDirection(R);let T=this.HistoryManager.get(this.HistoryManager.pointer);a=T.transition,n=T.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=E();let l=P({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=H()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},H=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return E(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return E(0,0)},N=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof g)||!(e.newPage instanceof g))throw`[Page] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=H()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(async a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var Y=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof L?t:new L(t),this.emitter=new x,this.history=new C,this.pages=new k(this),this.transitions=new N(this),this.services=new O(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 J=class extends v{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 X=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],Q=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?X(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],_=(r,t)=>typeof r=="function"?r(...t):r,j=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?Z[r]:r,et={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},z=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new x;let{options:e,...i}=t;this.options=Object.assign({},et,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:R,onfinish:T,target:U,keyframes:at,autoplay:lt,...pt}=this.options;this.mainElement=document.createElement("span"),this.targets=Q(U),this.properties=pt;let F;for(let f=0,S=this.targets.length;f0||(F=j(F,[f,S,I]));let it=b.delay+b.duration*b.iterations+b.endDelay;this.duration{T(I,f,S)},this.animations.set(I,rt)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),lt?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},st=(r={})=>new z(r);return ht;})(); //# sourceMappingURL=api.js.map diff --git a/packages/native/lib/api.js.map b/packages/native/lib/api.js.map index 097f349..716a9c4 100644 --- a/packages/native/lib/api.js.map +++ b/packages/native/lib/api.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/api.ts", "../src/config.ts", "../../manager/src/api.ts", "../src/manager.ts", "../src/url.ts", "../src/history.ts", "../src/page.ts", "../../emitter/src/api.ts", "../src/service.ts", "../src/pjax.ts", "../src/transition.ts", "../src/app.ts", "../src/route.ts", "../../animate/src/api.ts"], - "sourcesContent": ["export * from \"./config\";\r\nexport * from \"./manager\";\r\nexport * from \"./url\";\r\n\r\nexport * from \"./history\";\r\nexport * from \"./page\";\r\n\r\nexport * from \"./emitter\";\r\nexport * from \"./service\";\r\n\r\nexport * from \"./transition\";\r\n\r\nexport * from \"./app\";\r\nexport * from \"./pjax\";\r\nexport * from \"./route\";\r\n\r\nexport * from \"@okikio/animate\";\r\n", "// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise((done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], - "mappings": "oJAAA,qoBCcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QACX,QAAS,OAzBb,MAoDI,eACI,KAAK,OAAS,OAAO,OAAO,IAAK,GAAmB,GAWjD,WAA0C,IAC7C,IAAM,UAAW,KAAK,SACX,OAAO,EAAS,IAAM,EAAS,MAAM,IAChD,MAAO,GAAW,IAAI,KAAU,EAW7B,cAAkD,IACrD,GAAI,MAAO,IAAU,SACjB,MAAO,MAAK,OAEhB,MAAa,KAAK,OAAO,GACzB,MAAI,OAAO,IAAW,SACX,KAAK,OAAO,EAA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,EAAU,KAAK,SAChD,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,EAAU,KAAK,WAEpC,KASJ,WACH,MAAO,MAAK,cAAc,aAUvB,WAAyB,GAC5B,YAAK,cAAc,aAAe,EAClC,KAAK,WAAW,QAAQ,IACpB,EAAU,aAAe,IAEtB,KAQJ,QACH,KAAK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", + "sourcesContent": ["export * from \"./config\";\r\nexport * from \"./manager\";\r\nexport * from \"./url\";\r\n\r\nexport * from \"./history\";\r\nexport * from \"./page\";\r\n\r\nexport * from \"./emitter\";\r\nexport * from \"./service\";\r\n\r\nexport * from \"./transition\";\r\n\r\nexport * from \"./app\";\r\nexport * from \"./pjax\";\r\nexport * from \"./route\";\r\n\r\nexport * from \"@okikio/animate\";\r\n", "// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise(async (done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], + "mappings": "oJAAA,qoBCcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QACX,QAAS,OAzBb,MAoDI,eACI,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,QAAQ,IACpB,AAAI,EAAU,YAAc,YAAY,EAAU,UAEtD,KAAK,KAAK,UAEP,KASJ,cACH,MAAO,MAAK,SAST,iBACH,MAAO,MAAK,cAAc,YAUvB,kBACH,YAAK,cAAc,YAAc,EACjC,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,IAErB,KASJ,cACH,MAAO,MAAK,iBAAmB,KAAK,SAUjC,eACH,YAAK,cAAc,YAAc,EAAU,KAAK,SAChD,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,EAAU,KAAK,WAEpC,KASJ,WACH,MAAO,MAAK,cAAc,aAUvB,WAAyB,GAC5B,YAAK,cAAc,aAAe,EAClC,KAAK,WAAW,QAAQ,IACpB,EAAU,aAAe,IAEtB,KAQJ,QACH,KAAK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", "names": [] } diff --git a/packages/native/lib/api.modern.js b/packages/native/lib/api.modern.js index 53bf66f..cfdbbe4 100644 --- a/packages/native/lib/api.modern.js +++ b/packages/native/lib/api.modern.js @@ -1,3 +1,3 @@ -var $={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},P=class{constructor(t){this.config=Object.assign({...$},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},A=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},B=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},E=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},w=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,at=r=>r.hash.slice(1),_=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),R=(r,t)=>{let e=p(r),i=p(t);return _(e)===_(i)};var x=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),S=(r={url:h(p()),index:0,transition:"default",data:{scroll:x(),trigger:"HistoryManager"}})=>r,k=class{constructor(){this.pointer=-1;this.states=[];let t=S();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=S(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return W(e,i,o),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}},W=(r,t,e)=>{let i=h(p(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 Y=new DOMParser,b=class extends E{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=Y.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=this.config.getConfig("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}},O=class extends w{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new b),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new b(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=R(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var j=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),T=class extends u{constructor(t="event"){super();this.name=t}},v=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof T?e:(this.set(t,new T(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(j({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof T&&e){let o=j({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 T&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var I=class extends E{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},H=class extends w{constructor(t){super(t)}init(){return A(this,"init",this.app),this}boot(){return A(this,"boot",this.app),this}stop(){return A(this,"stop",this.app),this}};var J=class extends I{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),L=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),d=m&&L,K=h(p())===h(p(i));return!(o||n||s||a||l||c||d||K)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(R(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,L=m-c;e=this.getDirection(L);let d=this.HistoryManager.get(this.HistoryManager.pointer);a=d.transition,n=d.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=x();let l=S({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=N()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},N=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return x(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return x(0,0)},F=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof b)||!(e.newPage instanceof b))throw`[Page] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=N()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var X=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof P?t:new P(t),this.emitter=new v,this.history=new k,this.pages=new O(this),this.transitions=new F(this),this.services=new H(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 Q=class extends I{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 Z=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],tt=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?Z(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],z=(r,t)=>typeof r=="function"?r(...t):r,U=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?et[r]:r,rt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},V=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new v;let{options:e,...i}=t;this.options=Object.assign({},rt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:L,onfinish:d,target:K,keyframes:nt,autoplay:ot,...st}=this.options;this.mainElement=document.createElement("span"),this.targets=tt(K),this.properties=st;let C;for(let g=0,M=this.targets.length;g0||(C=U(C,[g,M,y]));let G=f.delay+f.duration*f.iterations+f.endDelay;this.duration{d(y,g,M)},this.animations.set(y,q)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),ot?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},lt=(r={})=>new V(r);export{w as AdvancedManager,V as Animate,X as App,P as CONFIG,$ as CONFIG_DEFAULTS,rt as DefaultAnimationOptions,T as Event,v as EventEmitter,k as HistoryManager,u as Manager,E as ManagerItem,Y as PARSER,J as PJAX,b as Page,O as PageManager,Q as Router,I as Service,H as ServiceManager,F as TransitionManager,lt as animate,B as asyncMethodCall,W as changeState,_ as clean,z as computeValue,et as easings,R as equal,it as getEase,Z as getElements,at as getHash,h as getHashedPath,tt as getTargets,N as hashAction,U as mapObject,A as methodCall,x as newCoords,j as newListener,S as newState,p as newURL}; +var $={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},P=class{constructor(t){this.config=Object.assign({...$},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},A=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},B=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},E=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},w=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,at=r=>r.hash.slice(1),_=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),R=(r,t)=>{let e=p(r),i=p(t);return _(e)===_(i)};var x=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),S=(r={url:h(p()),index:0,transition:"default",data:{scroll:x(),trigger:"HistoryManager"}})=>r,k=class{constructor(){this.pointer=-1;this.states=[];let t=S();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=S(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return W(e,i,o),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}},W=(r,t,e)=>{let i=h(p(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 Y=new DOMParser,b=class extends E{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=Y.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=this.config.getConfig("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}},O=class extends w{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new b),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new b(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=R(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var j=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),v=class extends u{constructor(t="event"){super();this.name=t}},T=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof v?e:(this.set(t,new v(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(j({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof v&&e){let o=j({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 v&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var I=class extends E{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},H=class extends w{constructor(t){super(t)}init(){return A(this,"init",this.app),this}boot(){return A(this,"boot",this.app),this}stop(){return A(this,"stop",this.app),this}};var J=class extends I{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),L=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),d=m&&L,K=h(p())===h(p(i));return!(o||n||s||a||l||c||d||K)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(R(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,L=m-c;e=this.getDirection(L);let d=this.HistoryManager.get(this.HistoryManager.pointer);a=d.transition,n=d.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=x();let l=S({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=N()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},N=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return x(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return x(0,0)},F=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof b)||!(e.newPage instanceof b))throw`[Page] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=N()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(async a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var X=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof P?t:new P(t),this.emitter=new T,this.history=new k,this.pages=new O(this),this.transitions=new F(this),this.services=new H(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 Q=class extends I{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 Z=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],tt=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?Z(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],z=(r,t)=>typeof r=="function"?r(...t):r,U=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?et[r]:r,rt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},V=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new T;let{options:e,...i}=t;this.options=Object.assign({},rt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:L,onfinish:d,target:K,keyframes:nt,autoplay:ot,...st}=this.options;this.mainElement=document.createElement("span"),this.targets=tt(K),this.properties=st;let C;for(let g=0,M=this.targets.length;g0||(C=U(C,[g,M,y]));let G=f.delay+f.duration*f.iterations+f.endDelay;this.duration{d(y,g,M)},this.animations.set(y,q)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),ot?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},lt=(r={})=>new V(r);export{w as AdvancedManager,V as Animate,X as App,P as CONFIG,$ as CONFIG_DEFAULTS,rt as DefaultAnimationOptions,v as Event,T as EventEmitter,k as HistoryManager,u as Manager,E as ManagerItem,Y as PARSER,J as PJAX,b as Page,O as PageManager,Q as Router,I as Service,H as ServiceManager,F as TransitionManager,lt as animate,B as asyncMethodCall,W as changeState,_ as clean,z as computeValue,et as easings,R as equal,it as getEase,Z as getElements,at as getHash,h as getHashedPath,tt as getTargets,N as hashAction,U as mapObject,A as methodCall,x as newCoords,j as newListener,S as newState,p as newURL}; //# sourceMappingURL=api.modern.js.map diff --git a/packages/native/lib/api.modern.js.map b/packages/native/lib/api.modern.js.map index ad2dd84..59d18bb 100644 --- a/packages/native/lib/api.modern.js.map +++ b/packages/native/lib/api.modern.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/config.ts", "../../manager/src/api.ts", "../src/manager.ts", "../src/url.ts", "../src/history.ts", "../src/page.ts", "../../emitter/src/api.ts", "../src/service.ts", "../src/pjax.ts", "../src/transition.ts", "../src/app.ts", "../src/route.ts", "../../animate/src/api.ts"], - "sourcesContent": ["// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise((done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], - "mappings": "AAcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QACX,QAAS,OAzBb,MA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AAK,WAAW,QAAQ,IACpB,AAAI,EAAU,YAAc,YAAY,EAAU,UAEtD,KAAK,KAAK,UAEP,KASJ,cACH,MAAO,MAAK,SAST,iBACH,MAAO,MAAK,cAAc,YAUvB,kBACH,YAAK,cAAc,YAAc,EACjC,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,IAErB,KASJ,cACH,MAAO,MAAK,iBAAmB,KAAK,SAUjC,eACH,YAAK,cAAc,YAAc,EAAU,KAAK,SAChD,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,EAAU,KAAK,WAEpC,KASJ,WACH,MAAO,MAAK,cAAc,aAUvB,WAAyB,GAC5B,YAAK,cAAc,aAAe,EAClC,KAAK,WAAW,QAAQ,IACpB,EAAU,aAAe,IAEtB,KAQJ,QACH,KAAK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", + "sourcesContent": ["// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise(async (done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], + "mappings": "AAcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QAC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qB,KAAK,gBACjC,KAAK,WAAW,QAAQ,IACpB,AAAI,EAAU,YAAc,YAAY,EAAU,UAEtD,KAAK,KAAK,UAEP,KASJ,cACH,MAAO,MAAK,SAST,iBACH,MAAO,MAAK,cAAc,YAUvB,kBACH,YAAK,cAAc,YAAc,EACjC,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,IAErB,KASJ,cACH,MAAO,MAAK,iBAAmB,KAAK,SAUjC,eACH,YAAK,cAAc,YAAc,EAAU,KAAK,SAChD,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,EAAU,KAAK,WAEpC,KASJ,WACH,MAAO,MAAK,cAAc,aAUvB,WAAyB,GAC5B,YAAK,cAAc,aAAe,EAClC,KAAK,WAAW,QAAQ,IACpB,EAAU,aAAe,IAEtB,KAQJ,QACH,KAAK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", "names": [] } diff --git a/packages/native/lib/api.node.js b/packages/native/lib/api.node.js index bc358e0..1c61cd8 100644 --- a/packages/native/lib/api.node.js +++ b/packages/native/lib/api.node.js @@ -1,3 +1,3 @@ -var $=Object.defineProperty,lt=r=>$(r,"__esModule",{value:!0}),pt=(r,t)=>{lt(r);for(var e in t)$(r,e,{get:t[e],enumerable:!0})};pt(exports,{AdvancedManager:()=>w,Animate:()=>V,App:()=>Q,CONFIG:()=>P,CONFIG_DEFAULTS:()=>B,DefaultAnimationOptions:()=>nt,Event:()=>T,EventEmitter:()=>v,HistoryManager:()=>k,Manager:()=>u,ManagerItem:()=>E,PARSER:()=>J,PJAX:()=>X,Page:()=>b,PageManager:()=>O,Router:()=>Z,Service:()=>I,ServiceManager:()=>H,TransitionManager:()=>F,animate:()=>ut,asyncMethodCall:()=>W,changeState:()=>Y,clean:()=>_,computeValue:()=>z,easings:()=>it,equal:()=>R,getEase:()=>rt,getElements:()=>tt,getHash:()=>ct,getHashedPath:()=>h,getTargets:()=>et,hashAction:()=>N,mapObject:()=>U,methodCall:()=>A,newCoords:()=>x,newListener:()=>j,newState:()=>S,newURL:()=>p});var B={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},P=class{constructor(t){this.config=Object.assign({...B},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},A=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},W=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},E=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},w=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,ct=r=>r.hash.slice(1),_=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),R=(r,t)=>{let e=p(r),i=p(t);return _(e)===_(i)};var x=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),S=(r={url:h(p()),index:0,transition:"default",data:{scroll:x(),trigger:"HistoryManager"}})=>r,k=class{constructor(){this.pointer=-1;this.states=[];let t=S();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=S(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return Y(e,i,o),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}},Y=(r,t,e)=>{let i=h(p(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 J=new DOMParser,b=class extends E{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=J.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=this.config.getConfig("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}},O=class extends w{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new b),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new b(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=R(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var j=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),T=class extends u{constructor(t="event"){super();this.name=t}},v=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof T?e:(this.set(t,new T(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(j({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof T&&e){let o=j({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 T&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var I=class extends E{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},H=class extends w{constructor(t){super(t)}init(){return A(this,"init",this.app),this}boot(){return A(this,"boot",this.app),this}stop(){return A(this,"stop",this.app),this}};var X=class extends I{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),L=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),d=m&&L,K=h(p())===h(p(i));return!(o||n||s||a||l||c||d||K)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(R(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,L=m-c;e=this.getDirection(L);let d=this.HistoryManager.get(this.HistoryManager.pointer);a=d.transition,n=d.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=x();let l=S({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=N()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},N=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return x(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return x(0,0)},F=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof b)||!(e.newPage instanceof b))throw`[Page] either oldPage or newPage aren't instances of the Page Class. - ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=N()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var Q=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof P?t:new P(t),this.emitter=new v,this.history=new k,this.pages=new O(this),this.transitions=new F(this),this.services=new H(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 Z=class extends I{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 tt=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],et=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?tt(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],z=(r,t)=>typeof r=="function"?r(...t):r,U=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?it[r]:r,nt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},V=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new v;let{options:e,...i}=t;this.options=Object.assign({},nt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:L,onfinish:d,target:K,keyframes:ot,autoplay:st,...at}=this.options;this.mainElement=document.createElement("span"),this.targets=et(K),this.properties=at;let C;for(let g=0,M=this.targets.length;g0||(C=U(C,[g,M,y]));let G=f.delay+f.duration*f.iterations+f.endDelay;this.duration{d(y,g,M)},this.animations.set(y,q)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),st?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},ut=(r={})=>new V(r); +var $=Object.defineProperty,lt=r=>$(r,"__esModule",{value:!0}),pt=(r,t)=>{lt(r);for(var e in t)$(r,e,{get:t[e],enumerable:!0})};pt(exports,{AdvancedManager:()=>w,Animate:()=>V,App:()=>Q,CONFIG:()=>P,CONFIG_DEFAULTS:()=>B,DefaultAnimationOptions:()=>nt,Event:()=>v,EventEmitter:()=>T,HistoryManager:()=>k,Manager:()=>u,ManagerItem:()=>E,PARSER:()=>J,PJAX:()=>X,Page:()=>b,PageManager:()=>O,Router:()=>Z,Service:()=>I,ServiceManager:()=>H,TransitionManager:()=>F,animate:()=>ut,asyncMethodCall:()=>W,changeState:()=>Y,clean:()=>_,computeValue:()=>z,easings:()=>it,equal:()=>R,getEase:()=>rt,getElements:()=>tt,getHash:()=>ct,getHashedPath:()=>h,getTargets:()=>et,hashAction:()=>N,mapObject:()=>U,methodCall:()=>A,newCoords:()=>x,newListener:()=>j,newState:()=>S,newURL:()=>p});var B={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},P=class{constructor(t){this.config=Object.assign({...B},t)}toAttr(t,e=!0){let{prefix:i}=this.config,n=`data${i?"-"+i:""}-${t}`;return e?`[${n}]`:n}getConfig(t,e=!0){if(typeof t!="string")return this.config;let i=this.config[t];return typeof i=="string"?this.toAttr(i,e):i}};var u=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 e=this.size,i=e;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=(...i)=>{},e){return this.map.forEach(t,e),this}[Symbol.iterator](){return this.entries()}},A=(r,t,...e)=>{r.forEach(i=>{i[t](...e)})},W=async(r,t,...e)=>{for(let[,i]of r)await i[t](...e)},E=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.delete(this.key),this.key=void 0,this.manager=void 0,this.app=void 0,this.config=void 0,this.emitter=void 0}},w=class extends u{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 p=(r=window.location.href)=>r instanceof URL?r:new URL(r,window.location.origin),h=r=>`${r.pathname}${r.hash}`,ct=r=>r.hash.slice(1),_=r=>r.toString().replace(/(\/#.*|\/|#.*)$/,""),R=(r,t)=>{let e=p(r),i=p(t);return _(e)===_(i)};var x=(r=window.scrollX,t=window.scrollY)=>({x:r,y:t}),S=(r={url:h(p()),index:0,transition:"default",data:{scroll:x(),trigger:"HistoryManager"}})=>r,k=class{constructor(){this.pointer=-1;this.states=[];let t=S();this.add(t,"replace")}get(t){return this.states[t]}add(t,e="push"){let i=S(t),n=this.length;this.states.push({...i}),this.pointer=n;let o={index:this.pointer,states:[...this.states]};return Y(e,i,o),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}},Y=(r,t,e)=>{let i=h(p(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 J=new DOMParser,b=class extends E{constructor(t=p(),e=document){super();this.url=t,typeof e=="string"?this.data=e:this.dom=e||document}async build(){if(this.dom instanceof Node||(this.dom=J.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=this.config.getConfig("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}},O=class extends w{constructor(t){super(t);this.loading=new u;this.maxPages=5;let e=p().pathname;this.set(e,new b),e=void 0}async load(t=p()){let e=p(t),i=e.pathname,n,o;if(this.has(i))return n=this.get(i),Promise.resolve(n);this.loading.has(i)?o=this.loading.get(i):(o=this.request(i),this.loading.set(i,o));let s=await o;if(this.loading.delete(i),n=new b(e,s),this.set(i,n),this.size>this.maxPages){let a=p(),l=this.keys(),c=R(a,l[0])?l[1]:l[0],m=this.get(c);m.unregister(),m=void 0,l=void 0,a=void 0,c=void 0}return n}async request(t){let e=new Headers(this.config.getConfig("headers")),i=window.setTimeout(()=>{throw window.clearTimeout(i),"Request Timed Out!"},this.config.getConfig("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();let o=new Error(n.statusText||""+n.status);throw o}catch(n){throw window.clearTimeout(i),n}}};var j=({callback:r=()=>{},scope:t=null,name:e="event"})=>({callback:r,scope:t,name:e}),v=class extends u{constructor(t="event"){super();this.name=t}},T=class extends u{constructor(){super()}getEvent(t){let e=this.get(t);return e instanceof v?e:(this.set(t,new v(t)),this.get(t))}newListener(t,e,i){let n=this.getEvent(t);return n.add(j({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,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],this.newListener(n,o,a)},this),this}removeListener(t,e,i){let n=this.get(t);if(n instanceof v&&e){let o=j({name:t,callback:e,scope:i});n.forEach((s,a)=>{if(s.callback===o.callback&&s.scope===o.scope)return n.delete(a)})}return n}off(t,e,i){if(typeof t=="undefined")return this;typeof t=="string"&&(t=t.trim().split(/\s/g));let n,o,s=typeof t=="object"&&!Array.isArray(t),a=s?e:i;return s||(o=e),Object.keys(t).forEach(l=>{s?(n=l,o=t[l]):n=t[l],typeof o=="function"?this.removeListener(n,o,a):this.delete(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 v&&n.forEach(o=>{let{callback:s,scope:a}=o;s.apply(a,e)})},this),this)}};var I=class extends E{install(){let{app:t}=this.manager;this.PageManager=t.pages,this.HistoryManager=t.history,this.ServiceManager=t.services,this.TransitionManager=t.transitions}init(...t){}boot(){this.initEvents()}initEvents(){}stopEvents(){}uninstall(){this.PageManager=void 0,this.HistoryManager=void 0,this.ServiceManager=void 0,this.TransitionManager=void 0}stop(){this.stopEvents(),this.unregister()}},H=class extends w{constructor(t){super(t)}init(){return A(this,"init",this.app),this}boot(){return A(this,"boot",this.app),this}stop(){return A(this,"stop",this.app),this}};var X=class extends I{constructor(){super(...arguments);this.ignoreURLs=[];this.prefetchIgnore=!1;this.isTransitioning=!1;this.stopOnTransitioning=!1;this.stickyScroll=!1;this.forceOnError=!1;this.autoScrollOnHash=!0;this.dontScroll=!1}transitionStart(){this.isTransitioning=!0}transitionStop(){this.isTransitioning=!1}init(){super.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(this.config.getConfig("transitionAttr",!1));return typeof e=="string"?e:null}validLink(t,e,i){let n=!window.history.pushState,o=!t||!i,s=e.metaKey||e.ctrlKey||e.shiftKey||e.altKey,a=t.hasAttribute("target")&&t.target==="_blank",l=t.protocol!==location.protocol||t.hostname!==location.hostname,c=typeof t.getAttribute("download")=="string",m=t.hasAttribute(this.config.getConfig("preventSelfAttr",!1)),L=Boolean(t.closest(this.config.getConfig("preventAllAttr"))),d=m&&L,K=h(p())===h(p(i));return!(o||n||s||a||l||c||d||K)}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);return!e||!this.validLink(e,t,i)?void 0: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.force(t);return}let n={x:0,y:0},o=this.HistoryManager.current,s=o.url;if(R(s,t))return;let a;if(i&&i.state){this.emitter.emit("POPSTATE",i);let{state:l}=i,{index:c}=l,m=o.index,L=m-c;e=this.getDirection(L);let d=this.HistoryManager.get(this.HistoryManager.pointer);a=d.transition,n=d.data.scroll,this.HistoryManager.replace(l.states),this.HistoryManager.pointer=c,e==="back"?this.emitter.emit("POPSTATE_BACK",i):e==="forward"&&this.emitter.emit("POPSTATE_FORWARD",i)}else{a=this.getTransitionName(e)||"default",n=x();let l=S({url:t,transition:a,data:{scroll:n}});this.HistoryManager.add(l),this.emitter.emit("HISTORY_NEW_ITEM",i)}return i&&(i.stopPropagation(),i.preventDefault()),this.emitter.emit("GO",i),this.load({oldHref:s,href:t,trigger:e,transitionName:a,scroll:n})}async load({oldHref:t,href:e,trigger:i,transitionName:n="default",scroll:o={x:0,y:0}}){try{let s=await this.PageManager.load(t);await s.build();let a;this.emitter.emit("PAGE_LOADING",{href:e,oldPage:s,trigger:i});try{try{a=await this.PageManager.load(e),await a.build(),this.transitionStart(),this.emitter.emit("PAGE_LOAD_COMPLETE",{newPage:a,oldPage:s,trigger:i})}catch(l){console.error(`[PJAX] page load error: ${l}`)}this.emitter.emit("NAVIGATION_START",{oldPage:s,newPage:a,trigger:i,transitionName:n});try{this.emitter.emit("TRANSITION_START",n);let l=await this.TransitionManager.boot(n,{oldPage:s,newPage:a,trigger:i,scroll:o});l.scrollable||(/back|popstate|forward/.test(i)||(o=N()),window.scroll(o.x,o.y)),this.emitter.emit("TRANSITION_END",{transition:l})}catch(l){console.error(`[PJAX] transition error: ${l}`)}this.emitter.emit("NAVIGATION_END",{oldPage:s,newPage:a,trigger:i,transitionName:n})}catch(l){throw this.transitionStop(),l}this.transitionStop()}catch(s){this.forceOnError?this.force(e):console.error(s)}}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)return;let i=p(this.getHref(e)),n=i.pathname;if(this.ignoredURL(i)||this.PageManager.has(n))return;this.emitter.emit("ANCHOR_HOVER HOVER",t);try{this.PageManager.load(i)}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)}},N=(r=window.location.hash)=>{try{let t=r[0]=="#"?r:p(r).hash;if(t.length>1){let e=document.getElementById(t.slice(1));if(e)return x(e.offsetLeft,e.offsetTop)}}catch(t){console.warn("hashAction error",t)}return x(0,0)},F=class extends u{constructor(t){super();this.app=t,this.config=t.config,this.emitter=t.emitter}async boot(t,e){let i=this.get(t),n=e.scroll;if(!(e.oldPage instanceof b)||!(e.newPage instanceof b))throw`[Page] either oldPage or newPage aren't instances of the Page Class. + ${{newPage:e.newPage,oldPage:e.oldPage}}`;let o=e.oldPage.wrapper,s=e.newPage.wrapper;if(document.title=""+e.newPage.title,!(o instanceof Node)||!(s instanceof Node))throw`[Wrapper] the wrapper from the ${s instanceof Node?"current":"next"} page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig("wrapperAttr")}.`;return i.init&&i?.init(e),this.emitter.emit("BEFORE_TRANSITION_OUT"),await new Promise(a=>{let l=i.out.call(i,{...e,from:e.oldPage,trigger:e.trigger,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_OUT"),await new Promise(a=>{o.insertAdjacentElement("beforebegin",s),this.emitter.emit("CONTENT_INSERT"),/back|popstate|forward/.test(e.trigger)||(n=N()),a()}),await new Promise(a=>{o.remove(),o=void 0,s=void 0,this.emitter.emit("CONTENT_REPLACED"),a()}),this.emitter.emit("BEFORE_TRANSITION_IN"),await new Promise(async a=>{let l=i.in.call(i,{...e,from:e.oldPage,to:e.newPage,trigger:e.trigger,scroll:n,done:a});l.then&&l.then(a)}),this.emitter.emit("AFTER_TRANSITION_IN"),i}};var Q=class{constructor(t={}){this.register(t)}register(t={}){this.config=t instanceof P?t:new P(t),this.emitter=new T,this.history=new k,this.pages=new O(this),this.transitions=new F(this),this.services=new H(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,e){switch(t.toLowerCase()){case"service":return this.services.get(e);case"transition":return this.transitions.get(e);case"state":return this.history.get(e);default:throw`Error: can't get type '${t}', it is not a recognized type. Did you spell it correctly.`}}async load(t,e){switch(t.toLowerCase()){case"page":return await this.pages.load(e);default:return Promise.resolve(this.get(t,e))}}setService(t,e){return this.services.set(t,e),this}setTransition(t,e){return this.transitions.set(t,e),this}add(t,e){switch(t.toLowerCase()){case"service":this.services.add(e);break;case"transition":this.transitions.set(e.name,e);break;case"state":this.history.add(e);break;default:throw`Error: can't add type '${t}', it is not a recognized type. Did you spell it correctly.`}return this}boot(){return this.services.init(),this.services.boot(),this}stop(){return this.services.stop(),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 Z=class extends I{constructor(t=[]){super();this.routes=new u;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:o}=i;return{from:this.parsePath(n),to:this.parsePath(o)}}route(){let t=this.HistoryManager,e=h(p((t.length>1?t.previous:t.current).url)),i=h(p());this.routes.forEach((n,o)=>{let s=o.from,a=o.to;if(typeof s=="boolean"&&typeof a=="boolean")throw`[Router] path ({ from: ${s}, to: ${a} }) 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 l=s,c=a;s instanceof RegExp&&s.test(e)&&(l=s.exec(e)),a instanceof RegExp&&a.test(i)&&(c=a.exec(i)),(Array.isArray(c)&&Array.isArray(l)||Array.isArray(c)&&typeof l=="boolean"&&l||Array.isArray(l)&&typeof c=="boolean"&&c)&&n({from:l,to:c,path:{from:e,to:i}})})}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 tt=r=>typeof r=="string"?Array.from(document.querySelectorAll(r)):[r],et=r=>Array.isArray(r)?r:typeof r=="string"||r instanceof Node?tt(r):r instanceof NodeList||r instanceof HTMLCollection?Array.from(r):[],z=(r,t)=>typeof r=="function"?r(...t):r,U=(r,t)=>{let e,i,n={},o=Object.keys(r);for(let s=0,a=o.length;s/^(ease|in|out)/.test(r)?it[r]:r,nt={keyframes:[],loop:1,delay:0,speed:1,endDelay:0,easing:"ease",autoplay:!0,duration:1e3,onfinish(){},fillMode:"auto",direction:"normal"},V=class{constructor(t={}){this.options={};this.targets=[];this.properties={};this.animations=new Map;this.duration=0;this.emitter=new T;let{options:e,...i}=t;this.options=Object.assign({},nt,e,i),this.loop=this.loop.bind(this);let{loop:n,delay:o,speed:s,easing:a,endDelay:l,duration:c,direction:m,fillMode:L,onfinish:d,target:K,keyframes:ot,autoplay:st,...at}=this.options;this.mainElement=document.createElement("span"),this.targets=et(K),this.properties=at;let C;for(let g=0,M=this.targets.length;g0||(C=U(C,[g,M,y]));let G=f.delay+f.duration*f.iterations+f.endDelay;this.duration{d(y,g,M)},this.animations.set(y,q)}this.mainAnimation=this.mainElement.animate([{opacity:"0"},{opacity:"1"}],{duration:this.duration,easing:"linear"}),this.setSpeed(s),st?this.play():this.pause(),this.promise=this.newPromise(),this.mainAnimation.onfinish=()=>{this.finish(this.options),window.cancelAnimationFrame(this.animationFrame)}}getTargets(){return this.targets}newPromise(){return new Promise((t,e)=>{try{this.finish=i=>(this.emit("finish",i),t(i))}catch(i){e(i)}})}then(t,e){return this.promise.then(t,e)}catch(t){return this.promise.catch(t)}finally(t){return this.promise.finally(t)}loop(){this.animationFrame=window.requestAnimationFrame(this.loop),this.emit("tick change",this.getCurrentTime())}on(t,e,i){return this.emitter.on(t,e,i),this}off(t,e,i){return this.emitter.off(t,e,i),this}emit(t,...e){return this.emitter.emit(t,...e),this}getAnimation(t){return this.animations.get(t)}play(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.play(),this.animationFrame=requestAnimationFrame(this.loop),this.animations.forEach(t=>{t.playState!=="finished"&&t.play()}),this.emit("play")),this}pause(){return this.mainAnimation.playState!=="finished"&&(this.mainAnimation.pause(),window.cancelAnimationFrame(this.animationFrame),this.animations.forEach(t=>{t.playState!=="finished"&&t.pause()}),this.emit("pause")),this}getDuration(){return this.duration}getCurrentTime(){return this.mainAnimation.currentTime}setCurrentTime(t){return this.mainAnimation.currentTime=t,this.animations.forEach(e=>{e.currentTime=t}),this}getProgress(){return this.getCurrentTime()/this.duration}setProgress(t){return this.mainAnimation.currentTime=t*this.duration,this.animations.forEach(e=>{e.currentTime=t*this.duration}),this}getSpeed(){return this.mainAnimation.playbackRate}setSpeed(t=1){return this.mainAnimation.playbackRate=t,this.animations.forEach(e=>{e.playbackRate=t}),this}reset(){this.setCurrentTime(0),this.promise=this.newPromise(),this.options.autoplay?this.play():this.pause()}getPlayState(){return this.mainAnimation.playState}getOptions(){return this.options}toJSON(){return this.getOptions()}},ut=(r={})=>new V(r); //# sourceMappingURL=api.node.js.map diff --git a/packages/native/lib/api.node.js.map b/packages/native/lib/api.node.js.map index a00268d..d01eae1 100644 --- a/packages/native/lib/api.node.js.map +++ b/packages/native/lib/api.node.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../src/api.ts", "../src/config.ts", "../../manager/src/api.ts", "../src/manager.ts", "../src/url.ts", "../src/history.ts", "../src/page.ts", "../../emitter/src/api.ts", "../src/service.ts", "../src/pjax.ts", "../src/transition.ts", "../src/app.ts", "../src/route.ts", "../../animate/src/api.ts"], - "sourcesContent": ["export * from \"./config\";\r\nexport * from \"./manager\";\r\nexport * from \"./url\";\r\n\r\nexport * from \"./history\";\r\nexport * from \"./page\";\r\n\r\nexport * from \"./emitter\";\r\nexport * from \"./service\";\r\n\r\nexport * from \"./transition\";\r\n\r\nexport * from \"./app\";\r\nexport * from \"./pjax\";\r\nexport * from \"./route\";\r\n\r\nexport * from \"@okikio/animate\";\r\n", "// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise((done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], - "mappings": "gIAAA,uoBCcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QACX,QAAS,OAzBb,MAoDI,eACI,KAAK,OAAS,OAAO,OAAO,IAAK,GAAmB,GAWjD,WAA0C,IAC7C,IAAM,UAAW,KAAK,SACX,OAAO,EAAS,IAAM,EAAS,MAAM,IAChD,MAAO,GAAW,IAAI,KAAU,EAW7B,cAAkD,IACrD,GAAI,MAAO,IAAU,SACjB,MAAO,MAAK,OAEhB,MAAa,KAAK,OAAO,GACzB,MAAI,OAAO,IAAW,SACX,KAAK,OAAO,EAAQ,GACxB,ICrFf,IAAA,QAwBC,eACC,KAAK,IAAM,GAAI,KAAI,GASb,SACN,MAAO,MAAK,IAUN,OACN,MAAO,MAAK,IAAI,IAAI,GASd,OACN,MAAO,OAAM,KAAK,KAAK,IAAI,QASrB,SACN,MAAO,OAAM,KAAK,KAAK,IAAI,UAWrB,SACN,Y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AK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", + "sourcesContent": ["export * from \"./config\";\r\nexport * from \"./manager\";\r\nexport * from \"./url\";\r\n\r\nexport * from \"./history\";\r\nexport * from \"./page\";\r\n\r\nexport * from \"./emitter\";\r\nexport * from \"./service\";\r\n\r\nexport * from \"./transition\";\r\n\r\nexport * from \"./app\";\r\nexport * from \"./pjax\";\r\nexport * from \"./route\";\r\n\r\nexport * from \"@okikio/animate\";\r\n", "// The config variables\r\nexport interface ICONFIG {\r\n prefix?: string;\r\n wrapperAttr?: string;\r\n noAjaxLinkAttr?: string;\r\n noPrefetchAttr?: \"no-prefetch\";\r\n headers?: string[][];\r\n preventSelfAttr?: string;\r\n preventAllAttr?: string;\r\n transitionAttr?: string;\r\n blockAttr?: string;\r\n timeout?: number\r\n}\r\n\r\nexport const CONFIG_DEFAULTS: ICONFIG = {\r\n wrapperAttr: \"wrapper\",\r\n noAjaxLinkAttr: \"no-ajax-link\",\r\n noPrefetchAttr: \"no-prefetch\",\r\n headers: [\r\n [\"x-partial\", \"true\"]\r\n ],\r\n preventSelfAttr: `prevent=\"self\"`,\r\n preventAllAttr: `prevent=\"all\"`,\r\n transitionAttr: \"transition\",\r\n blockAttr: `block`,\r\n timeout: 30000\r\n};\r\n\r\nexport type ConfigKeys = keyof ICONFIG;\r\n\r\n/**\r\n * The Config class\r\n *\r\n * @export\r\n * @class CONFIG\r\n */\r\nexport class CONFIG {\r\n /**\r\n * The current Configuration\r\n *\r\n * @public\r\n * @type ICONFIG\r\n * @memberof CONFIG\r\n */\r\n public config: ICONFIG;\r\n\r\n /**\r\n * Creates an instance of CONFIG.\r\n *\r\n * @param {ICONFIG} config\r\n * @memberof CONFIG\r\n */\r\n constructor(config: ICONFIG) {\r\n this.config = Object.assign({ ...CONFIG_DEFAULTS }, config);\r\n }\r\n\r\n /**\r\n * Converts string into data attributes\r\n *\r\n * @param {string} value\r\n * @param {boolean} brackets [brackets=true]\r\n * @returns string\r\n * @memberof CONFIG\r\n */\r\n public toAttr(value: string, brackets: boolean = true): string {\r\n let { prefix } = this.config;\r\n let attr = `data${prefix ? \"-\" + prefix : \"\"}-${value}`;\r\n return brackets ? `[${attr}]` : attr;\r\n }\r\n\r\n /**\r\n * Selects config vars, and formats them for use, or simply returns the current configurations for the framework\r\n *\r\n * @param {ConfigKeys} value\r\n * @param {boolean} [brackets=true]\r\n * @returns any\r\n * @memberof CONFIG\r\n */\r\n public getConfig(value?: ConfigKeys, brackets: boolean = true): any {\r\n if (typeof value !== \"string\")\r\n return this.config;\r\n\r\n let config = this.config[value];\r\n if (typeof config === \"string\")\r\n return this.toAttr(config, brackets);\r\n return config;\r\n }\r\n}\r\n", "/**\r\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.\r\n *\r\n * @export\r\n * @class Manager\r\n * @template K\r\n * @template V\r\n */\r\nexport class Manager {\r\n\t/**\r\n\t * The complex list of named data, to which the Manager controls\r\n\t *\r\n\t * @public\r\n\t * @type Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic map: Map;\r\n\r\n\t/**\r\n\t * Creates an instance of Manager.\r\n\t *\r\n\t * @param {Array<[K, V]>} [value]\r\n\t * @memberof Manager\r\n\t */\r\n\tconstructor(value?: Array<[K, V]>) {\r\n\t\tthis.map = new Map(value);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the Manager class's list\r\n\t *\r\n\t * @returns Map\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic getMap(): Map {\r\n\t\treturn this.map;\r\n\t}\r\n\r\n\t/**\r\n\t * Get a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key to find in the Manager's list\r\n\t * @returns V\r\n\t */\r\n\tpublic get(key: K): V {\r\n\t\treturn this.map.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the keys of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic keys(): Array {\r\n\t\treturn Array.from(this.map.keys());\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the values of all items stored in the Manager as an Array\r\n\t *\r\n\t * @returns Array\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic values(): Array {\r\n\t\treturn Array.from(this.map.values());\r\n\t}\r\n\r\n\t/**\r\n\t * Set a value stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key where the value will be stored\r\n\t * @param {V} value - The value to store\r\n\t * @returns Manager\r\n\t */\r\n\tpublic set(key: K, value: V): Manager {\r\n\t\tthis.map.set(key, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\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\r\n\t *\r\n\t * @public\r\n\t * @param {V} value\r\n\t * @returns Manager\r\n\t */\r\n\tpublic add(value: V): Manager {\r\n\t\tlet size = this.size;\r\n\t\t// @ts-ignore\r\n\t\tlet num: K = size as K;\r\n\t\tthis.set(num, value);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the total number of items stored in the Manager\r\n\t *\r\n\t * @public\r\n\t * @returns Number\r\n\t */\r\n\tpublic get size(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\tpublic get length(): number {\r\n\t\treturn this.map.size;\r\n\t}\r\n\r\n\t/**\r\n\t * Returns the last item in the Manager who's index is a certain distance from the last item in the Manager\r\n\t *\r\n\t * @param {number} [distance=1]\r\n\t * @returns V | undefined\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic last(distance: number = 1): V | undefined {\r\n\t\tlet key = this.keys()[this.size - distance];\r\n\t\treturn this.get(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns true if an element in the Map object existed and has been removed, or false if the element does not exist.\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns boolean\r\n\t */\r\n\tpublic delete(key: K): boolean {\r\n\t\treturn this.map.delete(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Removes a value stored in the Manager, via the key, returns the Manager class, allowing for chains\r\n\t *\r\n\t * @public\r\n\t * @param {K} key - The key for the key value pair to be removed\r\n\t * @returns Manager\r\n\t */\r\n\tpublic remove(key: K): Manager {\r\n\t\tthis.map.delete(key);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Clear the Manager of all its contents\r\n\t *\r\n\t * @public\r\n\t * @returns Manager\r\n\t */\r\n\tpublic clear(): Manager {\r\n\t\tthis.map.clear();\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Checks if the Manager contains a certain key\r\n\t *\r\n\t * @public\r\n\t * @param {K} key\r\n\t * @returns boolean\r\n\t */\r\n\tpublic has(key: K): boolean {\r\n\t\treturn this.map.has(key);\r\n\t}\r\n\r\n\t/**\r\n\t * Returns a new Iterator object that contains an array of [key, value] for each element in the Map object in insertion order.\r\n\t *\r\n\t * @public\r\n\t * @returns IterableIterator<[K, V]>\r\n\t */\r\n\tpublic entries(): IterableIterator<[K, V]> {\r\n\t\treturn this.map.entries();\r\n\t}\r\n\r\n\t/**\r\n\t * Iterates through the Managers contents, calling a callback function every iteration\r\n\t *\r\n\t * @param {*} [callback=(...args: any): void => { }]\r\n\t * @param {object} context\r\n\t * @returns Manager\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic forEach(\r\n\t\tcallback: any = (...args: any): void => { },\r\n\t\tcontext?: object\r\n\t): Manager {\r\n\t\tthis.map.forEach(callback, context);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Allows iteration via the for..of, learn more: [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators]\r\n\t *\r\n\t * @returns IterableIterator<[K, V]>\r\n\t * @memberof Manager\r\n\t */\r\n\tpublic [Symbol.iterator](): IterableIterator<[K, V]> {\r\n\t\treturn this.entries();\r\n\t}\r\n}\r\n\r\n/**\r\n * Calls the method of a certain name for all items that are currently installed\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const methodCall = (manager: Manager, method: string, ...args: any): void => {\r\n\tmanager.forEach((item) => {\r\n\t\t// @ts-ignore\r\n\t\titem[method](...args);\r\n\t});\r\n};\r\n\r\n/**\r\n * Asynchronously calls the method of a certain name for all items that are currently installed, similar to methodCall\r\n *\r\n * @param {Manager} manager\r\n * @param {string} method\r\n * @param {Array} [args=[]]\r\n */\r\nexport const asyncMethodCall = async (manager: Manager, method: string, ...args: any): Promise => {\r\n\tfor (let [, item] of manager) {\r\n\t\t// @ts-ignore\r\n\t\tawait item[method](...args);\r\n\t}\r\n};\r\n\r\nexport default Manager;\r\n", "import { Manager, methodCall, asyncMethodCall } from \"@okikio/manager\";\r\nimport { CONFIG } from \"./config\";\r\nimport { App } from \"./app\";\r\nimport EventEmitter from \"@okikio/emitter\";\r\n\r\nexport type IAdvancedManager = AdvancedManager;\r\n\r\n/**\r\n * The base class for all AdvancedManager and AdvancedStorage items\r\n *\r\n * @export\r\n * @class ManagerItem\r\n */\r\nexport class ManagerItem {\r\n /**\r\n * The AdvancedManager the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type IAdvancedManager\r\n * @memberof ManagerItem\r\n */\r\n public manager: IAdvancedManager;\r\n\r\n /**\r\n * The App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type App\r\n * @memberof ManagerItem\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the ManagerItem is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof ManagerItem\r\n */\r\n public config: CONFIG;\r\n public emitter: EventEmitter;\r\n public key: any;\r\n\r\n /**\r\n * Creates an instance of ManagerItem.\r\n *\r\n * @memberof ManagerItem\r\n */\r\n constructor() { }\r\n\r\n /**\r\n * Run after the Manager Item has been registered\r\n *\r\n * @returns any\r\n * @memberof ManagerItem\r\n */\r\n public install(): any { }\r\n\r\n /**\r\n * Register the current Manager Item's manager\r\n *\r\n * @param {IAdvancedManager} manager\r\n * @returns ManagerItem\r\n * @memberof ManagerItem\r\n */\r\n public register(manager: IAdvancedManager, key: any): ManagerItem {\r\n this.manager = manager;\r\n this.app = manager.app;\r\n this.config = manager.config;\r\n this.emitter = manager.emitter;\r\n this.key = key;\r\n this.install();\r\n return this;\r\n }\r\n\r\n public uninstall(): any { }\r\n\r\n public unregister() {\r\n this.uninstall();\r\n\r\n this.manager.delete(this.key);\r\n this.key = undefined;\r\n this.manager = undefined;\r\n this.app = undefined;\r\n this.config = undefined;\r\n this.emitter = undefined;\r\n }\r\n}\r\n\r\n/**\r\n * A tweak to the Manager class that makes it self aware of the App class it's instantiated in\r\n *\r\n * @export\r\n * @class AdvancedManager\r\n * @extends {Manager}\r\n * @template K\r\n * @template V\r\n */\r\nexport class AdvancedManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of AdvancedManager.\r\n *\r\n * @param {App} app - The instance of the App class, the Manager is instantiated in\r\n * @memberof AdvancedManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Set a value stored in the Manager\r\n *\r\n * @public\r\n * @param {K} key - The key where the value will be stored\r\n * @param {V} value - The value to store\r\n * @returns AdvancedManager\r\n */\r\n public set(key: K, value: V) {\r\n super.set(key, value);\r\n value.register(this, key);\r\n return this;\r\n }\r\n}\r\n\r\nexport { Manager, methodCall, asyncMethodCall };\r\n", "/**\r\n * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype.\r\n *\r\n * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class.\r\n *\r\n * @export\r\n * @class URL\r\n * @extends {URL}\r\n */\r\n// Read up on the native URL class [devdocs.io/dom/url]\r\n/**\r\n * Creates an instance of URL.\r\n *\r\n * @param {(string | URL | Location)} [url=window.location.pathname]\r\n * @return URL\r\n */\r\nexport const newURL = (url: string | URL | Location = window.location.href): URL => {\r\n return url instanceof URL ? url : new URL(url as unknown as string, window.location.origin);\r\n};\r\n\r\n/**\r\n * Returns the pathname with the hash\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHashedPath = (url: URL): string => (`${url.pathname}${url.hash}`);\r\n\r\n/**\r\n * Returns the actual hash without the hashtag\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const getHash = (url: URL): string => (url.hash.slice(1));\r\n\r\n/**\r\n * Removes the hash from the full URL for a clean URL string\r\n *\r\n * @param {URL} url\r\n * @returns string\r\n */\r\nexport const clean = (url: URL): string => (url.toString().replace(/(\\/#.*|\\/|#.*)$/, ''));\r\n\r\n/**\r\n * Compares two URLs to each other\r\n *\r\n * @param {URL} a\r\n * @param {URL} b\r\n * @returns boolean\r\n */\r\nexport const equal = (a: URL | string, b: URL | string): boolean => {\r\n let urlA = newURL(a);\r\n let urlB = newURL(b);\r\n return clean(urlA) === clean(urlB);\r\n};\r\n", "import { getHashedPath, newURL } from \"./url\";\r\n\r\nexport type Trigger = HTMLAnchorElement | \"HistoryManager\" | \"popstate\" | \"back\" | \"forward\";\r\nexport interface ICoords {\r\n\treadonly x: number;\r\n\treadonly y: number;\r\n}\r\n\r\nexport interface IStateData {\r\n\tscroll: ICoords;\r\n\t[key: string]: any;\r\n}\r\n\r\nexport interface IState {\r\n\turl: string;\r\n\tindex?: number;\r\n\ttransition: string;\r\n\tdata: IStateData;\r\n}\r\n\r\nexport interface IHistoryItem {\r\n\tindex: number;\r\n\tstates: IState[];\r\n}\r\n\r\n/**\r\n * A quick snapshot of page coordinates, e.g. scroll positions\r\n *\r\n * @export\r\n * @param {number} [x=window.scrollX]\r\n * @param {number} [y=window.scrollY]\r\n */\r\nexport const newCoords = (x: number = window.scrollX, y: number = window.scrollY): ICoords => ({ x, y });\r\n\r\n/**\r\n * Represents the current status of the page consisting of properties like: url, transition, and data\r\n *\r\n * @export\r\n * @param {IState} {\r\n * url = getHashedPath(newURL()),\r\n * index = 0,\r\n * transition = \"default\",\r\n * data = {\r\n * scroll: newCoords(),\r\n * trigger: \"HistoryManager\"\r\n * }\r\n * }\r\n * @memberof State\r\n*/\r\nexport const newState = (state: IState = {\r\n\turl: getHashedPath(newURL()),\r\n\tindex: 0,\r\n\ttransition: \"default\",\r\n\tdata: {\r\n\t\tscroll: newCoords(),\r\n\t\ttrigger: \"HistoryManager\"\r\n\t}\r\n}): IState => (state);\r\n\r\n\r\n/**\r\n * History of the site, stores only the State class\r\n *\r\n * @export\r\n * @class HistoryManager\r\n * @extends {Manager}\r\n */\r\nexport class HistoryManager {\r\n\tpublic states: IState[];\r\n\tpublic pointer = -1;\r\n\r\n\t/**\r\n\t * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class.\r\n\t *\r\n\t * @memberof HistoryManager\r\n\t * @constructor\r\n\t */\r\n\tconstructor() {\r\n\t\tthis.states = [];\r\n\r\n\t\tlet state = newState();\r\n\t\tthis.add(state, \"replace\");\r\n\t}\r\n\r\n\tpublic get(index: number) {\r\n\t\treturn this.states[index];\r\n\t}\r\n\r\n\t/**\r\n\t * Sets the index of the state before adding to HistoryManager\r\n\t *\r\n\t * @param {IState} value\r\n\t * @returns HistoryManager\r\n\t */\r\n\tpublic add(value?: IState, historyAction: \"replace\" | \"push\" = \"push\"): HistoryManager {\r\n\t\tlet state = newState(value);\r\n\t\tlet len = this.length;\r\n\t\tthis.states.push({ ...state });\r\n\t\tthis.pointer = len;\r\n\r\n\t\tlet item: IHistoryItem = {\r\n\t\t\tindex: this.pointer,\r\n\t\t\tstates: [...this.states]\r\n\t\t};\r\n\t\tchangeState(historyAction, state, item);\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic remove(index?: number) {\r\n\t\tif (index) {\r\n\t\t\tthis.states.splice(index, 1);\r\n\t\t} else {\r\n\t\t\tthis.states.pop();\r\n\t\t}\r\n\r\n\t\tthis.pointer--;\r\n\t\treturn this;\r\n\t}\r\n\r\n\tpublic replace(newStates: IState[]) {\r\n\t\tthis.states = newStates;\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Set state by index.\r\n\t */\r\n\tpublic set(i: number, state: IState) {\r\n\t\treturn (this.states[i] = state);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the current state.\r\n\t */\r\n\tget current(): IState {\r\n\t\treturn this.get(this.pointer);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the last state (top of the history stack).\r\n\t */\r\n\tget last(): IState {\r\n\t\treturn this.get(this.length - 1);\r\n\t}\r\n\r\n\t/**\r\n\t * Get the previous state.\r\n\t */\r\n\tget previous(): IState | null {\r\n\t\treturn this.pointer < 1 ? null : this.get(this.pointer - 1);\r\n\t}\r\n\r\n\tget length() {\r\n\t\treturn this.states.length;\r\n\t}\r\n\r\n}\r\n\r\n/**\r\n * Either push or replace history state\r\n *\r\n * @param {(\"push\" | \"replace\")} action\r\n * @param {IState} state\r\n * @param {_URL} url\r\n * @memberof PJAX\r\n */\r\nexport const changeState = (action: \"push\" | \"replace\", state: IState, item: object) => {\r\n\tlet href = getHashedPath(newURL(state.url));\r\n\tlet args = [item, \"\", href];\r\n\tif (window.history) {\r\n\t\tswitch (action) {\r\n\t\t\tcase \"push\":\r\n\t\t\t\twindow.history.pushState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t\tcase \"replace\":\r\n\t\t\t\twindow.history.replaceState.apply(window.history, args);\r\n\t\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n};\r\n", "import { Manager, ManagerItem, AdvancedManager } from \"./manager\";\r\nimport { equal, newURL } from \"./url\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Parses strings to DOM\r\n */\r\nexport const PARSER: DOMParser = new DOMParser();\r\n\r\n/**\r\n * A page represents the DOM elements that create each page\r\n *\r\n * @export\r\n * @class Page\r\n */\r\nexport class Page extends ManagerItem {\r\n /**\r\n * Holds the DOM of the current page\r\n *\r\n * @public\r\n * @type Document\r\n * @memberof Page\r\n */\r\n public dom: Document;\r\n\r\n /**\r\n * Holds the wrapper element to be swapped out of each Page\r\n *\r\n * @public\r\n * @type HTMLElement\r\n * @memberof Page\r\n */\r\n public wrapper: HTMLElement;\r\n\r\n /**\r\n * Holds the title of each page\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Page\r\n */\r\n public title: string;\r\n\r\n /**\r\n * Holds the head element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public head: Element;\r\n\r\n /**\r\n * Holds the body element of each page\r\n *\r\n * @public\r\n * @type Element\r\n * @memberof Page\r\n */\r\n public body: Element;\r\n\r\n /**\r\n * The URL of the current page\r\n *\r\n * @public\r\n * @type URL\r\n * @memberof Page\r\n */\r\n public url: URL;\r\n public data: string;\r\n public wrapperAttr: string;\r\n\r\n /**\r\n * Creates an instance of Page, it also creates a new page from response text, or a Document Object\r\n *\r\n * @param {URL} [url = newURL()]\r\n * @param {(string | Document)} [dom=document]\r\n * @memberof Page\r\n */\r\n constructor(url: URL = newURL(), dom: string | Document = document) {\r\n super();\r\n this.url = url;\r\n\r\n if (typeof dom === \"string\") {\r\n this.data = dom;\r\n } else this.dom = dom || document;\r\n }\r\n\r\n public async build() {\r\n if (!(this.dom instanceof Node)) {\r\n this.dom = PARSER.parseFromString(this.data, \"text/html\");\r\n }\r\n\r\n if (!(this.body instanceof Node)) {\r\n let { title, head, body } = this.dom;\r\n this.title = title;\r\n this.head = head;\r\n this.body = body;\r\n this.wrapper = this.body.querySelector(this.wrapperAttr);\r\n }\r\n }\r\n\r\n /**\r\n * Runs once the the manager and config have been registered\r\n *\r\n * @returns void\r\n * @memberof Page\r\n */\r\n public install(): void {\r\n this.wrapperAttr = this.config.getConfig(\"wrapperAttr\");\r\n }\r\n\r\n public uninstall() {\r\n this.url = undefined;\r\n this.title = undefined;\r\n this.head = undefined;\r\n this.body = undefined;\r\n this.dom = undefined;\r\n this.wrapper = undefined;\r\n this.data = undefined;\r\n this.wrapperAttr = undefined;\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Controls which page to be load\r\n *\r\n * @export\r\n * @class PageManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class PageManager extends AdvancedManager {\r\n /**\r\n * Stores all URLs that are currently loading\r\n *\r\n * @public\r\n * @type Manager>\r\n * @memberof PageManager\r\n */\r\n public loading: Manager> = new Manager();\r\n public maxPages = 5;\r\n\r\n /**\r\n * Creates an instance of the PageManager\r\n *\r\n * @param {App} app\r\n * @memberof PageManager\r\n */\r\n constructor(app: App) {\r\n super(app);\r\n let URLString = newURL().pathname;\r\n this.set(URLString, new Page());\r\n URLString = undefined;\r\n }\r\n\r\n /**\r\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\"\r\n *\r\n * @param {(URL | string)} [_url=newURL()]\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async load(_url: URL | string = newURL()): Promise {\r\n let url: URL = newURL(_url);\r\n let urlString: string = url.pathname;\r\n let page: Page, request: Promise;\r\n if (this.has(urlString)) {\r\n page = this.get(urlString);\r\n return Promise.resolve(page);\r\n }\r\n\r\n if (!this.loading.has(urlString)) {\r\n request = this.request(urlString);\r\n this.loading.set(urlString, request);\r\n } else request = this.loading.get(urlString);\r\n\r\n let response = await request;\r\n this.loading.delete(urlString);\r\n\r\n page = new Page(url, response);\r\n this.set(urlString, page);\r\n\r\n if (this.size > this.maxPages) {\r\n let currentUrl = newURL();\r\n let keys = this.keys();\r\n let first = equal(currentUrl, keys[0]) ? keys[1] : keys[0];\r\n let page = this.get(first);\r\n page.unregister();\r\n page = undefined;\r\n keys = undefined;\r\n currentUrl = undefined;\r\n first = undefined;\r\n }\r\n return page;\r\n }\r\n\r\n /**\r\n * Starts a fetch request\r\n *\r\n * @param {string} url\r\n * @returns Promise\r\n * @memberof PageManager\r\n */\r\n public async request(url: string): Promise {\r\n const headers = new Headers(this.config.getConfig(\"headers\"));\r\n const timeout = window.setTimeout(() => {\r\n window.clearTimeout(timeout);\r\n throw \"Request Timed Out!\";\r\n }, this.config.getConfig(\"timeout\"));\r\n\r\n try {\r\n let response = await fetch(url, {\r\n mode: 'same-origin',\r\n method: \"GET\",\r\n headers,\r\n cache: \"default\",\r\n credentials: \"same-origin\",\r\n });\r\n\r\n window.clearTimeout(timeout);\r\n if (response.status >= 200 && response.status < 300) {\r\n return await response.text();\r\n }\r\n\r\n const err = new Error(response.statusText || \"\" + response.status);\r\n throw err;\r\n } catch (err) {\r\n window.clearTimeout(timeout);\r\n throw err;\r\n }\r\n }\r\n}\r\n", "import { Manager } from \"@okikio/manager\";\r\n\r\nexport type ListenerCallback = ((...args: any) => void);\r\nexport interface IListener {\r\n readonly callback: ListenerCallback;\r\n readonly scope: object;\r\n readonly name: string;\r\n}\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n */\r\nexport const newListener = ({\r\n callback = () => { },\r\n scope = null,\r\n name = \"event\",\r\n}: IListener): IListener => ({ callback, scope, name });\r\n\r\n/**\r\n * Represents a new event listener consisting of properties like: callback, scope, name\r\n *\r\n * @export\r\n * @class Event\r\n * @extends {Manager}\r\n */\r\nexport class Event extends Manager {\r\n /**\r\n * The name of the event\r\n *\r\n * @public\r\n * @type string\r\n * @memberof Event\r\n */\r\n public name: string;\r\n\r\n /**\r\n * Creates an instance of Event.\r\n *\r\n * @param {string} [name=\"event\"]\r\n * @memberof Event\r\n */\r\n constructor(name: string = \"event\") {\r\n super();\r\n this.name = name;\r\n }\r\n}\r\n\r\nexport type EventInput = string | object | Array;\r\n\r\n/**\r\n * An event emitter\r\n *\r\n * @export\r\n * @class EventEmitter\r\n * @extends {Manager}\r\n */\r\nexport class EventEmitter extends Manager {\r\n /**\r\n * Creates an instance of EventEmitter.\r\n *\r\n * @memberof EventEmitter\r\n */\r\n constructor() {\r\n super();\r\n }\r\n\r\n /**\r\n * Gets events, if event doesn't exist create a new Event\r\n *\r\n * @param {string} name\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public getEvent(name: string): Event {\r\n let event = this.get(name);\r\n if (!(event instanceof Event)) {\r\n this.set(name, new Event(name));\r\n return this.get(name);\r\n }\r\n\r\n return event;\r\n }\r\n /**\r\n * Creates a new listener and adds it to the event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} callback\r\n * @param {object} scope\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public newListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event = this.getEvent(name);\r\n event.add(newListener({ name, callback, scope }));\r\n return event;\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} callback\r\n * @param {object} scope\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public on(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n this.newListener(_name, _callback, _scope);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {string} name\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns Event\r\n * @memberof EventEmitter\r\n */\r\n public removeListener(\r\n name: string,\r\n callback: ListenerCallback,\r\n scope: object\r\n ): Event {\r\n let event: Event = this.get(name);\r\n if (event instanceof Event && callback) {\r\n let listener = newListener({ name, callback, scope });\r\n\r\n event.forEach((value: IListener, i: number) => {\r\n if (\r\n value.callback === listener.callback &&\r\n value.scope === listener.scope\r\n ) {\r\n return event.delete(i);\r\n }\r\n });\r\n }\r\n\r\n return event;\r\n }\r\n\r\n /**\r\n * Removes a listener from a given event, or it just completely removes an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback | object} [callback]\r\n * @param {object} [scope]\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public off(\r\n events: EventInput,\r\n callback?: ListenerCallback | object,\r\n scope?: object\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n let _name: string;\r\n let _callback: ListenerCallback;\r\n let isObject = typeof events == \"object\" && !Array.isArray(events);\r\n\r\n let _scope: object = isObject ? callback : scope;\r\n if (!isObject) _callback = (callback as ListenerCallback);\r\n\r\n // Loop through the list of events\r\n Object.keys(events).forEach(key => {\r\n // Select the name of the event from the list\r\n // Remember events can be {String | Object | Array}\r\n\r\n // Check If events is an Object (JSON like Object, and not an Array)\r\n if (isObject) {\r\n _name = key;\r\n _callback = events[key];\r\n } else {\r\n _name = events[key];\r\n }\r\n\r\n if (typeof _callback === \"function\") {\r\n this.removeListener(_name, _callback, _scope);\r\n } else this.delete(_name);\r\n }, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | Array)} events\r\n * @param {...any} args\r\n * @returns EventEmitter\r\n * @memberof EventEmitter\r\n */\r\n public emit(\r\n events: string | Array,\r\n ...args: any\r\n ): EventEmitter {\r\n // If there is no event break\r\n if (typeof events == \"undefined\") return this;\r\n\r\n // Create a new event every space\r\n if (typeof events == \"string\") events = events.trim().split(/\\s/g);\r\n\r\n // Loop through the list of events\r\n events.forEach((event: string) => {\r\n let _event: Event = this.get(event);\r\n\r\n if (_event instanceof Event) {\r\n _event.forEach((listener: IListener) => {\r\n let { callback, scope } = listener;\r\n callback.apply(scope, args);\r\n });\r\n }\r\n }, this);\r\n return this;\r\n }\r\n}\r\n\r\nexport default EventEmitter;\r\n", "import { AdvancedManager, ManagerItem, methodCall } from \"./manager\";\r\nimport { TransitionManager } from \"./transition\";\r\nimport { HistoryManager } from \"./history\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { PageManager } from \"./page\";\r\nimport { App } from \"./app\";\r\n\r\n/**\r\n * Controls specific kinds of actions that require JS\r\n *\r\n * @export\r\n * @class Service\r\n */\r\nexport class Service extends ManagerItem {\r\n\t/**\r\n\t * Stores access to the App class's EventEmitter\r\n\t *\r\n\t * @public\r\n\t * @type EventEmitter\r\n\t * @memberof Service\r\n\t */\r\n\tpublic emitter: EventEmitter;\r\n\r\n\t/**\r\n\t * Stores access to the App class's PageManager\r\n\t *\r\n\t * @public\r\n\t * @type PageManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic PageManager: PageManager;\r\n\r\n\t/**\r\n\t * Stores access to the App class's HistoryManager\r\n\t *\r\n\t * @public\r\n\t * @type HistoryManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic HistoryManager: HistoryManager;\r\n\r\n\t/**\r\n\t * Stores the ServiceManager the service is install on\r\n\t *\r\n\t * @public\r\n\t * @type ServiceManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic ServiceManager: ServiceManager;\r\n\r\n\t/**\r\n\t * Stores access to the App's TransitionManager\r\n\t *\r\n\t * @public\r\n\t * @type TransitionManager\r\n\t * @memberof Service\r\n\t */\r\n\tpublic TransitionManager: TransitionManager;\r\n\r\n\t/**\r\n\t * Method is run once when Service is installed on a ServiceManager\r\n\t *\r\n\t * @memberof Service\r\n\t */\r\n\tpublic install(): void {\r\n\t\tlet { app } = this.manager;\r\n\t\tthis.PageManager = app.pages;\r\n\t\tthis.HistoryManager = app.history;\r\n\t\tthis.ServiceManager = app.services;\r\n\t\tthis.TransitionManager = app.transitions;\r\n\t}\r\n\r\n\t// Called before the start of a Service, represents a constructor of sorts\r\n\tpublic init(...args: any): void { }\r\n\r\n\t// Called on start of Service\r\n\tpublic boot(): void {\r\n\t\tthis.initEvents();\r\n\t}\r\n\r\n\t// Initialize events\r\n\tpublic initEvents(): void { }\r\n\r\n\t// Stop events\r\n\tpublic stopEvents(): void { }\r\n\r\n\tpublic uninstall() {\r\n\t\tthis.PageManager = undefined;\r\n\t\tthis.HistoryManager = undefined;\r\n\t\tthis.ServiceManager = undefined;\r\n\t\tthis.TransitionManager = undefined;\r\n\t}\r\n\r\n\t// Stop services\r\n\tpublic stop(): void {\r\n\t\tthis.stopEvents();\r\n\t\tthis.unregister();\r\n\t}\r\n}\r\n\r\n/**\r\n * The Service Manager controls the lifecycle of all services in an App\r\n *\r\n * @export\r\n * @class ServiceManager\r\n * @extends {AdvancedManager}\r\n */\r\nexport class ServiceManager extends AdvancedManager {\r\n\t/**\r\n\t * Creates an instance of ServiceManager.\r\n\t *\r\n\t * @param {App} app\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tconstructor(app: App) {\r\n\t\tsuper(app);\r\n\t}\r\n\r\n\t/**\r\n\t * Call the init method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic init(): ServiceManager {\r\n\t\tmethodCall(this, \"init\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the boot method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic boot(): ServiceManager {\r\n\t\tmethodCall(this, \"boot\", this.app);\r\n\t\treturn this;\r\n\t}\r\n\r\n\t/**\r\n\t * Call the stop method for all Services\r\n\t *\r\n\t * @returns ServiceManager\r\n\t * @memberof ServiceManager\r\n\t */\r\n\tpublic stop(): ServiceManager {\r\n\t\tmethodCall(this, \"stop\", this.app);\r\n\t\treturn this;\r\n\t}\r\n}\r\n", "import { newState, Trigger, IState, newCoords, IHistoryItem, changeState } from \"./history\";\r\nimport { Service } from \"./service\";\r\nimport { Page } from \"./page\";\r\nimport { newURL, getHashedPath, equal } from \"./url\";\r\n\r\nexport type LinkEvent = MouseEvent | TouchEvent;\r\nexport type StateEvent = LinkEvent | PopStateEvent;\r\nexport type IgnoreURLsList = Array;\r\n\r\n/**\r\n * Creates a Barba JS like PJAX Service, for the Framework\r\n *\r\n * @export\r\n * @class PJAX\r\n * @extends {Service}\r\n */\r\n// Based on Barba JS and StartingBlocks\r\nexport class PJAX extends Service {\r\n /**\r\n * URLs to ignore when prefetching\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected ignoreURLs: IgnoreURLsList = [];\r\n\r\n /**\r\n * Whether or not to disable prefetching\r\n *\r\n * @private\r\n *\r\n * @memberof PJAX\r\n */\r\n protected prefetchIgnore: boolean = false;\r\n\r\n /**\r\n * Current state or transitions\r\n *\r\n * @public\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n public isTransitioning: boolean = false;\r\n\r\n /**\r\n * Ignore extra clicks of an anchor element if a transition has already started\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stopOnTransitioning: boolean = false;\r\n\r\n /**\r\n * On page change (excluding popstate event) keep current scroll position\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected stickyScroll: boolean = false;\r\n\r\n /**\r\n * Force load a page if an error occurs\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected forceOnError: boolean = false;\r\n\r\n /**\r\n * Dictates whether to auto scroll if an hash is present in the window URL\r\n *\r\n * @protected\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected autoScrollOnHash: boolean = true;\r\n\r\n /**\r\n * Disables all extra scroll effects of PJAX\r\n *\r\n * @private\r\n * @type boolean\r\n * @memberof PJAX\r\n */\r\n protected dontScroll: boolean = false;\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to true\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStart() {\r\n this.isTransitioning = true;\r\n }\r\n\r\n /**\r\n * Sets the transition state, sets isTransitioning to false\r\n *\r\n * @private\r\n * @memberof PJAX\r\n */\r\n private transitionStop() {\r\n this.isTransitioning = false;\r\n }\r\n\r\n public init() {\r\n super.init();\r\n\r\n /**\r\n * Bind the event listeners to the PJAX class\r\n *\r\n * @memberof PJAX\r\n */\r\n this.onHover = this.onHover.bind(this);\r\n this.onClick = this.onClick.bind(this);\r\n this.onStateChange = this.onStateChange.bind(this);\r\n }\r\n\r\n /**\r\n * Starts the PJAX Service\r\n *\r\n * @memberof PJAX\r\n */\r\n public boot() {\r\n if (\"scrollRestoration\" in window.history) {\r\n // Back off, browser, I got this...\r\n window.history.scrollRestoration = \"manual\";\r\n }\r\n\r\n super.boot();\r\n }\r\n\r\n /**\r\n * Gets the transition to use for a certain anchor\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getTransitionName(el: HTMLAnchorElement): string | null {\r\n if (!el || !el.getAttribute) return null;\r\n let transitionAttr = el.getAttribute(\r\n this.config.getConfig(\"transitionAttr\", false)\r\n );\r\n if (typeof transitionAttr === \"string\") return transitionAttr;\r\n return null;\r\n }\r\n\r\n /**\r\n * Checks to see if the anchor is valid\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @param {(LinkEvent | KeyboardEvent)} event\r\n * @param {string} href\r\n *\r\n * @memberof PJAX\r\n */\r\n public validLink(\r\n el: HTMLAnchorElement,\r\n event: LinkEvent | KeyboardEvent,\r\n href: string\r\n ): boolean {\r\n let pushStateSupport = !window.history.pushState;\r\n let exists = !el || !href;\r\n let eventMutate =\r\n (event as KeyboardEvent).metaKey ||\r\n (event as KeyboardEvent).ctrlKey ||\r\n (event as KeyboardEvent).shiftKey ||\r\n (event as KeyboardEvent).altKey;\r\n let newTab =\r\n el.hasAttribute(\"target\") &&\r\n (el as HTMLAnchorElement).target === \"_blank\";\r\n let crossOrigin =\r\n (el as HTMLAnchorElement).protocol !== location.protocol ||\r\n (el as HTMLAnchorElement).hostname !== location.hostname;\r\n let download = typeof el.getAttribute(\"download\") === \"string\";\r\n let preventSelf = el.hasAttribute(this.config.getConfig(\"preventSelfAttr\", false));\r\n let preventAll = Boolean(\r\n el.closest(this.config.getConfig(\"preventAllAttr\"))\r\n );\r\n let prevent = preventSelf && preventAll;\r\n let sameURL = getHashedPath(newURL()) === getHashedPath(newURL(href));\r\n return !(\r\n exists ||\r\n pushStateSupport ||\r\n eventMutate ||\r\n newTab ||\r\n crossOrigin ||\r\n download ||\r\n prevent ||\r\n sameURL\r\n );\r\n }\r\n\r\n /**\r\n * Returns the href or an Anchor element\r\n *\r\n * @param {HTMLAnchorElement} el\r\n * @returns {(string | null)}\r\n * @memberof PJAX\r\n */\r\n public getHref(el: HTMLAnchorElement): string | null {\r\n if (\r\n el &&\r\n el.tagName &&\r\n el.tagName.toLowerCase() === \"a\" &&\r\n typeof el.href === \"string\"\r\n )\r\n return el.href;\r\n return null;\r\n }\r\n\r\n /**\r\n * Check if event target is a valid anchor with an href, if so, return the link\r\n *\r\n * @param {LinkEvent} event\r\n *\r\n * @memberof PJAX\r\n */\r\n public getLink(event: LinkEvent): HTMLAnchorElement {\r\n let el = event.target as HTMLAnchorElement;\r\n let href: string = this.getHref(el);\r\n\r\n while (el && !href) {\r\n el = (el as HTMLElement).parentNode as HTMLAnchorElement;\r\n href = this.getHref(el);\r\n }\r\n\r\n // Check for a valid link\r\n if (!el || !this.validLink(el, event, href)) return;\r\n return el;\r\n }\r\n\r\n /**\r\n * When an element is clicked.\r\n *\r\n * Get valid anchor element.\r\n * Go for a transition.\r\n *\r\n * @param {LinkEvent} event\r\n * @returns\r\n * @memberof PJAX\r\n */\r\n public onClick(event: LinkEvent) {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n event.preventDefault();\r\n event.stopPropagation();\r\n return;\r\n }\r\n\r\n let href = this.getHref(el);\r\n this.emitter.emit(\"ANCHOR_CLICK CLICK\", event);\r\n this.go({ href, trigger: el, event });\r\n }\r\n\r\n /**\r\n * Returns the direction of the State change as a String, either the Back button or the Forward button\r\n *\r\n * @param {number} value\r\n *\r\n * @memberof PJAX\r\n */\r\n public getDirection(value: number): Trigger {\r\n if (Math.abs(value) > 1) {\r\n // Ex 6-0 > 0 -> forward, 0-6 < 0 -> back\r\n return value > 0 ? \"forward\" : \"back\";\r\n } else {\r\n if (value === 0) {\r\n return \"popstate\";\r\n } else {\r\n // Ex 6-5 > 0 -> back, 5-6 < 0 -> forward\r\n return value > 0 ? \"back\" : \"forward\";\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Force a page to go to a certain URL\r\n *\r\n * @param {string} href\r\n * @memberof PJAX\r\n */\r\n public force(href: string): void {\r\n window.location.assign(href);\r\n }\r\n\r\n /**\r\n * If transition is running force load page.\r\n * Stop if currentURL is the same as new url.\r\n * On state change, change the current state history,\r\n * to reflect the direction of said state change\r\n * Load page and page transition.\r\n *\r\n * @param {string} href\r\n * @param {Trigger} [trigger='HistoryManager']\r\n * @param {StateEvent} [event]\r\n * @memberof PJAX\r\n */\r\n public go({\r\n href,\r\n trigger = \"HistoryManager\",\r\n event,\r\n }: {\r\n href: string;\r\n trigger?: Trigger;\r\n event?: StateEvent;\r\n }): Promise {\r\n // If transition is already running and the go method is called again, force load page\r\n if (this.isTransitioning && this.stopOnTransitioning) {\r\n this.force(href);\r\n return;\r\n }\r\n\r\n let scroll = { x: 0, y: 0 };\r\n let currentState = this.HistoryManager.current;\r\n let currentURL = currentState.url;\r\n if (equal(currentURL, href)) {\r\n return;\r\n }\r\n\r\n let transitionName: string;\r\n if (event && (event as PopStateEvent).state) {\r\n this.emitter.emit(\"POPSTATE\", event);\r\n\r\n // If popstate, get back/forward direction.\r\n let { state }: { state: IHistoryItem } = event as PopStateEvent;\r\n let { index } = state;\r\n let currentIndex = currentState.index;\r\n let difference = currentIndex - index;\r\n\r\n trigger = this.getDirection(difference);\r\n\r\n let _state = this.HistoryManager.get(this.HistoryManager.pointer);\r\n transitionName = _state.transition;\r\n scroll = _state.data.scroll;\r\n\r\n // Based on the direction of the state change either remove or add a state\r\n this.HistoryManager.replace(state.states);\r\n this.HistoryManager.pointer = index;\r\n if (trigger === \"back\") {\r\n // this.HistoryManager.remove(currentIndex);\r\n this.emitter.emit(`POPSTATE_BACK`, event);\r\n } else if (trigger === \"forward\") {\r\n // this.HistoryManager.add({ url: href, transition, data });\r\n this.emitter.emit(`POPSTATE_FORWARD`, event);\r\n }\r\n\r\n } else {\r\n // Add new state\r\n transitionName = this.getTransitionName(trigger as HTMLAnchorElement) ||\r\n \"default\";\r\n\r\n scroll = newCoords();\r\n\r\n let state = newState({\r\n url: href,\r\n transition: transitionName,\r\n data: { scroll },\r\n });\r\n\r\n this.HistoryManager.add(state);\r\n this.emitter.emit(\"HISTORY_NEW_ITEM\", event);\r\n }\r\n\r\n if (event) {\r\n event.stopPropagation();\r\n event.preventDefault();\r\n }\r\n\r\n this.emitter.emit(\"GO\", event);\r\n return this.load({\r\n oldHref: currentURL,\r\n href,\r\n trigger,\r\n transitionName,\r\n scroll,\r\n });\r\n }\r\n\r\n /**\r\n * Load the new Page as well as a Transition; run the Transition\r\n *\r\n * @param {string} oldHref\r\n * @param {string} href\r\n * @param {Trigger} trigger\r\n * @param {string} [transitionName=\"default\"]\r\n *\r\n * @memberof PJAX\r\n */\r\n public async load({\r\n oldHref,\r\n href,\r\n trigger,\r\n transitionName = \"default\",\r\n scroll = { x: 0, y: 0 },\r\n }: {\r\n oldHref: string;\r\n href: string;\r\n trigger: Trigger;\r\n transitionName?: string;\r\n scroll: { x: number; y: number };\r\n }): Promise {\r\n try {\r\n let oldPage = await this.PageManager.load(oldHref);\r\n await oldPage.build();\r\n let newPage: Page;\r\n\r\n this.emitter.emit(\"PAGE_LOADING\", { href, oldPage, trigger });\r\n try {\r\n try {\r\n newPage = await this.PageManager.load(href);\r\n await newPage.build();\r\n this.transitionStart();\r\n this.emitter.emit(\"PAGE_LOAD_COMPLETE\", {\r\n newPage,\r\n oldPage,\r\n trigger,\r\n });\r\n } catch (err) {\r\n console.error(`[PJAX] page load error: ${err}`);\r\n }\r\n\r\n // --\r\n // --\r\n\r\n this.emitter.emit(\"NAVIGATION_START\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n\r\n try {\r\n this.emitter.emit(\"TRANSITION_START\", transitionName);\r\n\r\n let transition = await this.TransitionManager.boot(transitionName, {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n scroll,\r\n });\r\n\r\n if (!transition.scrollable) {\r\n if (!/back|popstate|forward/.test(trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n\r\n window.scroll(scroll.x, scroll.y);\r\n }\r\n\r\n this.emitter.emit(\"TRANSITION_END\", { transition });\r\n\r\n } catch (err) {\r\n console.error(`[PJAX] transition error: ${err}`);\r\n }\r\n\r\n this.emitter.emit(\"NAVIGATION_END\", {\r\n oldPage,\r\n newPage,\r\n trigger,\r\n transitionName,\r\n });\r\n } catch (err) {\r\n this.transitionStop();\r\n throw err;\r\n }\r\n\r\n this.transitionStop(); // Sets isTransitioning to false\r\n } catch (err) {\r\n if (this.forceOnError) this.force(href);\r\n else console.error(err);\r\n }\r\n }\r\n\r\n /**\r\n * Check to see if the URL is to be ignored, uses either RegExp of Strings to check\r\n *\r\n * @param {URL} { pathname }\r\n *\r\n * @memberof PJAX\r\n */\r\n public ignoredURL({ pathname }: URL): boolean {\r\n return (\r\n this.ignoreURLs.length &&\r\n this.ignoreURLs.some((url) => {\r\n return typeof url === \"string\"\r\n ? url === pathname\r\n : (url as RegExp).exec(pathname) !== null;\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * When you hover over an anchor, prefetch the event target's href\r\n *\r\n * @param {LinkEvent} event\r\n * @memberof PJAX\r\n */\r\n public onHover(event: LinkEvent): Promise {\r\n let el = this.getLink(event);\r\n if (!el) return;\r\n\r\n let url = newURL(this.getHref(el));\r\n let urlString: string = url.pathname;\r\n // If Url is ignored or already in cache, don't do any think\r\n if (this.ignoredURL(url) || this.PageManager.has(urlString)) return;\r\n this.emitter.emit(\"ANCHOR_HOVER HOVER\", event);\r\n\r\n try {\r\n this.PageManager.load(url);\r\n } catch (err) {\r\n console.warn(\"[PJAX] prefetch error,\", err);\r\n }\r\n }\r\n\r\n /**\r\n * When History state changes.\r\n *\r\n * Get url from State\r\n * Go for a Barba transition.\r\n *\r\n * @param {PopStateEvent} event\r\n * @memberof PJAX\r\n */\r\n public onStateChange(event: PopStateEvent): void {\r\n this.go({ href: window.location.href, trigger: \"popstate\", event });\r\n }\r\n\r\n /**\r\n * Initialize DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public initEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.addEventListener(\"mouseover\", this.onHover);\r\n document.addEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.addEventListener(\"click\", this.onClick);\r\n window.addEventListener(\"popstate\", this.onStateChange);\r\n }\r\n\r\n /**\r\n * Stop DOM Events\r\n *\r\n * @memberof PJAX\r\n */\r\n public stopEvents() {\r\n if (this.prefetchIgnore !== true) {\r\n document.removeEventListener(\"mouseover\", this.onHover);\r\n document.removeEventListener(\"touchstart\", this.onHover);\r\n }\r\n\r\n document.removeEventListener(\"click\", this.onClick);\r\n window.removeEventListener(\"popstate\", this.onStateChange);\r\n }\r\n}\r\n\r\n\r\n/**\r\n * Auto scrolls to an elements position if the element has an hash\r\n *\r\n * @param {string} [hash=window.location.hash]\r\n * @memberof PJAX\r\n */\r\nexport const hashAction = (hash: string = window.location.hash) => {\r\n try {\r\n\r\n let _hash = hash[0] == \"#\" ? hash : newURL(hash).hash;\r\n if (_hash.length > 1) {\r\n let el = document.getElementById(_hash.slice(1)) as HTMLElement;\r\n\r\n if (el) {\r\n return newCoords(el.offsetLeft, el.offsetTop);\r\n }\r\n }\r\n } catch (e) {\r\n console.warn(\"hashAction error\", e);\r\n }\r\n\r\n return newCoords(0, 0);\r\n};\r\n", "import { Manager } from \"./manager\";\r\nimport { EventEmitter } from \"./emitter\";\r\nimport { ICoords, Trigger } from \"./history\";\r\nimport { Page } from \"./page\";\r\nimport { App } from \"./app\";\r\nimport { CONFIG } from \"./config\";\r\nimport { hashAction } from \"./pjax\";\r\n\r\n/**\r\n * The async function type, allows for smooth transition between Promises\r\n */\r\nexport type asyncFn = (err?: any, value?: any) => void;\r\nexport interface ITransition {\r\n oldPage?: Page;\r\n newPage?: Page;\r\n trigger?: Trigger;\r\n scroll?: { x: number; y: number };\r\n scrollable?: boolean;\r\n in: (data: ITransitionData) => any;\r\n out: (data: ITransitionData) => any;\r\n [key: string]: any;\r\n}\r\nexport interface ITransitionData {\r\n from?: Page;\r\n to?: Page;\r\n trigger?: Trigger;\r\n scroll?: ICoords;\r\n done: asyncFn;\r\n}\r\n\r\n/**\r\n * Controls which animation between pages to use\r\n *\r\n * @export\r\n * @class TransitionManager\r\n * @extends {Manager}\r\n */\r\nexport class TransitionManager extends Manager {\r\n /**\r\n * The instance of the App class, the Manager is instantiated in\r\n *\r\n * @type App\r\n * @memberof AdvancedManager\r\n */\r\n public app: App;\r\n\r\n /**\r\n * The Config class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof AdvancedManager\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * The EventEmitter class of the App the AdvancedManager is attached to\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof AdvancedManager\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * Creates an instance of the TransitionManager\r\n *\r\n * @param {App} app\r\n * @memberof TransitionManager\r\n */\r\n constructor(app: App) {\r\n super();\r\n this.app = app;\r\n this.config = app.config;\r\n this.emitter = app.emitter;\r\n }\r\n\r\n /**\r\n * Runs a transition\r\n *\r\n * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data\r\n * @returns Promise\r\n * @memberof TransitionManager\r\n */\r\n public async boot(name: string, data: any): Promise {\r\n let transition: ITransition = this.get(name);\r\n let scroll = data.scroll;\r\n if (!(data.oldPage instanceof Page) || !(data.newPage instanceof Page))\r\n throw `[Page] either oldPage or newPage aren't instances of the Page Class.\\n ${{\r\n newPage: data.newPage,\r\n oldPage: data.oldPage,\r\n }}`;\r\n\r\n let fromWrapper = data.oldPage.wrapper;\r\n let toWrapper = data.newPage.wrapper;\r\n document.title = `` + data.newPage.title;\r\n\r\n if (!(fromWrapper instanceof Node) || !(toWrapper instanceof Node))\r\n throw `[Wrapper] the wrapper from the ${!(toWrapper instanceof Node) ? \"next\" : \"current\"\r\n } page cannot be found. The wrapper must be an element that has the attribute ${this.config.getConfig(\r\n \"wrapperAttr\"\r\n )}.`;\r\n transition.init && transition?.init(data);\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n let outMethod: Promise = transition.out.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n trigger: data.trigger,\r\n done,\r\n });\r\n\r\n if (outMethod.then) outMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_OUT\");\r\n await new Promise((done) => {\r\n fromWrapper.insertAdjacentElement(\"beforebegin\", toWrapper);\r\n this.emitter.emit(\"CONTENT_INSERT\");\r\n\r\n if (!/back|popstate|forward/.test(data.trigger as string)) {\r\n scroll = hashAction();\r\n }\r\n done();\r\n });\r\n\r\n await new Promise((done) => {\r\n fromWrapper.remove();\r\n fromWrapper = undefined;\r\n toWrapper = undefined;\r\n this.emitter.emit(\"CONTENT_REPLACED\");\r\n done();\r\n });\r\n\r\n this.emitter.emit(\"BEFORE_TRANSITION_IN\");\r\n\r\n await new Promise(async (done) => {\r\n let inMethod: Promise = transition.in.call(transition, {\r\n ...data,\r\n from: data.oldPage,\r\n to: data.newPage,\r\n trigger: data.trigger,\r\n scroll,\r\n done,\r\n });\r\n\r\n if (inMethod.then) inMethod.then(done);\r\n });\r\n\r\n this.emitter.emit(\"AFTER_TRANSITION_IN\");\r\n return transition;\r\n }\r\n}\r\n", "import { EventEmitter, ListenerCallback, EventInput } from \"./emitter\";\r\nimport { ITransition, TransitionManager } from \"./transition\";\r\nimport { HistoryManager, IState } from \"./history\";\r\nimport { ServiceManager, Service } from \"./service\";\r\nimport { PageManager } from \"./page\";\r\nimport { CONFIG, ICONFIG } from \"./config\";\r\n\r\n/**\r\n * The App class starts the entire process, it controls all managers and all services\r\n *\r\n * @export\r\n * @class App\r\n */\r\nexport class App {\r\n /**\r\n * A new instance of the HistoryManager\r\n *\r\n * @public\r\n * @type HistoryManager\r\n * @memberof App\r\n */\r\n public history: HistoryManager;\r\n\r\n /**\r\n * A new instance of the TransitionManager\r\n *\r\n * @public\r\n * @type TransitionManager\r\n * @memberof App\r\n */\r\n public transitions: TransitionManager;\r\n\r\n /**\r\n * A new instance of the ServiceManager\r\n *\r\n * @public\r\n * @type ServiceManager\r\n * @memberof App\r\n */\r\n public services: ServiceManager;\r\n\r\n /**\r\n * A new instance of an EventEmitter\r\n *\r\n * @public\r\n * @type EventEmitter\r\n * @memberof App\r\n */\r\n public emitter: EventEmitter;\r\n\r\n /**\r\n * A new instance of the PageManager\r\n *\r\n * @public\r\n * @type PageManager\r\n * @memberof App\r\n */\r\n public pages: PageManager;\r\n\r\n /**\r\n * The current Configuration's for the framework\r\n *\r\n * @public\r\n * @type CONFIG\r\n * @memberof App\r\n */\r\n public config: CONFIG;\r\n\r\n /**\r\n * Creates an instance of App.\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @memberof App\r\n */\r\n constructor(config: object = {}) {\r\n this.register(config);\r\n }\r\n\r\n /**\r\n * For registering all managers and the configurations\r\n *\r\n * @param {(ICONFIG | CONFIG)} [config={}]\r\n * @returns App\r\n * @memberof App\r\n */\r\n public register(config: ICONFIG | CONFIG = {}): App {\r\n this.config = config instanceof CONFIG ? config : new CONFIG(config);\r\n this.emitter = new EventEmitter();\r\n this.history = new HistoryManager();\r\n this.pages = new PageManager(this);\r\n this.transitions = new TransitionManager(this);\r\n this.services = new ServiceManager(this);\r\n\r\n let handler = (() => {\r\n document.removeEventListener(\"DOMContentLoaded\", handler);\r\n window.removeEventListener(\"load\", handler);\r\n this.emitter.emit(\"READY ready\");\r\n }).bind(this);\r\n\r\n document.addEventListener(\"DOMContentLoaded\", handler);\r\n window.addEventListener(\"load\", handler);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\" | string)} type\r\n * @param {any} key\r\n * @returns Service | Transition | State\r\n * @memberof App\r\n */\r\n public get(type: \"service\" | \"transition\" | \"state\" | string, key: any): Service | ITransition | IState {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n return this.services.get(key);\r\n case \"transition\":\r\n return this.transitions.get(key);\r\n case \"state\":\r\n return this.history.get(key);\r\n default:\r\n throw `Error: can't get type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n }\r\n\r\n /**\r\n * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers\r\n *\r\n * @param {(\"page\" | string)} type\r\n * @param {any} key\r\n * @returns App\r\n * @memberof App\r\n */\r\n public async load(type: \"page\" | string, key: any): Promise {\r\n switch (type.toLowerCase()) {\r\n case \"page\":\r\n return await this.pages.load(key);\r\n default:\r\n return Promise.resolve(this.get(type, key));\r\n }\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {Service} service\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setService(key: string, service: Service): App {\r\n this.services.set(key, service);\r\n return this;\r\n }\r\n\r\n /**\r\n * Adds a Service to the App's instance of the ServiceManager, with a name\r\n *\r\n * @param {string} key\r\n * @param {ITransition} tranisition\r\n * @returns App\r\n * @memberof App\r\n */\r\n public setTransition(key: string, transition: ITransition): App {\r\n this.transitions.set(key, transition);\r\n return this;\r\n }\r\n\r\n /**\r\n * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers\r\n *\r\n * @param {(\"service\" | \"transition\" | \"state\")} type\r\n * @param {any} value\r\n * @returns App\r\n * @memberof App\r\n */\r\n public add(type: \"service\" | \"transition\" | \"state\", value: any): App {\r\n switch (type.toLowerCase()) {\r\n case \"service\":\r\n this.services.add(value);\r\n break;\r\n case \"transition\":\r\n this.transitions.set(value.name, value);\r\n break;\r\n case \"state\":\r\n this.history.add(value);\r\n break;\r\n default:\r\n throw `Error: can't add type '${type}', it is not a recognized type. Did you spell it correctly.`;\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Start the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public boot(): App {\r\n this.services.init();\r\n this.services.boot();\r\n return this;\r\n }\r\n\r\n /**\r\n * Stop the App and the ServiceManager\r\n *\r\n * @returns App\r\n * @memberof App\r\n */\r\n public stop(): App {\r\n this.services.stop();\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter on method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.on(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter off method\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} callback\r\n * @returns App\r\n * @memberof App\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback): App {\r\n this.emitter.off(events, callback, this);\r\n return this;\r\n }\r\n\r\n /**\r\n * A shortcut to the App EventEmitter emit method\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns App\r\n * @memberof App\r\n */\r\n public emit(events: string | any[], ...args: any): App {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n}\r\n", "import { Service } from \"./service\";\r\nimport { Manager } from \"./manager\";\r\nimport { newURL, getHashedPath } from \"./url\";\r\n\r\nexport type RouteMethod = (...args: any) => any;\r\nexport type RouteStyle = string | RegExp | boolean;\r\nexport interface IRouteToFrom {\r\n to: RouteStyle,\r\n from: RouteStyle\r\n}\r\nexport type RoutePath = IRouteToFrom | RouteStyle;\r\nexport interface IRoute {\r\n path: RoutePath,\r\n method: RouteMethod\r\n}\r\n\r\n/**\r\n * Controls what happens when certain url paths match a set of criteria\r\n *\r\n * @export\r\n * @class Router\r\n * @extends {Service}\r\n */\r\nexport class Router extends Service {\r\n /**\r\n * List of routes inputted\r\n *\r\n * @protected\r\n * @type {Manager}\r\n * @memberof Router\r\n */\r\n protected routes: Manager;\r\n\r\n /**\r\n * Creates an instance of Router.\r\n *\r\n * @param {Array} [routes=[]]\r\n * @memberof Router\r\n */\r\n constructor(routes: IRoute[] = []) {\r\n super();\r\n this.routes = new Manager();\r\n for (let route of routes) {\r\n this.add(route);\r\n }\r\n }\r\n\r\n /**\r\n * Add a new route to watch for\r\n *\r\n * @param {IRoute} { path, method }\r\n * @returns {Router}\r\n * @memberof Router\r\n */\r\n public add({ path, method }: IRoute): Router {\r\n let key = this.parse(path);\r\n this.routes.set(key, method);\r\n return this;\r\n }\r\n\r\n /**\r\n * Convert strings into path match functions\r\n *\r\n * @param {RouteStyle} path\r\n * @returns {RegExp | boolean}\r\n * @memberof Router\r\n */\r\n public parsePath(path: RouteStyle): RegExp | boolean {\r\n if (typeof path === \"string\") return new RegExp(path, \"i\");\r\n else if (path instanceof RegExp || typeof path === \"boolean\")\r\n return path;\r\n throw \"[Router] only regular expressions, strings and booleans are accepted as paths.\";\r\n }\r\n\r\n /**\r\n * Determines if a strings counts has a path\r\n *\r\n * @param {RouteStyle} input\r\n * @returns boolean\r\n * @memberof Router\r\n */\r\n public isPath(input: RouteStyle): boolean {\r\n return (\r\n typeof input === \"string\" ||\r\n input instanceof RegExp ||\r\n typeof input === \"boolean\"\r\n );\r\n }\r\n\r\n /**\r\n * Parse the multiple different formats for paths, into a { from, to } object\r\n *\r\n * @param {RouteStyle} input\r\n * @returns {IRouteToFrom}\r\n * @memberof Router\r\n */\r\n public parse(input: RoutePath): IRouteToFrom {\r\n let route = input as IRouteToFrom;\r\n let toFromPath: IRouteToFrom = {\r\n from: /(.*)/g,\r\n to: /(.*)/g,\r\n };\r\n\r\n if (this.isPath(input as RouteStyle))\r\n toFromPath = {\r\n from: true,\r\n to: input as RouteStyle,\r\n };\r\n else if (this.isPath(route.from) && this.isPath(route.to as RouteStyle))\r\n toFromPath = route;\r\n else\r\n throw \"[Router] path is neither a string, regular expression, or a { from, to } object.\";\r\n\r\n let { from, to } = toFromPath;\r\n return {\r\n from: this.parsePath(from),\r\n to: this.parsePath(to),\r\n };\r\n }\r\n\r\n /**\r\n * Test if route paths are true, if so run their methods\r\n *\r\n * @memberof Router\r\n */\r\n public route() {\r\n let history = this.HistoryManager;\r\n let from: string = getHashedPath(newURL((history.length > 1 ? history.previous : history.current).url));\r\n let to: string = getHashedPath(newURL());\r\n\r\n this.routes.forEach((method: RouteMethod, path: IRouteToFrom) => {\r\n let fromRegExp = path.from as RegExp | boolean;\r\n let toRegExp = path.to as RegExp | boolean;\r\n\r\n if (\r\n typeof fromRegExp === \"boolean\" &&\r\n typeof toRegExp === \"boolean\"\r\n ) {\r\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.`;\r\n }\r\n\r\n let fromParam: RegExpExecArray | RegExp | boolean = fromRegExp;\r\n let toParam: RegExpExecArray | RegExp | boolean = toRegExp;\r\n\r\n if (fromRegExp instanceof RegExp && fromRegExp.test(from))\r\n fromParam = fromRegExp.exec(from);\r\n if (toRegExp instanceof RegExp && toRegExp.test(to))\r\n toParam = toRegExp.exec(to);\r\n\r\n if (\r\n (Array.isArray(toParam) && Array.isArray(fromParam)) ||\r\n (Array.isArray(toParam) &&\r\n typeof fromParam == \"boolean\" &&\r\n fromParam) ||\r\n (Array.isArray(fromParam) &&\r\n typeof toParam == \"boolean\" &&\r\n toParam)\r\n )\r\n method({ from: fromParam, to: toParam, path: { from, to } });\r\n });\r\n }\r\n\r\n /**\r\n * Add listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public initEvents() {\r\n this.emitter.on(\"READY\", this.route, this);\r\n this.emitter.on(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n\r\n /**\r\n * Remove listeners for PJAX Events\r\n *\r\n * @memberof Router\r\n */\r\n public stopEvents() {\r\n this.emitter.off(\"READY\", this.route, this);\r\n this.emitter.off(\"CONTENT_REPLACED\", this.route, this);\r\n }\r\n}\r\n", "import { EventEmitter, EventInput, ListenerCallback } from \"@okikio/emitter\";\r\n\r\n// DOM\r\nexport type AnimationTarget = string | Node | NodeList | HTMLCollection | HTMLElement[] | any[];\r\nexport const getElements = (selector: string | Node): Node[] => {\r\n return typeof selector === \"string\" ? Array.from(document.querySelectorAll(selector as string)) : [selector];\r\n};\r\n\r\nexport const getTargets = (targets: AnimationTarget): Node[] => {\r\n if (Array.isArray(targets)) return targets;\r\n if (typeof targets == \"string\" || targets instanceof Node)\r\n return getElements(targets);\r\n if (targets instanceof NodeList || targets instanceof HTMLCollection)\r\n return Array.from(targets);\r\n return [];\r\n};\r\n\r\n// VALUES\r\nexport type closureArgs = [number, number, HTMLElement];\r\nexport type closure = ((index?: number, total?: number, element?: HTMLElement) => any) | any;\r\nexport const computeValue = (value: closure, args: closureArgs) => {\r\n if (typeof value === \"function\") {\r\n return value(...args);\r\n } else { return value; }\r\n};\r\n\r\nexport const mapObject = (obj: object, args: closureArgs): any => {\r\n let key, value, result = {};\r\n let keys = Object.keys(obj);\r\n for (let i = 0, len = keys.length; i < len; i++) {\r\n key = keys[i];\r\n value = obj[key];\r\n result[key] = computeValue(value, args);\r\n }\r\n\r\n return result;\r\n};\r\n\r\n// From: [https://easings.net]\r\nexport const easings = {\r\n \"ease\": \"ease\",\r\n \"in\": \"ease-in\",\r\n \"out\": \"ease-out\",\r\n \"in-out\": \"ease-in-out\",\r\n\r\n // Sine\r\n \"in-sine\": \"cubic-bezier(0.47, 0, 0.745, 0.715)\",\r\n \"out-sine\": \"cubic-bezier(0.39, 0.575, 0.565, 1)\",\r\n \"in-out-sine\": \"cubic-bezier(0.445, 0.05, 0.55, 0.95)\",\r\n\r\n // Quad\r\n \"in-quad\": \"cubic-bezier(0.55, 0.085, 0.68, 0.53)\",\r\n \"out-quad\": \"cubic-bezier(0.25, 0.46, 0.45, 0.94)\",\r\n \"in-out-quad\": \"cubic-bezier(0.455, 0.03, 0.515, 0.955)\",\r\n\r\n // Cubic\r\n \"in-cubic\": \"cubic-bezier(0.55, 0.055, 0.675, 0.19)\",\r\n \"out-cubic\": \"cubic-bezier(0.215, 0.61, 0.355, 1)\",\r\n \"in-out-cubic\": \"cubic-bezier(0.645, 0.045, 0.355, 1)\",\r\n\r\n // Quart\r\n \"in-quart\": \"cubic-bezier(0.895, 0.03, 0.685, 0.22)\",\r\n \"out-quart\": \"cubic-bezier(0.165, 0.84, 0.44, 1)\",\r\n \"in-out-quart\": \"cubic-bezier(0.77, 0, 0.175, 1)\",\r\n\r\n // Quint\r\n \"in-quint\": \"cubic-bezier(0.755, 0.05, 0.855, 0.06)\",\r\n \"out-quint\": \"cubic-bezier(0.23, 1, 0.32, 1)\",\r\n \"in-out-quint\": \"cubic-bezier(0.86, 0, 0.07, 1)\",\r\n\r\n // Expo\r\n \"in-expo\": \"cubic-bezier(0.95, 0.05, 0.795, 0.035)\",\r\n \"out-expo\": \"cubic-bezier(0.19, 1, 0.22, 1)\",\r\n \"in-out-expo\": \"cubic-bezier(1, 0, 0, 1)\",\r\n\r\n // Circ\r\n \"in-circ\": \"cubic-bezier(0.6, 0.04, 0.98, 0.335)\",\r\n \"out-circ\": \"cubic-bezier(0.075, 0.82, 0.165, 1)\",\r\n \"in-out-circ\": \"cubic-bezier(0.785, 0.135, 0.15, 0.86)\",\r\n\r\n // Back\r\n \"in-back\": \"cubic-bezier(0.6, -0.28, 0.735, 0.045)\",\r\n \"out-back\": \"cubic-bezier(0.175, 0.885, 0.32, 1.275)\",\r\n \"in-out-back\": \"cubic-bezier(0.68, -0.55, 0.265, 1.55)\"\r\n};\r\nexport const getEase = (ease: string) => {\r\n return /^(ease|in|out)/.test(ease) ? easings[ease] : ease;\r\n};\r\n\r\nexport interface AnimationOptions {\r\n target?: AnimationTarget,\r\n\r\n speed?: number | closure,\r\n delay?: number | closure,\r\n easing?: string | closure,\r\n endDelay?: number | closure,\r\n duration?: number | closure,\r\n autoplay?: boolean | closure,\r\n keyframes?: object[] | closure,\r\n loop?: number | boolean | closure, // iterations: number,\r\n options?: AnimationOptions | closure,\r\n onfinish?: (element?: HTMLElement, index?: number, total?: number) => any,\r\n fillMode?: \"none\" | \"forwards\" | \"backwards\" | \"both\" | \"auto\" | closure,\r\n direction?: \"normal\" | \"reverse\" | \"alternate\" | \"alternate-reverse\" | closure,\r\n [property: string]: closure | boolean | object | string | string[] | number | null | (number | null)[] | undefined;\r\n};\r\n\r\nexport const DefaultAnimationOptions: AnimationOptions = {\r\n keyframes: [],\r\n\r\n loop: 1, // iterations: number,\r\n delay: 0,\r\n speed: 1,\r\n endDelay: 0,\r\n easing: \"ease\",\r\n autoplay: true,\r\n duration: 1000,\r\n onfinish() { },\r\n fillMode: \"auto\",\r\n direction: \"normal\",\r\n};\r\n\r\n// You can check it out here: https://codepen.io/okikio/pen/qBbdGaW?editors=0011\r\nexport class Animate {\r\n /**\r\n * Stores the options for the current animation\r\n *\r\n * @public\r\n * @type AnimationOptions\r\n * @memberof Animate\r\n */\r\n public options: AnimationOptions = {};\r\n\r\n /**\r\n * The Array of Elements to Animate\r\n *\r\n * @public\r\n * @type {Node[]}\r\n * @memberof Animate\r\n */\r\n public targets: Node[] = [];\r\n\r\n /**\r\n * The properties to animate\r\n *\r\n * @public\r\n * @type {object}\r\n * @memberof Animate\r\n */\r\n public properties: object = {};\r\n\r\n /**\r\n * A Set of Animations\r\n *\r\n * @public\r\n * @type {Map}\r\n * @memberof Animate\r\n */\r\n public animations: Map = new Map();\r\n\r\n /**\r\n * The total duration of all Animation's\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public duration: number = 0;\r\n\r\n /**\r\n * The Element the main animation uses\r\n *\r\n * @public\r\n * @type {HTMLElement}\r\n * @memberof Animate\r\n */\r\n public mainElement: HTMLElement;\r\n\r\n /**\r\n * Stores an animation that runs on the total duration of the all other Animations, and as such it's the main Animation\r\n *\r\n * @public\r\n * @type {Animation}\r\n * @memberof Animate\r\n */\r\n public mainAnimation: Animation;\r\n\r\n /**\r\n * Stores request frame calls\r\n *\r\n * @public\r\n * @type {number}\r\n * @memberof Animate\r\n */\r\n public animationFrame: number;\r\n\r\n /**\r\n * An event emitter\r\n *\r\n * @public\r\n * @type {EventEmitter}\r\n * @memberof Animate\r\n */\r\n public emitter: EventEmitter = new EventEmitter();\r\n\r\n /**\r\n * The finish method, is called when the main animation has finished\r\n *\r\n * @public\r\n * @type {*}\r\n * @memberof Animate\r\n */\r\n public finish: any;\r\n\r\n /**\r\n * Returns a promise that is fulfilled when the mainAnimation is finished\r\n *\r\n * @public\r\n * @type {Promise}\r\n * @memberof Animate\r\n */\r\n public promise: Promise;\r\n\r\n /**\r\n * Creates an instance of Animate.\r\n *\r\n * @param {AnimationOptions} options\r\n * @memberof Animate\r\n */\r\n constructor(options: AnimationOptions = {}) {\r\n let { options: animation, ...rest } = options;\r\n this.options = Object.assign({}, DefaultAnimationOptions, animation, rest);\r\n this.loop = this.loop.bind(this);\r\n\r\n let {\r\n loop,\r\n delay,\r\n speed,\r\n easing,\r\n endDelay,\r\n duration,\r\n direction,\r\n fillMode,\r\n onfinish,\r\n target,\r\n keyframes,\r\n autoplay,\r\n ...properties\r\n } = this.options;\r\n\r\n this.mainElement = document.createElement(\"span\");\r\n this.targets = getTargets(target);\r\n this.properties = properties;\r\n\r\n let animationKeyframe: Keyframe[] | PropertyIndexedKeyframes;\r\n for (let i = 0, len = this.targets.length; i < len; i++) {\r\n let target = this.targets[i] as HTMLElement;\r\n let animationOptions = {\r\n easing: getEase(easing),\r\n iterations: loop === true ? Infinity : (loop as number),\r\n direction,\r\n endDelay,\r\n duration,\r\n delay,\r\n fill: fillMode,\r\n };\r\n\r\n // Accept keyframes as a keyframes Object, or a method,\r\n // if there are no animations in the keyframes array,\r\n // uses css properties from the options object\r\n let arrKeyframes = computeValue((keyframes as Keyframe[]), [i, len, target]);\r\n animationKeyframe = arrKeyframes.length ? arrKeyframes :\r\n (this.properties as PropertyIndexedKeyframes);\r\n\r\n // Allows the use of functions as the values, for both the keyframes and the animation object\r\n // It adds the capability of advanced stagger animation, similar to the anime js stagger functions\r\n animationOptions = mapObject(animationOptions, [i, len, target]);\r\n if (!(arrKeyframes.length > 0))\r\n animationKeyframe = mapObject(animationKeyframe, [i, len, target]);\r\n\r\n // Set the Animate classes duration to be the Animation with the largest totalDuration\r\n let tempDuration: number =\r\n animationOptions.delay +\r\n (animationOptions.duration * animationOptions.iterations) +\r\n animationOptions.endDelay;\r\n if (this.duration < tempDuration) this.duration = tempDuration;\r\n\r\n // Add animation to the Animations Set\r\n let animation = target.animate(animationKeyframe, animationOptions);\r\n animation.onfinish = () => {\r\n onfinish(target, i, len);\r\n };\r\n this.animations.set(target, animation);\r\n }\r\n\r\n this.mainAnimation = this.mainElement.animate([\r\n { opacity: \"0\" },\r\n { opacity: \"1\" }\r\n ], {\r\n duration: this.duration,\r\n easing: \"linear\"\r\n });\r\n\r\n this.setSpeed(speed);\r\n if (autoplay) this.play();\r\n else this.pause();\r\n\r\n this.promise = this.newPromise();\r\n this.mainAnimation.onfinish = () => {\r\n this.finish(this.options);\r\n window.cancelAnimationFrame(this.animationFrame);\r\n };\r\n }\r\n\r\n /**\r\n * Returns the Array of targets\r\n *\r\n * @returns {Node[]}\r\n * @memberof Animate\r\n */\r\n public getTargets(): Node[] {\r\n return this.targets;\r\n }\r\n\r\n /**\r\n * Returns a new Promise that is resolve when this.finish is called\r\n *\r\n * @public\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public newPromise(): Promise {\r\n return new Promise((resolve, reject) => {\r\n try {\r\n this.finish = (options: AnimationOptions) => {\r\n this.emit(\"finish\", options);\r\n return resolve(options);\r\n };\r\n } catch (err) { reject(err); }\r\n });\r\n }\r\n\r\n /**\r\n * Fulfills the this.promise Promise\r\n *\r\n * @param {(value?: any) => any} [onFulfilled]\r\n * @param {(reason?: any) => any} [onRejected]\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public then(\r\n onFulfilled?: (value?: any) => any,\r\n onRejected?: (reason?: any) => any\r\n ): Promise {\r\n return this.promise.then(onFulfilled, onRejected);\r\n }\r\n\r\n /**\r\n * Catches error that occur in the this.promise Promise\r\n *\r\n * @param {(reason?: any) => any} onRejected\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public catch(onRejected: (reason?: any) => any): Promise {\r\n return this.promise.catch(onRejected);\r\n }\r\n\r\n /**\r\n * If you don't care if the this.promise Promise has either been rejected or resolved\r\n *\r\n * @param {() => any} onFinally\r\n * @returns {Promise}\r\n * @memberof Animate\r\n */\r\n public finally(onFinally: () => any): Promise {\r\n return this.promise.finally(onFinally);\r\n }\r\n\r\n /**\r\n * Represents an Animation Frame Loop\r\n *\r\n * @public\r\n * @memberof Animate\r\n */\r\n public loop(): void {\r\n this.animationFrame = window.requestAnimationFrame(this.loop);\r\n this.emit(\"tick change\", this.getCurrentTime());\r\n }\r\n\r\n /**\r\n * Adds a listener for a given event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public on(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.on(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Removes a listener from an event\r\n *\r\n * @param {EventInput} events\r\n * @param {ListenerCallback} [callback]\r\n * @param {object} [scope]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public off(events: EventInput, callback?: ListenerCallback, scope?: object): Animate {\r\n this.emitter.off(events, callback, scope);\r\n return this;\r\n }\r\n\r\n /**\r\n * Call all listeners within an event\r\n *\r\n * @param {(string | any[])} events\r\n * @param {...any} args\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public emit(events: string | any[], ...args: any): Animate {\r\n this.emitter.emit(events, ...args);\r\n return this;\r\n }\r\n\r\n /**\r\n * Get a specific Animation from an Animate instance\r\n *\r\n * @param {HTMLElement} element\r\n * @returns {Animation}\r\n * @memberof Animate\r\n */\r\n public getAnimation(element: HTMLElement): Animation {\r\n return this.animations.get(element);\r\n }\r\n\r\n /**\r\n * Play Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public play(): Animate {\r\n // Once the animation is done, it's done, it can only be paused by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.play();\r\n this.animationFrame = requestAnimationFrame(this.loop);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.play();\r\n });\r\n this.emit(\"play\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Pause Animation's\r\n *\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public pause(): Animate {\r\n // Once the animation is done, it's done, it can only be reset by the reset method\r\n if (this.mainAnimation.playState !== \"finished\") {\r\n this.mainAnimation.pause();\r\n window.cancelAnimationFrame(this.animationFrame);\r\n this.animations.forEach(animation => {\r\n if (animation.playState !== \"finished\") animation.pause();\r\n });\r\n this.emit(\"pause\");\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the total duration of all Animations\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getDuration(): number {\r\n return this.duration;\r\n }\r\n\r\n /**\r\n * Returns the current time of the Main Animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getCurrentTime(): number {\r\n return this.mainAnimation.currentTime;\r\n }\r\n\r\n /**\r\n * Set the current time of the Main Animation\r\n *\r\n * @param {number} time\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setCurrentTime(time: number): Animate {\r\n this.mainAnimation.currentTime = time;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = time;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Returns the Animation progress as a fraction of the current time / duration\r\n *\r\n * @returns\r\n * @memberof Animate\r\n */\r\n public getProgress() {\r\n return this.getCurrentTime() / this.duration;\r\n }\r\n\r\n /**\r\n * Set the Animation progress as a fraction of the current time / duration\r\n *\r\n * @param {number} percent\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setProgress(percent: number): Animate {\r\n this.mainAnimation.currentTime = percent * this.duration;\r\n this.animations.forEach(animation => {\r\n animation.currentTime = percent * this.duration;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Return the playback speed of the animation\r\n *\r\n * @returns {number}\r\n * @memberof Animate\r\n */\r\n public getSpeed(): number {\r\n return this.mainAnimation.playbackRate;\r\n }\r\n\r\n /**\r\n * Set the playback speed of an Animation\r\n *\r\n * @param {number} [speed=1]\r\n * @returns {Animate}\r\n * @memberof Animate\r\n */\r\n public setSpeed(speed: number = 1): Animate {\r\n this.mainAnimation.playbackRate = speed;\r\n this.animations.forEach(animation => {\r\n animation.playbackRate = speed;\r\n });\r\n return this;\r\n }\r\n\r\n /**\r\n * Reset all Animations\r\n *\r\n * @memberof Animate\r\n */\r\n public reset() {\r\n this.setCurrentTime(0);\r\n this.promise = this.newPromise();\r\n\r\n if (this.options.autoplay) this.play();\r\n else this.pause();\r\n }\r\n\r\n /**\r\n * Returns the current playing state\r\n *\r\n * @returns {(\"idle\" | \"running\" | \"paused\" | \"finished\")}\r\n * @memberof Animate\r\n */\r\n public getPlayState(): \"idle\" | \"running\" | \"paused\" | \"finished\" {\r\n return this.mainAnimation.playState;\r\n }\r\n\r\n /**\r\n * Get the options of an Animate instance\r\n *\r\n * @returns {AnimationOptions}\r\n * @memberof Animate\r\n */\r\n public getOptions(): AnimationOptions {\r\n return this.options;\r\n }\r\n\r\n // Returns the Animate options, as JSON\r\n public toJSON(): AnimationOptions {\r\n return this.getOptions();\r\n }\r\n}\r\n\r\n// Creates a new Animate instance\r\nexport const animate = (options: AnimationOptions = {}): Animate => {\r\n return new Animate(options);\r\n};\r\n\r\nexport default animate;\r\n"], + "mappings": "gIAAA,uoBCcO,IAAM,EAA2B,CACpC,YAAa,UACb,eAAgB,eAChB,eAAgB,cAChB,QAAS,CACL,CAAC,YAAa,SAElB,gBAAiB,iBACjB,eAAgB,gBAChB,eAAgB,aAChB,UAAW,QACX,QAAS,OAzBb,MAoDI,eACI,KAAK,OAAS,OAAO,OAAO,IAAK,GAAmB,GAWjD,WAA0C,IAC7C,IAAM,UAAW,KAAK,SACX,OAAO,EAAS,IAAM,EAAS,MAAM,IAChD,MAAO,GAAW,IAAI,KAAU,EAW7B,cAAkD,IACrD,GAAI,MAAO,IAAU,SACjB,MAAO,MAAK,OAEhB,MAA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ACH,MAAO,MAAK,iBAAmB,KAAK,SAUjC,eACH,YAAK,cAAc,YAAc,EAAU,KAAK,SAChD,KAAK,WAAW,QAAQ,IACpB,EAAU,YAAc,EAAU,KAAK,WAEpC,KASJ,WACH,MAAO,MAAK,cAAc,aAUvB,WAAyB,GAC5B,YAAK,cAAc,aAAe,EAClC,KAAK,WAAW,QAAQ,IACpB,EAAU,aAAe,IAEtB,KAQJ,QACH,KAAK,eAAe,GACpB,KAAK,QAAU,KAAK,aAEpB,AAAI,KAAK,QAAQ,SAAU,KAAK,OAC3B,KAAK,QASP,eACH,MAAO,MAAK,cAAc,UASvB,aACH,MAAO,MAAK,QAIT,SACH,MAAO,MAAK,kBAKG,GAA6B,KACzC,GAAI,GAAQ", "names": [] } diff --git a/packages/native/lib/types/api.d.ts b/packages/native/lib/types/api.d.ts new file mode 100644 index 0000000..c62c6c6 --- /dev/null +++ b/packages/native/lib/types/api.d.ts @@ -0,0 +1,12 @@ +export * from "./config"; +export * from "./manager"; +export * from "./url"; +export * from "./history"; +export * from "./page"; +export * from "./emitter"; +export * from "./service"; +export * from "./transition"; +export * from "./app"; +export * from "./pjax"; +export * from "./route"; +export * from "@okikio/animate"; diff --git a/packages/native/lib/types/app.d.ts b/packages/native/lib/types/app.d.ts new file mode 100644 index 0000000..1de2590 --- /dev/null +++ b/packages/native/lib/types/app.d.ts @@ -0,0 +1,163 @@ +import { EventEmitter, ListenerCallback, EventInput } from "./emitter"; +import { ITransition, TransitionManager } from "./transition"; +import { HistoryManager, IState } from "./history"; +import { ServiceManager, Service } from "./service"; +import { PageManager } from "./page"; +import { CONFIG, ICONFIG } from "./config"; +/** + * The App class starts the entire process, it controls all managers and all services + * + * @export + * @class App + */ +export declare class App { + /** + * A new instance of the HistoryManager + * + * @public + * @type HistoryManager + * @memberof App + */ + history: HistoryManager; + /** + * A new instance of the TransitionManager + * + * @public + * @type TransitionManager + * @memberof App + */ + transitions: TransitionManager; + /** + * A new instance of the ServiceManager + * + * @public + * @type ServiceManager + * @memberof App + */ + services: ServiceManager; + /** + * A new instance of an EventEmitter + * + * @public + * @type EventEmitter + * @memberof App + */ + emitter: EventEmitter; + /** + * A new instance of the PageManager + * + * @public + * @type PageManager + * @memberof App + */ + pages: PageManager; + /** + * The current Configuration's for the framework + * + * @public + * @type CONFIG + * @memberof App + */ + config: CONFIG; + /** + * Creates an instance of App. + * + * @param {(ICONFIG | CONFIG)} [config={}] + * @memberof App + */ + constructor(config?: object); + /** + * For registering all managers and the configurations + * + * @param {(ICONFIG | CONFIG)} [config={}] + * @returns App + * @memberof App + */ + register(config?: ICONFIG | CONFIG): App; + /** + * Based on the type, it will return either a Transition, a Service, or a State from their respective Managers + * + * @param {("service" | "transition" | "state" | string)} type + * @param {any} key + * @returns Service | Transition | State + * @memberof App + */ + get(type: "service" | "transition" | "state" | string, key: any): Service | ITransition | IState; + /** + * Based on the type, it will return load either Page a Transition, a Service, a State, or a Page from their respective Managers + * + * @param {("page" | string)} type + * @param {any} key + * @returns App + * @memberof App + */ + load(type: "page" | string, key: any): Promise; + /** + * Adds a Service to the App's instance of the ServiceManager, with a name + * + * @param {string} key + * @param {Service} service + * @returns App + * @memberof App + */ + setService(key: string, service: Service): App; + /** + * Adds a Service to the App's instance of the ServiceManager, with a name + * + * @param {string} key + * @param {ITransition} tranisition + * @returns App + * @memberof App + */ + setTransition(key: string, transition: ITransition): App; + /** + * Based on the type, it will add either a Transition, a Service, or a State to their respective Managers + * + * @param {("service" | "transition" | "state")} type + * @param {any} value + * @returns App + * @memberof App + */ + add(type: "service" | "transition" | "state", value: any): App; + /** + * Start the App and the ServiceManager + * + * @returns App + * @memberof App + */ + boot(): App; + /** + * Stop the App and the ServiceManager + * + * @returns App + * @memberof App + */ + stop(): App; + /** + * A shortcut to the App EventEmitter on method + * + * @param {EventInput} events + * @param {ListenerCallback} callback + * @returns App + * @memberof App + */ + on(events: EventInput, callback?: ListenerCallback): App; + /** + * A shortcut to the App EventEmitter off method + * + * @param {EventInput} events + * @param {ListenerCallback} callback + * @returns App + * @memberof App + */ + off(events: EventInput, callback?: ListenerCallback): App; + /** + * A shortcut to the App EventEmitter emit method + * + * @param {(string | any[])} events + * @param {...any} args + * @returns App + * @memberof App + */ + emit(events: string | any[], ...args: any): App; +} diff --git a/packages/native/lib/types/config.d.ts b/packages/native/lib/types/config.d.ts new file mode 100644 index 0000000..74637a9 --- /dev/null +++ b/packages/native/lib/types/config.d.ts @@ -0,0 +1,55 @@ +export interface ICONFIG { + prefix?: string; + wrapperAttr?: string; + noAjaxLinkAttr?: string; + noPrefetchAttr?: "no-prefetch"; + headers?: string[][]; + preventSelfAttr?: string; + preventAllAttr?: string; + transitionAttr?: string; + blockAttr?: string; + timeout?: number; +} +export declare const CONFIG_DEFAULTS: ICONFIG; +export declare type ConfigKeys = keyof ICONFIG; +/** + * The Config class + * + * @export + * @class CONFIG + */ +export declare class CONFIG { + /** + * The current Configuration + * + * @public + * @type ICONFIG + * @memberof CONFIG + */ + config: ICONFIG; + /** + * Creates an instance of CONFIG. + * + * @param {ICONFIG} config + * @memberof CONFIG + */ + constructor(config: ICONFIG); + /** + * Converts string into data attributes + * + * @param {string} value + * @param {boolean} brackets [brackets=true] + * @returns string + * @memberof CONFIG + */ + toAttr(value: string, brackets?: boolean): string; + /** + * Selects config vars, and formats them for use, or simply returns the current configurations for the framework + * + * @param {ConfigKeys} value + * @param {boolean} [brackets=true] + * @returns any + * @memberof CONFIG + */ + getConfig(value?: ConfigKeys, brackets?: boolean): any; +} diff --git a/packages/native/lib/types/emitter.d.ts b/packages/native/lib/types/emitter.d.ts new file mode 100644 index 0000000..f93b0bb --- /dev/null +++ b/packages/native/lib/types/emitter.d.ts @@ -0,0 +1 @@ +export * from "@okikio/emitter"; diff --git a/packages/native/lib/types/history.d.ts b/packages/native/lib/types/history.d.ts new file mode 100644 index 0000000..edfc0d7 --- /dev/null +++ b/packages/native/lib/types/history.d.ts @@ -0,0 +1,97 @@ +export declare type Trigger = HTMLAnchorElement | "HistoryManager" | "popstate" | "back" | "forward"; +export interface ICoords { + readonly x: number; + readonly y: number; +} +export interface IStateData { + scroll: ICoords; + [key: string]: any; +} +export interface IState { + url: string; + index?: number; + transition: string; + data: IStateData; +} +export interface IHistoryItem { + index: number; + states: IState[]; +} +/** + * A quick snapshot of page coordinates, e.g. scroll positions + * + * @export + * @param {number} [x=window.scrollX] + * @param {number} [y=window.scrollY] + */ +export declare const newCoords: (x?: number, y?: number) => ICoords; +/** + * Represents the current status of the page consisting of properties like: url, transition, and data + * + * @export + * @param {IState} { + * url = getHashedPath(newURL()), + * index = 0, + * transition = "default", + * data = { + * scroll: newCoords(), + * trigger: "HistoryManager" + * } + * } + * @memberof State +*/ +export declare const newState: (state?: IState) => IState; +/** + * History of the site, stores only the State class + * + * @export + * @class HistoryManager + * @extends {Manager} + */ +export declare class HistoryManager { + states: IState[]; + pointer: number; + /** + * Creates an instance of the HistoryManager class, which inherits properties and methods from the Storage class. + * + * @memberof HistoryManager + * @constructor + */ + constructor(); + get(index: number): IState; + /** + * Sets the index of the state before adding to HistoryManager + * + * @param {IState} value + * @returns HistoryManager + */ + add(value?: IState, historyAction?: "replace" | "push"): HistoryManager; + remove(index?: number): this; + replace(newStates: IState[]): this; + /** + * Set state by index. + */ + set(i: number, state: IState): IState; + /** + * Get the current state. + */ + get current(): IState; + /** + * Get the last state (top of the history stack). + */ + get last(): IState; + /** + * Get the previous state. + */ + get previous(): IState | null; + get length(): number; +} +/** + * Either push or replace history state + * + * @param {("push" | "replace")} action + * @param {IState} state + * @param {_URL} url + * @memberof PJAX + */ +export declare const changeState: (action: "push" | "replace", state: IState, item: object) => void; diff --git a/packages/native/lib/types/manager.d.ts b/packages/native/lib/types/manager.d.ts new file mode 100644 index 0000000..03d58a2 --- /dev/null +++ b/packages/native/lib/types/manager.d.ts @@ -0,0 +1,113 @@ +import { Manager, methodCall, asyncMethodCall } from "@okikio/manager"; +import { CONFIG } from "./config"; +import { App } from "./app"; +import EventEmitter from "@okikio/emitter"; +export declare type IAdvancedManager = AdvancedManager; +/** + * The base class for all AdvancedManager and AdvancedStorage items + * + * @export + * @class ManagerItem + */ +export declare class ManagerItem { + /** + * The AdvancedManager the ManagerItem is attached to + * + * @public + * @type IAdvancedManager + * @memberof ManagerItem + */ + manager: IAdvancedManager; + /** + * The App the ManagerItem is attached to + * + * @public + * @type App + * @memberof ManagerItem + */ + app: App; + /** + * The Config class of the App the ManagerItem is attached to + * + * @public + * @type CONFIG + * @memberof ManagerItem + */ + config: CONFIG; + emitter: EventEmitter; + key: any; + /** + * Creates an instance of ManagerItem. + * + * @memberof ManagerItem + */ + constructor(); + /** + * Run after the Manager Item has been registered + * + * @returns any + * @memberof ManagerItem + */ + install(): any; + /** + * Register the current Manager Item's manager + * + * @param {IAdvancedManager} manager + * @returns ManagerItem + * @memberof ManagerItem + */ + register(manager: IAdvancedManager, key: any): ManagerItem; + uninstall(): any; + unregister(): void; +} +/** + * A tweak to the Manager class that makes it self aware of the App class it's instantiated in + * + * @export + * @class AdvancedManager + * @extends {Manager} + * @template K + * @template V + */ +export declare class AdvancedManager extends Manager { + /** + * The instance of the App class, the Manager is instantiated in + * + * @type App + * @memberof AdvancedManager + */ + app: App; + /** + * The Config class of the App the AdvancedManager is attached to + * + * @public + * @type CONFIG + * @memberof AdvancedManager + */ + config: CONFIG; + /** + * The EventEmitter class of the App the AdvancedManager is attached to + * + * @public + * @type EventEmitter + * @memberof AdvancedManager + */ + emitter: EventEmitter; + /** + * Creates an instance of AdvancedManager. + * + * @param {App} app - The instance of the App class, the Manager is instantiated in + * @memberof AdvancedManager + */ + constructor(app: App); + /** + * Set a value stored in the Manager + * + * @public + * @param {K} key - The key where the value will be stored + * @param {V} value - The value to store + * @returns AdvancedManager + */ + set(key: K, value: V): this; +} +export { Manager, methodCall, asyncMethodCall }; diff --git a/packages/native/lib/types/page.d.ts b/packages/native/lib/types/page.d.ts new file mode 100644 index 0000000..6bdded0 --- /dev/null +++ b/packages/native/lib/types/page.d.ts @@ -0,0 +1,122 @@ +import { Manager, ManagerItem, AdvancedManager } from "./manager"; +import { App } from "./app"; +/** + * Parses strings to DOM + */ +export declare const PARSER: DOMParser; +/** + * A page represents the DOM elements that create each page + * + * @export + * @class Page + */ +export declare class Page extends ManagerItem { + /** + * Holds the DOM of the current page + * + * @public + * @type Document + * @memberof Page + */ + dom: Document; + /** + * Holds the wrapper element to be swapped out of each Page + * + * @public + * @type HTMLElement + * @memberof Page + */ + wrapper: HTMLElement; + /** + * Holds the title of each page + * + * @public + * @type string + * @memberof Page + */ + title: string; + /** + * Holds the head element of each page + * + * @public + * @type Element + * @memberof Page + */ + head: Element; + /** + * Holds the body element of each page + * + * @public + * @type Element + * @memberof Page + */ + body: Element; + /** + * The URL of the current page + * + * @public + * @type URL + * @memberof Page + */ + url: URL; + data: string; + wrapperAttr: string; + /** + * Creates an instance of Page, it also creates a new page from response text, or a Document Object + * + * @param {URL} [url = newURL()] + * @param {(string | Document)} [dom=document] + * @memberof Page + */ + constructor(url?: URL, dom?: string | Document); + build(): Promise; + /** + * Runs once the the manager and config have been registered + * + * @returns void + * @memberof Page + */ + install(): void; + uninstall(): void; +} +/** + * Controls which page to be load + * + * @export + * @class PageManager + * @extends {AdvancedManager} + */ +export declare class PageManager extends AdvancedManager { + /** + * Stores all URLs that are currently loading + * + * @public + * @type Manager> + * @memberof PageManager + */ + loading: Manager>; + maxPages: number; + /** + * Creates an instance of the PageManager + * + * @param {App} app + * @memberof PageManager + */ + constructor(app: App); + /** + * 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" + * + * @param {(URL | string)} [_url=newURL()] + * @returns Promise + * @memberof PageManager + */ + load(_url?: URL | string): Promise; + /** + * Starts a fetch request + * + * @param {string} url + * @returns Promise + * @memberof PageManager + */ + request(url: string): Promise; +} diff --git a/packages/native/lib/types/pjax.d.ts b/packages/native/lib/types/pjax.d.ts new file mode 100644 index 0000000..d90f3c7 --- /dev/null +++ b/packages/native/lib/types/pjax.d.ts @@ -0,0 +1,240 @@ +import { Trigger } from "./history"; +import { Service } from "./service"; +export declare type LinkEvent = MouseEvent | TouchEvent; +export declare type StateEvent = LinkEvent | PopStateEvent; +export declare type IgnoreURLsList = Array; +/** + * Creates a Barba JS like PJAX Service, for the Framework + * + * @export + * @class PJAX + * @extends {Service} + */ +export declare class PJAX extends Service { + /** + * URLs to ignore when prefetching + * + * @private + * @type boolean + * @memberof PJAX + */ + protected ignoreURLs: IgnoreURLsList; + /** + * Whether or not to disable prefetching + * + * @private + * + * @memberof PJAX + */ + protected prefetchIgnore: boolean; + /** + * Current state or transitions + * + * @public + * @type boolean + * @memberof PJAX + */ + isTransitioning: boolean; + /** + * Ignore extra clicks of an anchor element if a transition has already started + * + * @private + * @type boolean + * @memberof PJAX + */ + protected stopOnTransitioning: boolean; + /** + * On page change (excluding popstate event) keep current scroll position + * + * @private + * @type boolean + * @memberof PJAX + */ + protected stickyScroll: boolean; + /** + * Force load a page if an error occurs + * + * @private + * @type boolean + * @memberof PJAX + */ + protected forceOnError: boolean; + /** + * Dictates whether to auto scroll if an hash is present in the window URL + * + * @protected + * @type boolean + * @memberof PJAX + */ + protected autoScrollOnHash: boolean; + /** + * Disables all extra scroll effects of PJAX + * + * @private + * @type boolean + * @memberof PJAX + */ + protected dontScroll: boolean; + /** + * Sets the transition state, sets isTransitioning to true + * + * @private + * @memberof PJAX + */ + private transitionStart; + /** + * Sets the transition state, sets isTransitioning to false + * + * @private + * @memberof PJAX + */ + private transitionStop; + init(): void; + /** + * Starts the PJAX Service + * + * @memberof PJAX + */ + boot(): void; + /** + * Gets the transition to use for a certain anchor + * + * @param {HTMLAnchorElement} el + * @returns {(string | null)} + * @memberof PJAX + */ + getTransitionName(el: HTMLAnchorElement): string | null; + /** + * Checks to see if the anchor is valid + * + * @param {HTMLAnchorElement} el + * @param {(LinkEvent | KeyboardEvent)} event + * @param {string} href + * + * @memberof PJAX + */ + validLink(el: HTMLAnchorElement, event: LinkEvent | KeyboardEvent, href: string): boolean; + /** + * Returns the href or an Anchor element + * + * @param {HTMLAnchorElement} el + * @returns {(string | null)} + * @memberof PJAX + */ + getHref(el: HTMLAnchorElement): string | null; + /** + * Check if event target is a valid anchor with an href, if so, return the link + * + * @param {LinkEvent} event + * + * @memberof PJAX + */ + getLink(event: LinkEvent): HTMLAnchorElement; + /** + * When an element is clicked. + * + * Get valid anchor element. + * Go for a transition. + * + * @param {LinkEvent} event + * @returns + * @memberof PJAX + */ + onClick(event: LinkEvent): void; + /** + * Returns the direction of the State change as a String, either the Back button or the Forward button + * + * @param {number} value + * + * @memberof PJAX + */ + getDirection(value: number): Trigger; + /** + * Force a page to go to a certain URL + * + * @param {string} href + * @memberof PJAX + */ + force(href: string): void; + /** + * If transition is running force load page. + * Stop if currentURL is the same as new url. + * On state change, change the current state history, + * to reflect the direction of said state change + * Load page and page transition. + * + * @param {string} href + * @param {Trigger} [trigger='HistoryManager'] + * @param {StateEvent} [event] + * @memberof PJAX + */ + go({ href, trigger, event, }: { + href: string; + trigger?: Trigger; + event?: StateEvent; + }): Promise; + /** + * Load the new Page as well as a Transition; run the Transition + * + * @param {string} oldHref + * @param {string} href + * @param {Trigger} trigger + * @param {string} [transitionName="default"] + * + * @memberof PJAX + */ + load({ oldHref, href, trigger, transitionName, scroll, }: { + oldHref: string; + href: string; + trigger: Trigger; + transitionName?: string; + scroll: { + x: number; + y: number; + }; + }): Promise; + /** + * Check to see if the URL is to be ignored, uses either RegExp of Strings to check + * + * @param {URL} { pathname } + * + * @memberof PJAX + */ + ignoredURL({ pathname }: URL): boolean; + /** + * When you hover over an anchor, prefetch the event target's href + * + * @param {LinkEvent} event + * @memberof PJAX + */ + onHover(event: LinkEvent): Promise; + /** + * When History state changes. + * + * Get url from State + * Go for a Barba transition. + * + * @param {PopStateEvent} event + * @memberof PJAX + */ + onStateChange(event: PopStateEvent): void; + /** + * Initialize DOM Events + * + * @memberof PJAX + */ + initEvents(): void; + /** + * Stop DOM Events + * + * @memberof PJAX + */ + stopEvents(): void; +} +/** + * Auto scrolls to an elements position if the element has an hash + * + * @param {string} [hash=window.location.hash] + * @memberof PJAX + */ +export declare const hashAction: (hash?: string) => import("./history").ICoords; diff --git a/packages/native/lib/types/route.d.ts b/packages/native/lib/types/route.d.ts new file mode 100644 index 0000000..4bb7dc4 --- /dev/null +++ b/packages/native/lib/types/route.d.ts @@ -0,0 +1,87 @@ +import { Service } from "./service"; +import { Manager } from "./manager"; +export declare type RouteMethod = (...args: any) => any; +export declare type RouteStyle = string | RegExp | boolean; +export interface IRouteToFrom { + to: RouteStyle; + from: RouteStyle; +} +export declare type RoutePath = IRouteToFrom | RouteStyle; +export interface IRoute { + path: RoutePath; + method: RouteMethod; +} +/** + * Controls what happens when certain url paths match a set of criteria + * + * @export + * @class Router + * @extends {Service} + */ +export declare class Router extends Service { + /** + * List of routes inputted + * + * @protected + * @type {Manager} + * @memberof Router + */ + protected routes: Manager; + /** + * Creates an instance of Router. + * + * @param {Array} [routes=[]] + * @memberof Router + */ + constructor(routes?: IRoute[]); + /** + * Add a new route to watch for + * + * @param {IRoute} { path, method } + * @returns {Router} + * @memberof Router + */ + add({ path, method }: IRoute): Router; + /** + * Convert strings into path match functions + * + * @param {RouteStyle} path + * @returns {RegExp | boolean} + * @memberof Router + */ + parsePath(path: RouteStyle): RegExp | boolean; + /** + * Determines if a strings counts has a path + * + * @param {RouteStyle} input + * @returns boolean + * @memberof Router + */ + isPath(input: RouteStyle): boolean; + /** + * Parse the multiple different formats for paths, into a { from, to } object + * + * @param {RouteStyle} input + * @returns {IRouteToFrom} + * @memberof Router + */ + parse(input: RoutePath): IRouteToFrom; + /** + * Test if route paths are true, if so run their methods + * + * @memberof Router + */ + route(): void; + /** + * Add listeners for PJAX Events + * + * @memberof Router + */ + initEvents(): void; + /** + * Remove listeners for PJAX Events + * + * @memberof Router + */ + stopEvents(): void; +} diff --git a/packages/native/lib/types/service.d.ts b/packages/native/lib/types/service.d.ts new file mode 100644 index 0000000..44f4764 --- /dev/null +++ b/packages/native/lib/types/service.d.ts @@ -0,0 +1,103 @@ +import { AdvancedManager, ManagerItem } from "./manager"; +import { TransitionManager } from "./transition"; +import { HistoryManager } from "./history"; +import { EventEmitter } from "./emitter"; +import { PageManager } from "./page"; +import { App } from "./app"; +/** + * Controls specific kinds of actions that require JS + * + * @export + * @class Service + */ +export declare class Service extends ManagerItem { + /** + * Stores access to the App class's EventEmitter + * + * @public + * @type EventEmitter + * @memberof Service + */ + emitter: EventEmitter; + /** + * Stores access to the App class's PageManager + * + * @public + * @type PageManager + * @memberof Service + */ + PageManager: PageManager; + /** + * Stores access to the App class's HistoryManager + * + * @public + * @type HistoryManager + * @memberof Service + */ + HistoryManager: HistoryManager; + /** + * Stores the ServiceManager the service is install on + * + * @public + * @type ServiceManager + * @memberof Service + */ + ServiceManager: ServiceManager; + /** + * Stores access to the App's TransitionManager + * + * @public + * @type TransitionManager + * @memberof Service + */ + TransitionManager: TransitionManager; + /** + * Method is run once when Service is installed on a ServiceManager + * + * @memberof Service + */ + install(): void; + init(...args: any): void; + boot(): void; + initEvents(): void; + stopEvents(): void; + uninstall(): void; + stop(): void; +} +/** + * The Service Manager controls the lifecycle of all services in an App + * + * @export + * @class ServiceManager + * @extends {AdvancedManager} + */ +export declare class ServiceManager extends AdvancedManager { + /** + * Creates an instance of ServiceManager. + * + * @param {App} app + * @memberof ServiceManager + */ + constructor(app: App); + /** + * Call the init method for all Services + * + * @returns ServiceManager + * @memberof ServiceManager + */ + init(): ServiceManager; + /** + * Call the boot method for all Services + * + * @returns ServiceManager + * @memberof ServiceManager + */ + boot(): ServiceManager; + /** + * Call the stop method for all Services + * + * @returns ServiceManager + * @memberof ServiceManager + */ + stop(): ServiceManager; +} diff --git a/packages/native/lib/types/transition.d.ts b/packages/native/lib/types/transition.d.ts new file mode 100644 index 0000000..599e620 --- /dev/null +++ b/packages/native/lib/types/transition.d.ts @@ -0,0 +1,77 @@ +import { Manager } from "./manager"; +import { EventEmitter } from "./emitter"; +import { ICoords, Trigger } from "./history"; +import { Page } from "./page"; +import { App } from "./app"; +import { CONFIG } from "./config"; +/** + * The async function type, allows for smooth transition between Promises + */ +export declare type asyncFn = (err?: any, value?: any) => void; +export interface ITransition { + oldPage?: Page; + newPage?: Page; + trigger?: Trigger; + scroll?: { + x: number; + y: number; + }; + scrollable?: boolean; + in: (data: ITransitionData) => any; + out: (data: ITransitionData) => any; + [key: string]: any; +} +export interface ITransitionData { + from?: Page; + to?: Page; + trigger?: Trigger; + scroll?: ICoords; + done: asyncFn; +} +/** + * Controls which animation between pages to use + * + * @export + * @class TransitionManager + * @extends {Manager} + */ +export declare class TransitionManager extends Manager { + /** + * The instance of the App class, the Manager is instantiated in + * + * @type App + * @memberof AdvancedManager + */ + app: App; + /** + * The Config class of the App the AdvancedManager is attached to + * + * @public + * @type CONFIG + * @memberof AdvancedManager + */ + config: CONFIG; + /** + * The EventEmitter class of the App the AdvancedManager is attached to + * + * @public + * @type EventEmitter + * @memberof AdvancedManager + */ + emitter: EventEmitter; + /** + * Creates an instance of the TransitionManager + * + * @param {App} app + * @memberof TransitionManager + */ + constructor(app: App); + /** + * Runs a transition + * + * @param {{ name: string, oldPage: Page, newPage: Page, trigger: Trigger }} data + * @returns Promise + * @memberof TransitionManager + */ + boot(name: string, data: any): Promise; +} diff --git a/packages/native/lib/types/url.d.ts b/packages/native/lib/types/url.d.ts new file mode 100644 index 0000000..effa346 --- /dev/null +++ b/packages/native/lib/types/url.d.ts @@ -0,0 +1,45 @@ +/** + * Adds new methods to the native URL Object; it seemed cleaner than using a custom method or editing the prototype. + * + * This doesn't extend the **Class** object because it's meant to be a small extension of the native URL class. + * + * @export + * @class URL + * @extends {URL} + */ +/** + * Creates an instance of URL. + * + * @param {(string | URL | Location)} [url=window.location.pathname] + * @return URL + */ +export declare const newURL: (url?: string | URL | Location) => URL; +/** + * Returns the pathname with the hash + * + * @param {URL} url + * @returns string + */ +export declare const getHashedPath: (url: URL) => string; +/** + * Returns the actual hash without the hashtag + * + * @param {URL} url + * @returns string + */ +export declare const getHash: (url: URL) => string; +/** + * Removes the hash from the full URL for a clean URL string + * + * @param {URL} url + * @returns string + */ +export declare const clean: (url: URL) => string; +/** + * Compares two URLs to each other + * + * @param {URL} a + * @param {URL} b + * @returns boolean + */ +export declare const equal: (a: URL | string, b: URL | string) => boolean; diff --git a/packages/native/package.json b/packages/native/package.json index ce717a2..5c091bd 100644 --- a/packages/native/package.json +++ b/packages/native/package.json @@ -5,10 +5,12 @@ "publishConfig": { "access": "public", "main": "lib/api.js", + "types": "lib/types/api.d.ts", "browser": "lib/api.js", "node": "lib/api.node.js", "unpkg": "lib/api.js", - "module": "lib/api.modern.js" + "module": "lib/api.modern.js", + "exports": "./lib/api.modern.js" }, "main": "src/api.ts", "source": "src/api.ts", @@ -22,9 +24,8 @@ "scripts": { "build": "node ./build", "watch": "node ./build --watch", - "test": "jest --maxWorkers=1", - "test:watch": "jest --maxWorkers=1 --watch --verbose false", - "pre-release": "npm run build && ultra docs:build", + "dts": "tsc --project dts.tsconfig.json", + "pre-release": "npm run build && npm run dts && npm run docs:build", "docs:build": "gulp build", "docs:watch": "gulp default --watch" }, @@ -51,9 +52,9 @@ }, "homepage": "https://github.com/okikio/native#readme", "devDependencies": { - "@types/jest": "^26.0.16", + "@types/jest": "^26.0.18", "browser-sync": "^2.26.13", - "esbuild": "^0.8.20", + "esbuild": "^0.8.21", "esbuild-jest": "^0.3.0", "eslint": "^7.15.0", "gulp": "^4.0.2", @@ -61,6 +62,7 @@ "jest": "^26.6.3", "jest-chain": "^1.1.5", "merge-stream": "^2.0.0", + "typescript": "^4.1.2", "ultra-runner": "^3.6.0" }, "dependencies": { diff --git a/packages/native/src/transition.ts b/packages/native/src/transition.ts index b1f514b..397cef7 100644 --- a/packages/native/src/transition.ts +++ b/packages/native/src/transition.ts @@ -115,7 +115,7 @@ export class TransitionManager extends Manager { }); this.emitter.emit("AFTER_TRANSITION_OUT"); - await new Promise((done) => { + await new Promise((done) => { fromWrapper.insertAdjacentElement("beforebegin", toWrapper); this.emitter.emit("CONTENT_INSERT"); @@ -125,7 +125,7 @@ export class TransitionManager extends Manager { done(); }); - await new Promise((done) => { + await new Promise((done) => { fromWrapper.remove(); fromWrapper = undefined; toWrapper = undefined; @@ -135,7 +135,7 @@ export class TransitionManager extends Manager { this.emitter.emit("BEFORE_TRANSITION_IN"); - await new Promise((done) => { + await new Promise(async (done) => { let inMethod: Promise = transition.in.call(transition, { ...data, from: data.oldPage, diff --git a/packages/native/tests/test.ts b/packages/native/tests/test.ts deleted file mode 100644 index 2856fee..0000000 --- a/packages/native/tests/test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// -import { Manager } from "../src/api"; -import "jest-chain"; - -/* - Find: @(returns|type) \{([\w_-{,<[\]\s>]+)\} - Replace: @$1 $2 -*/ - -describe("Native", () => { - let arr = [1, 2, 3, 4, 5]; - let entries = Array.from(arr.entries()); - let manager: Manager; - - beforeEach(() => { - manager = new Manager(entries); - }); - - describe("#get()", () => { - test("get index 2 which is expected to be 3", () => { - expect(manager.get(2)).toEqual(3); - }); - }); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a9d8ad7..4cb2298 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,23 +3,24 @@ importers: devDependencies: '@commitlint/cli': 11.0.0 '@commitlint/config-conventional': 11.0.0 - '@types/jest': 26.0.16 + '@types/jest': 26.0.18 browser-sync: 2.26.13 - esbuild: 0.8.20 - esbuild-jest: 0.3.0_esbuild@0.8.20 + esbuild: 0.8.21 + esbuild-jest: 0.3.0_esbuild@0.8.21 gulp: 4.0.2 jest: 26.6.3 jest-chain: 1.1.5 lerna: 3.22.1 merge-stream: 2.0.0 pnpm: 5.13.5 + typescript: 4.1.2 ultra-runner: 3.6.0 specifiers: '@commitlint/cli': ^11.0.0 '@commitlint/config-conventional': ^11.0.0 - '@types/jest': ^26.0.16 + '@types/jest': ^26.0.18 browser-sync: ^2.26.13 - esbuild: ^0.8.20 + esbuild: ^0.8.21 esbuild-jest: ^0.3.0 gulp: ^4.0.2 jest: ^26.6.3 @@ -27,81 +28,88 @@ importers: lerna: ^3.22.1 merge-stream: ^2.0.0 pnpm: ^5.13.5 + typescript: ^4.1.2 ultra-runner: ^3.6.0 packages/animate: dependencies: '@okikio/emitter': 'link:../emitter' devDependencies: - '@types/jest': 26.0.16 + '@types/jest': 26.0.18 browser-sync: 2.26.13 - esbuild: 0.8.20 - esbuild-jest: 0.3.0_esbuild@0.8.20 + esbuild: 0.8.21 + esbuild-jest: 0.3.0_esbuild@0.8.21 eslint: 7.15.0 gulp: 4.0.2 - gulp-esbuild: 0.3.2 + gulp-esbuild: 0.3.4 gulp-pug: 4.0.1 gulp-sass: 4.1.0 jest: 26.6.3 jest-chain: 1.1.5 merge-stream: 2.0.0 + typescript: 4.1.2 ultra-runner: 3.6.0 specifiers: '@okikio/emitter': 'workspace:^0.0.7' - '@types/jest': ^26.0.16 + '@types/jest': ^26.0.18 browser-sync: ^2.26.13 - esbuild: ^0.8.20 + esbuild: ^0.8.21 esbuild-jest: ^0.3.0 eslint: ^7.15.0 gulp: ^4.0.2 - gulp-esbuild: ^0.3.2 + gulp-esbuild: ^0.3.4 gulp-pug: ^4.0.1 gulp-sass: ^4.1.0 jest: ^26.6.3 jest-chain: ^1.1.5 merge-stream: ^2.0.0 + typescript: ^4.1.2 ultra-runner: ^3.6.0 packages/emitter: dependencies: '@okikio/manager': 'link:../manager' devDependencies: - '@types/jest': 26.0.16 + '@types/jest': 26.0.18 chokidar: 3.4.3 - esbuild: 0.8.20 - esbuild-jest: 0.3.0_esbuild@0.8.20 + esbuild: 0.8.21 + esbuild-jest: 0.3.0_esbuild@0.8.21 eslint: 7.15.0 jest: 26.6.3 jest-chain: 1.1.5 + typescript: 4.1.2 ultra-runner: 3.6.0 specifiers: '@okikio/manager': 'workspace:^0.0.7' - '@types/jest': ^26.0.16 + '@types/jest': ^26.0.18 chokidar: ^3.4.3 - esbuild: ^0.8.20 + esbuild: ^0.8.21 esbuild-jest: ^0.3.0 eslint: ^7.15.0 jest: ^26.6.3 jest-chain: ^1.1.5 + typescript: ^4.1.2 ultra-runner: ^3.6.0 packages/manager: devDependencies: - '@types/jest': 26.0.16 + '@types/jest': 26.0.18 chokidar: 3.4.3 - esbuild: 0.8.20 - esbuild-jest: 0.3.0_esbuild@0.8.20 + esbuild: 0.8.21 + esbuild-jest: 0.3.0_esbuild@0.8.21 eslint: 7.15.0 jest: 26.6.3 jest-chain: 1.1.5 node-fetch: 2.6.1 + typescript: 4.1.2 ultra-runner: 3.6.0 specifiers: - '@types/jest': ^26.0.16 + '@types/jest': ^26.0.18 chokidar: ^3.4.3 - esbuild: ^0.8.20 + esbuild: ^0.8.21 esbuild-jest: ^0.3.0 eslint: ^7.15.0 jest: ^26.6.3 jest-chain: ^1.1.5 node-fetch: ^2.6.1 + typescript: ^4.1.2 ultra-runner: ^3.6.0 packages/native: dependencies: @@ -109,24 +117,25 @@ importers: '@okikio/emitter': 'link:../emitter' '@okikio/manager': 'link:../manager' devDependencies: - '@types/jest': 26.0.16 + '@types/jest': 26.0.18 browser-sync: 2.26.13 - esbuild: 0.8.20 - esbuild-jest: 0.3.0_esbuild@0.8.20 + esbuild: 0.8.21 + esbuild-jest: 0.3.0_esbuild@0.8.21 eslint: 7.15.0 gulp: 4.0.2 gulp-sass: 4.1.0 jest: 26.6.3 jest-chain: 1.1.5 merge-stream: 2.0.0 + typescript: 4.1.2 ultra-runner: 3.6.0 specifiers: '@okikio/animate': 'workspace:^0.0.7' '@okikio/emitter': 'workspace:^0.0.7' '@okikio/manager': 'workspace:^0.0.7' - '@types/jest': ^26.0.16 + '@types/jest': ^26.0.18 browser-sync: ^2.26.13 - esbuild: ^0.8.20 + esbuild: ^0.8.21 esbuild-jest: ^0.3.0 eslint: ^7.15.0 gulp: ^4.0.2 @@ -134,6 +143,7 @@ importers: jest: ^26.6.3 jest-chain: ^1.1.5 merge-stream: ^2.0.0 + typescript: ^4.1.2 ultra-runner: ^3.6.0 lockfileVersion: 5.2 packages: @@ -143,60 +153,59 @@ packages: dev: true resolution: integrity: sha512-vG6SvB6oYEhvgisZNFRmRCUkLz11c7rp+tbNTynGqc6mS1d5ATd/sGyV6W0KZZnXRKMTzZDRgQT3Ou9jhpAfUg== - /@babel/core/7.12.9: + /@babel/core/7.12.10: dependencies: '@babel/code-frame': 7.10.4 - '@babel/generator': 7.12.5 + '@babel/generator': 7.12.10 '@babel/helper-module-transforms': 7.12.1 '@babel/helpers': 7.12.5 - '@babel/parser': 7.12.7 + '@babel/parser': 7.12.10 '@babel/template': 7.12.7 - '@babel/traverse': 7.12.9 - '@babel/types': 7.12.7 + '@babel/traverse': 7.12.10 + '@babel/types': 7.12.10 convert-source-map: 1.7.0 debug: 4.3.1 gensync: 1.0.0-beta.2 json5: 2.1.3 lodash: 4.17.20 - resolve: 1.19.0 semver: 5.7.1 source-map: 0.5.7 dev: true engines: node: '>=6.9.0' resolution: - integrity: sha512-gTXYh3M5wb7FRXQy+FErKFAv90BnlOuNn1QkCK2lREoPAjrQCO49+HVSrFoe5uakFAF5eenS75KbO2vQiLrTMQ== - /@babel/generator/7.12.5: + integrity: sha512-eTAlQKq65zHfkHZV0sIVODCPGVgoo1HdBlbSLi9CqOzuZanMv2ihzY+4paiKr1mH+XmYESMAmJ/dpZ68eN6d8w== + /@babel/generator/7.12.10: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 jsesc: 2.5.2 source-map: 0.5.7 dev: true resolution: - integrity: sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A== + integrity: sha512-6mCdfhWgmqLdtTkhXjnIz0LcdVCd26wS2JXRtj2XY0u5klDsXBREA/pG5NVOuVnF2LUrBGNFtQkIqqTbblg0ww== /@babel/helper-function-name/7.10.4: dependencies: - '@babel/helper-get-function-arity': 7.10.4 + '@babel/helper-get-function-arity': 7.12.10 '@babel/template': 7.12.7 - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-YdaSyz1n8gY44EmN7x44zBn9zQ1Ry2Y+3GTA+3vH6Mizke1Vw0aWDM66FOYEPw8//qKkmqOckrGgTYa+6sceqQ== - /@babel/helper-get-function-arity/7.10.4: + /@babel/helper-get-function-arity/7.12.10: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: - integrity: sha512-EkN3YDB+SRDgiIUnNgcmiD361ti+AVbL3f3Henf6dqqUyr5dMsorno0lJWJuLhDhkI5sYEpgj6y9kB8AOU1I2A== + integrity: sha512-mm0n5BPjR06wh9mPQaDdXWDoll/j5UpCAPl1x8fS71GHm7HA6Ua2V4ylG1Ju8lvcTOietbPNNPaSilKj+pj+Ag== /@babel/helper-member-expression-to-functions/7.12.7: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-DCsuPyeWxeHgh1Dus7APn7iza42i/qXqiFPWyBDdOFtvS581JQePsc1F/nD+fHrcswhLlRc2UpYS1NwERxZhHw== /@babel/helper-module-imports/7.12.5: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-SR713Ogqg6++uexFRORf/+nPXMmWIn80TALu0uaFb+iQIUoR7bOC7zBWyzBs5b3tBBJXuyD0cRu1F15GyzjOWA== @@ -208,18 +217,18 @@ packages: '@babel/helper-split-export-declaration': 7.11.0 '@babel/helper-validator-identifier': 7.10.4 '@babel/template': 7.12.7 - '@babel/traverse': 7.12.9 - '@babel/types': 7.12.7 + '@babel/traverse': 7.12.10 + '@babel/types': 7.12.10 lodash: 4.17.20 dev: true resolution: integrity: sha512-QQzehgFAZ2bbISiCpmVGfiGux8YVFXQ0abBic2Envhej22DVXV9nCFaS5hIQbkyo1AdGb+gNME2TSh3hYJVV/w== - /@babel/helper-optimise-call-expression/7.12.7: + /@babel/helper-optimise-call-expression/7.12.10: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: - integrity: sha512-I5xc9oSJ2h59OwyUqjv95HRyzxj53DAubUERgQMrpcCEYQyToeHA+NEcUEsVWB4j53RDeskeBJ0SgRAYHDBckw== + integrity: sha512-4tpbU0SrSTjjt65UMWSrUOPZTsgvPgGG4S8QSTNHacKzpS51IVWGDj0yCwyeZND/i+LSN2g/O63jEXEWm49sYQ== /@babel/helper-plugin-utils/7.10.4: dev: true resolution: @@ -227,21 +236,21 @@ packages: /@babel/helper-replace-supers/7.12.5: dependencies: '@babel/helper-member-expression-to-functions': 7.12.7 - '@babel/helper-optimise-call-expression': 7.12.7 - '@babel/traverse': 7.12.9 - '@babel/types': 7.12.7 + '@babel/helper-optimise-call-expression': 7.12.10 + '@babel/traverse': 7.12.10 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-5YILoed0ZyIpF4gKcpZitEnXEJ9UoDRki1Ey6xz46rxOzfNMAhVIJMoune1hmPVxh40LRv1+oafz7UsWX+vyWA== /@babel/helper-simple-access/7.12.1: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-OxBp7pMrjVewSSC8fXDFrHrBcJATOOFssZwv16F3/6Xtc138GHybBfPbm9kfiqQHKhYQrlamWILwlDCeyMFEaA== /@babel/helper-split-export-declaration/7.11.0: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-74Vejvp6mHkGE+m+k5vHY93FX2cAtrw1zXrZXRlG4l410Nm9PxfEiVTn1PjDPV5SnmieiueY4AFg2xqhNFuuZg== @@ -252,8 +261,8 @@ packages: /@babel/helpers/7.12.5: dependencies: '@babel/template': 7.12.7 - '@babel/traverse': 7.12.9 - '@babel/types': 7.12.7 + '@babel/traverse': 7.12.10 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-lgKGMQlKqA8meJqKsW6rUnc4MdUk35Ln0ATDqdM1a/UpARODdI4j5Y5lVfUScnSNkJcdCRAaWkspykNoFg9sJA== @@ -265,115 +274,115 @@ packages: dev: true resolution: integrity: sha512-i6rgnR/YgPEQzZZnbTHHuZdlE8qyoBNalD6F+q4vAFlcMEcqmkoG+mPqJYJCo63qPf74+Y1UZsl3l6f7/RIkmA== - /@babel/parser/7.12.7: + /@babel/parser/7.12.10: dev: true engines: node: '>=6.0.0' hasBin: true resolution: - integrity: sha512-oWR02Ubp4xTLCAqPRiNIuMVgNO5Aif/xpXtabhzW2HWUD47XJsAB4Zd/Rg30+XeQA3juXigV7hlquOTmwqLiwg== - /@babel/plugin-syntax-async-generators/7.8.4_@babel+core@7.12.9: + integrity: sha512-PJdRPwyoOqFAWfLytxrWwGrAxghCgh/yTNCYciOz8QgjflA7aZhECPZAa2VUedKg2+QMWkI0L9lynh2SNmNEgA== + /@babel/plugin-syntax-async-generators/7.8.4_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw== - /@babel/plugin-syntax-bigint/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-bigint/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg== - /@babel/plugin-syntax-class-properties/7.12.1_@babel+core@7.12.9: + /@babel/plugin-syntax-class-properties/7.12.1_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-U40A76x5gTwmESz+qiqssqmeEsKvcSyvtgktrm0uzcARAmM9I1jR221f6Oq+GmHrcD+LvZDag1UTOTe2fL3TeA== - /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.12.9: + /@babel/plugin-syntax-import-meta/7.10.4_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g== - /@babel/plugin-syntax-json-strings/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-json-strings/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA== - /@babel/plugin-syntax-logical-assignment-operators/7.10.4_@babel+core@7.12.9: + /@babel/plugin-syntax-logical-assignment-operators/7.10.4_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig== - /@babel/plugin-syntax-nullish-coalescing-operator/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-nullish-coalescing-operator/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ== - /@babel/plugin-syntax-numeric-separator/7.10.4_@babel+core@7.12.9: + /@babel/plugin-syntax-numeric-separator/7.10.4_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug== - /@babel/plugin-syntax-object-rest-spread/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-object-rest-spread/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA== - /@babel/plugin-syntax-optional-catch-binding/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-optional-catch-binding/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q== - /@babel/plugin-syntax-optional-chaining/7.8.3_@babel+core@7.12.9: + /@babel/plugin-syntax-optional-chaining/7.8.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: '@babel/core': ^7.0.0-0 resolution: integrity: sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg== - /@babel/plugin-syntax-top-level-await/7.12.1_@babel+core@7.12.9: + /@babel/plugin-syntax-top-level-await/7.12.1_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@babel/helper-plugin-utils': 7.10.4 dev: true peerDependencies: @@ -389,33 +398,33 @@ packages: /@babel/template/7.12.7: dependencies: '@babel/code-frame': 7.10.4 - '@babel/parser': 7.12.7 - '@babel/types': 7.12.7 + '@babel/parser': 7.12.10 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-GkDzmHS6GV7ZeXfJZ0tLRBhZcMcY0/Lnb+eEbXDBfCAcZCjrZKe6p3J4we/D24O9Y8enxWAg1cWwof59yLh2ow== - /@babel/traverse/7.12.9: + /@babel/traverse/7.12.10: dependencies: '@babel/code-frame': 7.10.4 - '@babel/generator': 7.12.5 + '@babel/generator': 7.12.10 '@babel/helper-function-name': 7.10.4 '@babel/helper-split-export-declaration': 7.11.0 - '@babel/parser': 7.12.7 - '@babel/types': 7.12.7 + '@babel/parser': 7.12.10 + '@babel/types': 7.12.10 debug: 4.3.1 globals: 11.12.0 lodash: 4.17.20 dev: true resolution: - integrity: sha512-iX9ajqnLdoU1s1nHt36JDI9KG4k+vmI8WgjK5d+aDTwQbL2fUnzedNedssA645Ede3PM2ma1n8Q4h2ohwXgMXw== - /@babel/types/7.12.7: + integrity: sha512-6aEtf0IeRgbYWzta29lePeYSk+YAFIC3kyqESeft8o5CkFlYIMX+EQDDWEiAQ9LHOA3d0oHdgrSsID/CKqXJlg== + /@babel/types/7.12.10: dependencies: '@babel/helper-validator-identifier': 7.10.4 lodash: 4.17.20 to-fast-properties: 2.0.0 dev: true resolution: - integrity: sha512-MNyI92qZq6jrQkXvtIiykvl4WtoRrVV9MPn+ZfsoEENjiWcBQ3ZSHrkxnJWgWtLX3XXqX5hrSQ+X69wkmesXuQ== + integrity: sha512-sf6wboJV5mGyip2hIpDSKsr80RszPinEFjsHTalMxZAZkoQ2/2yQzxlcFN52SJqsyPfLtPmenL4g2KB3KJXPDw== /@bcoe/v8-coverage/0.2.3: dev: true resolution: @@ -591,7 +600,7 @@ packages: globals: 12.4.0 ignore: 4.0.6 import-fresh: 3.2.2 - js-yaml: 3.14.0 + js-yaml: 3.14.1 lodash: 4.17.20 minimatch: 3.0.4 strip-json-comments: 3.1.1 @@ -675,7 +684,7 @@ packages: camelcase: 5.3.1 find-up: 4.1.0 get-package-type: 0.1.0 - js-yaml: 3.14.0 + js-yaml: 3.14.1 resolve-from: 5.0.0 dev: true engines: @@ -691,7 +700,7 @@ packages: /@jest/console/26.6.2: dependencies: '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 chalk: 4.1.0 jest-message-util: 26.6.2 jest-util: 26.6.2 @@ -708,7 +717,7 @@ packages: '@jest/test-result': 26.6.2 '@jest/transform': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 ansi-escapes: 4.3.1 chalk: 4.1.0 exit: 0.1.2 @@ -740,7 +749,7 @@ packages: dependencies: '@jest/fake-timers': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 jest-mock: 26.6.2 dev: true engines: @@ -751,7 +760,7 @@ packages: dependencies: '@jest/types': 26.6.2 '@sinonjs/fake-timers': 6.0.1 - '@types/node': 14.14.10 + '@types/node': 14.14.12 jest-message-util: 26.6.2 jest-mock: 26.6.2 jest-util: 26.6.2 @@ -838,7 +847,7 @@ packages: integrity: sha512-YHlVIjP5nfEyjlrSr8t/YdNfU/1XEt7c5b4OxcXCjyRhjzLYu/rO69/WHPuYcbCWkz8kAeZVZp2N2+IOLLEPGw== /@jest/transform/26.6.2: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@jest/types': 26.6.2 babel-plugin-istanbul: 6.0.0 chalk: 4.1.0 @@ -862,7 +871,7 @@ packages: dependencies: '@types/istanbul-lib-coverage': 2.0.3 '@types/istanbul-reports': 3.0.0 - '@types/node': 14.14.10 + '@types/node': 14.14.12 '@types/yargs': 15.0.11 chalk: 4.1.0 dev: true @@ -1742,14 +1751,14 @@ packages: integrity: sha512-ngDBevLbBTFfrHZeiS7SAMAZ6ssuVmXuya+F/7RaVvlysgGa1JKJkKWY+jV6TCJYcW0OALfJ7nTIGXcBXzycfQ== /@octokit/types/2.16.2: dependencies: - '@types/node': 14.14.10 + '@types/node': 14.14.12 dev: true resolution: integrity: sha512-O75k56TYvJ8WpAakWwYRN8Bgu60KrmX0z1KqFp1kNiFNkgW+JW+9EBKZ+S33PU6SLvbihqd+3drvPxKK68Ee8Q== /@octokit/types/6.1.1: dependencies: '@octokit/openapi-types': 2.0.0 - '@types/node': 14.14.10 + '@types/node': 14.14.12 dev: true resolution: integrity: sha512-btm3D6S7VkRrgyYF31etUtVY/eQ1KzrNRqhFt25KSe2mKlXuLXJilglRC6eDA2P6ou94BUnk/Kz5MPEolXgoiw== @@ -1771,33 +1780,33 @@ packages: integrity: sha512-qZLoYeXSTgQuK1h7QQS16hqLGdmqtRmN8w/rl3Au/l5x/zkHx+a4VHrHyBsi1I1vtK2oBHxSzKIu0R5p6spdOA== /@types/babel__core/7.1.12: dependencies: - '@babel/parser': 7.12.7 - '@babel/types': 7.12.7 + '@babel/parser': 7.12.10 + '@babel/types': 7.12.10 '@types/babel__generator': 7.6.2 '@types/babel__template': 7.4.0 - '@types/babel__traverse': 7.0.16 + '@types/babel__traverse': 7.11.0 dev: true resolution: integrity: sha512-wMTHiiTiBAAPebqaPiPDLFA4LYPKr6Ph0Xq/6rq1Ur3v66HXyG+clfR9CNETkD7MQS8ZHvpQOtA53DLws5WAEQ== /@types/babel__generator/7.6.2: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-MdSJnBjl+bdwkLskZ3NGFp9YcXGx5ggLpQQPqtgakVhsWK0hTtNYhjpZLlWQTviGTvF8at+Bvli3jV7faPdgeQ== /@types/babel__template/7.4.0: dependencies: - '@babel/parser': 7.12.7 - '@babel/types': 7.12.7 + '@babel/parser': 7.12.10 + '@babel/types': 7.12.10 dev: true resolution: integrity: sha512-NTPErx4/FiPCGScH7foPyr+/1Dkzkni+rHiYHHoTjvwou7AQzJkNeD60A9CXRy+ZEN2B1bggmkTMCDb+Mv5k+A== - /@types/babel__traverse/7.0.16: + /@types/babel__traverse/7.11.0: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 dev: true resolution: - integrity: sha512-S63Dt4CZOkuTmpLGGWtT/mQdVORJOpx6SZWGVaP56dda/0Nx5nEe82K7/LAm8zYr6SfMq+1N2OreIOrHAx656w== + integrity: sha512-kSjgDMZONiIfSH1Nxcr5JIRMwUetDki63FSQfpTCz8ogF3Ulqm8+mr5f78dUYs6vMiB6gBusQqfQmBvHZj/lwg== /@types/babylon/6.16.5: dependencies: '@types/babel-types': 7.0.9 @@ -1807,13 +1816,13 @@ packages: /@types/glob/7.1.3: dependencies: '@types/minimatch': 3.0.3 - '@types/node': 14.14.10 + '@types/node': 14.14.12 dev: true resolution: integrity: sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== /@types/graceful-fs/4.1.4: dependencies: - '@types/node': 14.14.10 + '@types/node': 14.14.12 dev: true resolution: integrity: sha512-mWA/4zFQhfvOA8zWkXobwJvBD7vzcxgrOQ0J5CH1votGqdq9m7+FwtGaqyCZqC3NyyBkc9z4m+iry4LlqcMWJg== @@ -1833,13 +1842,13 @@ packages: dev: true resolution: integrity: sha512-nwKNbvnwJ2/mndE9ItP/zc2TCzw6uuodnF4EHYWD+gCQDVBuRQL5UzbZD0/ezy1iKsFU2ZQiDqg4M9dN4+wZgA== - /@types/jest/26.0.16: + /@types/jest/26.0.18: dependencies: jest-diff: 26.6.2 pretty-format: 26.6.2 dev: true resolution: - integrity: sha512-Gp12+7tmKCgv9JjtltxUXokohCAEZfpJaEW5tn871SGRp8I+bRWBonQO7vW5NHwnAHe5dd50+Q4zyKuN35i09g== + integrity: sha512-scDPs+mELZgsFetTgBSsIxKGrlitn9t/d2ecP+S1QSIGD+31fkMBEftLfOAX5k3tU06/0PjreJIQ+gWEbbHqpw== /@types/minimatch/3.0.3: dev: true resolution: @@ -1848,10 +1857,10 @@ packages: dev: true resolution: integrity: sha512-fZQQafSREFyuZcdWFAExYjBiCL7AUCdgsk80iO0q4yihYYdcIiH28CcuPTGFgLOCC8RlW49GSQxdHwZP+I7CNg== - /@types/node/14.14.10: + /@types/node/14.14.12: dev: true resolution: - integrity: sha512-J32dgx2hw8vXrSbu4ZlVhn1Nm3GbeCFNw2FWL8S5QKucHGY0cyNwjdQdO+KMBZ4wpmC7KhLCiNsdk1RFRIYUQQ== + integrity: sha512-ASH8OPHMNlkdjrEdmoILmzFfsJICvhBsFfAum4aKZ/9U4B6M6tTmTPh+f3ttWdD74CEGV5XvXWkbyfSdXaTd7g== /@types/normalize-package-data/2.4.0: dev: true resolution: @@ -2389,14 +2398,14 @@ packages: dev: true resolution: integrity: sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ== - /babel-jest/26.6.3_@babel+core@7.12.9: + /babel-jest/26.6.3_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@jest/transform': 26.6.2 '@jest/types': 26.6.2 '@types/babel__core': 7.1.12 babel-plugin-istanbul: 6.0.0 - babel-preset-jest: 26.6.2_@babel+core@7.12.9 + babel-preset-jest: 26.6.2_@babel+core@7.12.10 chalk: 4.1.0 graceful-fs: 4.2.4 slash: 3.0.0 @@ -2422,39 +2431,39 @@ packages: /babel-plugin-jest-hoist/26.6.2: dependencies: '@babel/template': 7.12.7 - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 '@types/babel__core': 7.1.12 - '@types/babel__traverse': 7.0.16 + '@types/babel__traverse': 7.11.0 dev: true engines: node: '>= 10.14.2' resolution: integrity: sha512-PO9t0697lNTmcEHH69mdtYiOIkkOlj9fySqfO3K1eCcdISevLAE0xY59VLLUj0SoiPiTX/JU2CYFpILydUa5Lw== - /babel-preset-current-node-syntax/1.0.0_@babel+core@7.12.9: - dependencies: - '@babel/core': 7.12.9 - '@babel/plugin-syntax-async-generators': 7.8.4_@babel+core@7.12.9 - '@babel/plugin-syntax-bigint': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-class-properties': 7.12.1_@babel+core@7.12.9 - '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.12.9 - '@babel/plugin-syntax-json-strings': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-logical-assignment-operators': 7.10.4_@babel+core@7.12.9 - '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-numeric-separator': 7.10.4_@babel+core@7.12.9 - '@babel/plugin-syntax-object-rest-spread': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-optional-catch-binding': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-optional-chaining': 7.8.3_@babel+core@7.12.9 - '@babel/plugin-syntax-top-level-await': 7.12.1_@babel+core@7.12.9 + /babel-preset-current-node-syntax/1.0.0_@babel+core@7.12.10: + dependencies: + '@babel/core': 7.12.10 + '@babel/plugin-syntax-async-generators': 7.8.4_@babel+core@7.12.10 + '@babel/plugin-syntax-bigint': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-class-properties': 7.12.1_@babel+core@7.12.10 + '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.12.10 + '@babel/plugin-syntax-json-strings': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-logical-assignment-operators': 7.10.4_@babel+core@7.12.10 + '@babel/plugin-syntax-nullish-coalescing-operator': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-numeric-separator': 7.10.4_@babel+core@7.12.10 + '@babel/plugin-syntax-object-rest-spread': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-optional-catch-binding': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-optional-chaining': 7.8.3_@babel+core@7.12.10 + '@babel/plugin-syntax-top-level-await': 7.12.1_@babel+core@7.12.10 dev: true peerDependencies: '@babel/core': ^7.0.0 resolution: integrity: sha512-mGkvkpocWJes1CmMKtgGUwCeeq0pOhALyymozzDWYomHTbDLwueDYG6p4TK1YOeYHCzBzYPsWkgTto10JubI1Q== - /babel-preset-jest/26.6.2_@babel+core@7.12.9: + /babel-preset-jest/26.6.2_@babel+core@7.12.10: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 babel-plugin-jest-hoist: 26.6.2 - babel-preset-current-node-syntax: 1.0.0_@babel+core@7.12.9 + babel-preset-current-node-syntax: 1.0.0_@babel+core@7.12.10 dev: true engines: node: '>= 10.14.2' @@ -2682,7 +2691,7 @@ packages: serve-static: 1.13.2 server-destroy: 1.0.1 socket.io: 2.1.1 - ua-parser-js: 0.7.22 + ua-parser-js: 0.7.23 yargs: 15.4.1 dev: true engines: @@ -3243,7 +3252,7 @@ packages: integrity: sha512-MWufYdFw53ccGjCA+Ol7XJYpAlW6/prSMzuPOTRnJGcGzuhLn4Scrz7qf6o8bROZ514ltazcIFJZevcfbo0x7A== /config-chain/1.1.12: dependencies: - ini: 1.3.5 + ini: 1.3.7 proto-list: 1.2.4 dev: true resolution: @@ -3436,7 +3445,7 @@ packages: dependencies: import-fresh: 2.0.0 is-directory: 0.3.1 - js-yaml: 3.14.0 + js-yaml: 3.14.1 parse-json: 4.0.0 dev: true engines: @@ -3569,13 +3578,13 @@ packages: integrity: sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== /debug/3.2.7: dependencies: - ms: 2.1.2 + ms: 2.1.3 dev: true resolution: integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== /debug/4.1.1: dependencies: - ms: 2.1.2 + ms: 2.1.3 deprecated: 'Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)' dev: true resolution: @@ -4043,20 +4052,20 @@ packages: dev: true resolution: integrity: sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA== - /esbuild-jest/0.3.0_esbuild@0.8.20: + /esbuild-jest/0.3.0_esbuild@0.8.21: dependencies: - esbuild: 0.8.20 + esbuild: 0.8.21 dev: true peerDependencies: esbuild: '>=0.8.16' resolution: integrity: sha512-J1ZHN4IbQiLJAsCMK2XkPYZsTrD8ius+1B09RVqfrvmT+BnwGdR6CLvRq6DGopOaEmdkr4AIk/J6LQUhRQDsSg== - /esbuild/0.8.20: + /esbuild/0.8.21: dev: true hasBin: true requiresBuild: true resolution: - integrity: sha512-xXNLXa2SraaAoeTybOMAvOf6KW/DthI3ATXMG+W3yMav1iFpEGvo4XS22AzCPE3rTXbK/7TykxpwI8mD6lYUOg== + integrity: sha512-vRRx5MZmiekw2R7jK5BppvBUFCJA0Zkl0wYxrDmyUvMPBcQC/xJvxJUM4R+Hgjgb3gp5P1W655AsuoqDeQQDVw== /escalade/3.1.1: dev: true engines: @@ -4146,7 +4155,7 @@ packages: import-fresh: 3.2.2 imurmurhash: 0.1.4 is-glob: 4.0.1 - js-yaml: 3.14.0 + js-yaml: 3.14.1 json-stable-stringify-without-jsonify: 1.0.1 levn: 0.4.1 lodash: 4.17.20 @@ -4934,7 +4943,7 @@ packages: integrity: sha512-KlIa5jvMYLjXMQXkqpFzobsyD/V2K5DRHl5OAf+6oDFPlPLxrGDVQlIdI63c4/Kt6kai4kALENSALlzTGST3GQ== /gitconfiglocal/1.0.0: dependencies: - ini: 1.3.5 + ini: 1.3.7 dev: true resolution: integrity: sha1-QdBF84UaXqiPA/JMocYXgRRGS5s= @@ -5001,7 +5010,7 @@ packages: integrity: sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== /global-dirs/0.1.1: dependencies: - ini: 1.3.5 + ini: 1.3.7 dev: true engines: node: '>=4' @@ -5021,7 +5030,7 @@ packages: dependencies: expand-tilde: 2.0.2 homedir-polyfill: 1.0.3 - ini: 1.3.5 + ini: 1.3.7 is-windows: 1.0.2 which: 1.3.1 dev: true @@ -5115,16 +5124,16 @@ packages: hasBin: true resolution: integrity: sha512-zzGBl5fHo0EKSXsHzjspp3y5CONegCm8ErO5Qh0UzFzk2y4tMvzLWhoDokADbarfZRL2pGpRp7yt6gfJX4ph7A== - /gulp-esbuild/0.3.2: + /gulp-esbuild/0.3.4: dependencies: - esbuild: 0.8.20 + esbuild: 0.8.21 plugin-error: 1.0.1 vinyl: 2.2.1 dev: true engines: node: '>=8.6.0' resolution: - integrity: sha512-nUcmfOF1/qa8VTut+koBaK2seiqDwHpUl0BDetXGuW41bYAiX5vFpZyqCj1fvgp5uBGatUx8CfejpgJIe9ZQfQ== + integrity: sha512-tMbBstl8AUPJ3ReMxU68CU/tK09y4hxhlIWLZ/LehZAflBrDU3CDRE1GNZQf2TytpHEZcCxm96MtYH56xgZFcg== /gulp-pug/4.0.1: dependencies: '@types/pug': 2.0.4 @@ -5333,7 +5342,7 @@ packages: depd: 1.1.2 inherits: 2.0.3 setprototypeof: 1.1.0 - statuses: 1.4.0 + statuses: 1.5.0 dev: true engines: node: '>= 0.6' @@ -5398,7 +5407,7 @@ packages: integrity: sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== /humanize-ms/1.2.1: dependencies: - ms: 2.1.2 + ms: 2.1.3 dev: true resolution: integrity: sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0= @@ -5532,10 +5541,10 @@ packages: dev: true resolution: integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== - /ini/1.3.5: + /ini/1.3.7: dev: true resolution: - integrity: sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + integrity: sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ== /init-package-json/1.10.3: dependencies: glob: 7.1.6 @@ -6005,7 +6014,7 @@ packages: integrity: sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg== /istanbul-lib-instrument/4.0.3: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@istanbuljs/schema': 0.1.2 istanbul-lib-coverage: 3.0.0 semver: 6.3.0 @@ -6080,10 +6089,10 @@ packages: integrity: sha512-GF9noBSa9t08pSyl3CY4frMrqp+aQXFGFkf5hEPbh/pIUFYWMK6ZLTfbmadxJVcJrdRoChlWQsA2VkJcDFK8hg== /jest-config/26.6.3: dependencies: - '@babel/core': 7.12.9 + '@babel/core': 7.12.10 '@jest/test-sequencer': 26.6.3 '@jest/types': 26.6.2 - babel-jest: 26.6.3_@babel+core@7.12.9 + babel-jest: 26.6.3_@babel+core@7.12.10 chalk: 4.1.0 deepmerge: 4.2.2 glob: 7.1.6 @@ -6144,7 +6153,7 @@ packages: '@jest/environment': 26.6.2 '@jest/fake-timers': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 jest-mock: 26.6.2 jest-util: 26.6.2 jsdom: 16.4.0 @@ -6158,7 +6167,7 @@ packages: '@jest/environment': 26.6.2 '@jest/fake-timers': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 jest-mock: 26.6.2 jest-util: 26.6.2 dev: true @@ -6176,7 +6185,7 @@ packages: dependencies: '@jest/types': 26.6.2 '@types/graceful-fs': 4.1.4 - '@types/node': 14.14.10 + '@types/node': 14.14.12 anymatch: 3.1.1 fb-watchman: 2.0.1 graceful-fs: 4.2.4 @@ -6196,12 +6205,12 @@ packages: integrity: sha512-easWIJXIw71B2RdR8kgqpjQrbMRWQBgiBwXYEhtGUTaX+doCjBheluShdDMeR8IMfJiTqH4+zfhtg29apJf/8w== /jest-jasmine2/26.6.3: dependencies: - '@babel/traverse': 7.12.9 + '@babel/traverse': 7.12.10 '@jest/environment': 26.6.2 '@jest/source-map': 26.6.2 '@jest/test-result': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 chalk: 4.1.0 co: 4.6.0 expect: 26.6.2 @@ -6258,7 +6267,7 @@ packages: /jest-mock/26.6.2: dependencies: '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 dev: true engines: node: '>= 10.14.2' @@ -6314,7 +6323,7 @@ packages: '@jest/environment': 26.6.2 '@jest/test-result': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 chalk: 4.1.0 emittery: 0.7.2 exit: 0.1.2 @@ -6372,7 +6381,7 @@ packages: integrity: sha512-lrzyR3N8sacTAMeonbqpnSka1dHNux2uk0qqDXVkMv2c/A3wYnvQ4EXuI013Y6+gSKSCxdaczvf4HF0mVXHRdw== /jest-serializer/26.6.2: dependencies: - '@types/node': 14.14.10 + '@types/node': 14.14.12 graceful-fs: 4.2.4 dev: true engines: @@ -6381,9 +6390,9 @@ packages: integrity: sha512-S5wqyz0DXnNJPd/xfIzZ5Xnp1HrJWBczg8mMfMpN78OJ5eDxXyf+Ygld9wX1DnUWbIbhM1YDY95NjR4CBXkb2g== /jest-snapshot/26.6.2: dependencies: - '@babel/types': 7.12.7 + '@babel/types': 7.12.10 '@jest/types': 26.6.2 - '@types/babel__traverse': 7.0.16 + '@types/babel__traverse': 7.11.0 '@types/prettier': 2.1.5 chalk: 4.1.0 expect: 26.6.2 @@ -6405,7 +6414,7 @@ packages: /jest-util/26.6.2: dependencies: '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 chalk: 4.1.0 graceful-fs: 4.2.4 is-ci: 2.0.0 @@ -6432,7 +6441,7 @@ packages: dependencies: '@jest/test-result': 26.6.2 '@jest/types': 26.6.2 - '@types/node': 14.14.10 + '@types/node': 14.14.12 ansi-escapes: 4.3.1 chalk: 4.1.0 jest-util: 26.6.2 @@ -6444,7 +6453,7 @@ packages: integrity: sha512-WKJob0P/Em2csiVthsI68p6aGKTIcsfjH9Gsx1f0A3Italz43e3ho0geSAVsmj09RWOELP1AZ/DXyJgOgDKxXQ== /jest-worker/26.6.2: dependencies: - '@types/node': 14.14.10 + '@types/node': 14.14.12 merge-stream: 2.0.0 supports-color: 7.2.0 dev: true @@ -6475,14 +6484,14 @@ packages: dev: true resolution: integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== - /js-yaml/3.14.0: + /js-yaml/3.14.1: dependencies: argparse: 1.0.10 esprima: 4.0.1 dev: true hasBin: true resolution: - integrity: sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== + integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g== /jsbn/0.1.1: dev: true resolution: @@ -7276,6 +7285,10 @@ packages: dev: true resolution: integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== + /ms/2.1.3: + dev: true + resolution: + integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== /multimatch/3.0.0: dependencies: array-differ: 2.1.0 @@ -7424,7 +7437,7 @@ packages: is-wsl: 2.2.0 semver: 7.3.4 shellwords: 0.1.1 - uuid: 8.3.1 + uuid: 8.3.2 which: 2.0.2 dev: true optional: true @@ -10217,10 +10230,17 @@ packages: dev: true resolution: integrity: sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= - /ua-parser-js/0.7.22: + /typescript/4.1.2: + dev: true + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== + /ua-parser-js/0.7.23: dev: true resolution: - integrity: sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q== + integrity: sha512-m4hvMLxgGHXG3O3fQVAyyAQpZzDOvwnhOTjYz5Xmr7r/+LpkNy3vJXdVRWgd1TkAb7NGROZuSy96CrlNVjA7KA== /uglify-js/2.8.29: dependencies: source-map: 0.5.7 @@ -10428,12 +10448,12 @@ packages: hasBin: true resolution: integrity: sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A== - /uuid/8.3.1: + /uuid/8.3.2: dev: true hasBin: true optional: true resolution: - integrity: sha512-FOmRr+FmWEIG8uhZv6C2bTgEVXsHk08kE7mPlrBbEe+c3r9pjceVPgupIfNIhc4yx55H69OXANrUaSuu9eInKg== + integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== /v8-compile-cache/2.2.0: dev: true resolution: -- knotmirror 0.0.1