aptechka 0.60.1 → 0.61.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/morph/Morph.d.ts +2 -1
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +264 -248
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface MorphNavigateOptions {
|
|
|
30
30
|
offsetScroll?: number | ElementOrSelector<HTMLElement>;
|
|
31
31
|
revalidate?: boolean;
|
|
32
32
|
keepSearchParameters?: boolean;
|
|
33
|
+
submorph?: Array<string>;
|
|
33
34
|
}
|
|
34
35
|
export interface MorphScrollDetail {
|
|
35
36
|
left: number;
|
|
@@ -65,7 +66,7 @@ export declare class Morph {
|
|
|
65
66
|
hash: string;
|
|
66
67
|
};
|
|
67
68
|
prefetch(path: string, revalidate?: boolean): Promise<void>;
|
|
68
|
-
navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, }?: MorphNavigateOptions): Promise<void>;
|
|
69
|
+
navigate(path: string, { historyAction, centerScroll, offsetScroll, revalidate, keepSearchParameters, submorph, }?: MorphNavigateOptions): Promise<void>;
|
|
69
70
|
addLink(element: HTMLAnchorElement): void;
|
|
70
71
|
addLinks(elements: Array<HTMLAnchorElement>): void;
|
|
71
72
|
removeLink(element: HTMLAnchorElement): void;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var wt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),bt=n=>{throw TypeError(n)};var at=(n,t,s)=>t.has(n)||bt("Cannot "+s);var e=(n,t,s)=>(at(n,t,"read from private field"),s?s.call(n):t.get(n)),a=(n,t,s)=>t.has(n)?bt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),o=(n,t,s,i)=>(at(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(at(n,t,"access private method"),s);var N=(n,t,s)=>new Promise((i,u)=>{var E=p=>{try{H(s.next(p))}catch(h){u(h)}},L=p=>{try{H(s.throw(p))}catch(h){u(h)}},H=p=>p.done?i(p.value):Promise.resolve(p.value).then(E,L);H((s=s.apply(n,t)).next())});var Pt=(n,t,s)=>(t=n[wt("asyncIterator")])?t.call(n):(n=n[wt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=E=>new Promise((L,H,p)=>(E=u.call(n,E),p=E.done,Promise.resolve(E.value).then(h=>L({value:h,done:p}),H)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ct=require("../index-Cqw2NKev.cjs"),F=require("../events-KVanG9sR.cjs"),Rt=require("../polyfills-Df4r-ETT.cjs"),kt=require("../scroll-DAhSpkhR.cjs"),tt=require("../url-D1CgmwZ_.cjs"),zt=require("../css-value-parser/index.cjs");class Tt extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Ct.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Tt);var P,l,x,Y,V;class ot{constructor(t,s){a(this,P);a(this,l);a(this,x);a(this,Y,t=>{if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,P).previousPathname)history.back();else{const i=e(this,l).getAttribute("data-history-action")||"push",u=e(this,l).hasAttribute("data-center-scroll"),E=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),L=E?zt.cssValueParser.parse(E):void 0,H=e(this,l).hasAttribute("data-revalidate"),p=e(this,l).hasAttribute("data-keep-search-parameters");e(this,P).navigate(e(this,x),{historyAction:i,centerScroll:u,offsetScroll:L,revalidate:H,keepSearchParameters:p})}});a(this,V,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,P).prefetch(e(this,x),t),e(this,l).removeEventListener("pointerenter",e(this,V))});o(this,P,s),o(this,l,t),o(this,x,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Y)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,V))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,P).normalizePath(t),i=e(this,P).normalizePath(e(this,x));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,Y)),e(this,l).removeEventListener("pointerenter",e(this,V)),e(this,l).classList.remove("current")}}P=new WeakMap,l=new WeakMap,x=new WeakMap,Y=new WeakMap,V=new WeakMap;var C,B,v,q,D,T;class At{constructor(t,s,i){a(this,C);a(this,B);a(this,v,{x:0,y:0});a(this,q);a(this,D,null);a(this,T,null);o(this,C,t),o(this,B,s),o(this,q,i.cloneNode(!0))}get pathname(){return e(this,B)}get scrollState(){return e(this,v)}get document(){return e(this,T)}cloneDocument(){o(this,T,(e(this,D)||e(this,q)).cloneNode(!0))}get title(){let t="";if(e(this,T).title)t=e(this,T).title;else{const s=e(this,T).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,B)}return t}clearScrollState(){e(this,v).x=0,e(this,v).y=0}clearDocumentState(){o(this,D,null)}saveScrollState(){e(this,q).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,v).x=0,e(this,v).y=0):(e(this,v).x=e(this,C).scrollElement.scrollLeft,e(this,v).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,q).documentElement.hasAttribute("data-no-page-restoration")?o(this,D,null):o(this,D,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,v).y,left:e(this,v).x})}renewScrollPosition(){e(this,C).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}C=new WeakMap,B=new WeakMap,v=new WeakMap,q=new WeakMap,D=new WeakMap,T=new WeakMap;var k,W,m,st,M,f,G,R,A,w,j,z,J,c,et,Mt,lt,Ht,ht,ut,dt,mt,it,U;const K=class K{constructor(t){a(this,c);a(this,k,null);a(this,W,null);a(this,m,[]);a(this,st,new DOMParser);a(this,M);a(this,f,null);a(this,G);a(this,R,[]);a(this,A,!1);a(this,w,null);a(this,j,new Map);a(this,z,null);a(this,J,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,it,t=>N(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),o(this,A,!0),yield this.navigate(t.state.path,{historyAction:"none"}),o(this,A,!1))}));a(this,U,()=>{const t=e(this,w).scrollTop,s=e(this,w).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),F.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Ct.isBrowser&&!K.instance){K.instance=this,o(this,k,{base:tt.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),o(this,W,d(this,c,lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);o(this,f,s.pathname),e(this,j).set(e(this,f),new At(this,e(this,f),document)),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,it)),tt.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters||location.search,hash:s.hash}),o(this,z,new Tt),d(this,c,dt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,G)}get links(){return e(this,m)}get scrollElement(){return e(this,w)}get isPopstateNavigation(){return e(this,A)}normalizePath(t){return tt.splitPath(t,{base:e(this,k).base,trailingSlash:e(this,k).trailingSlash})}prefetch(t,s){return N(this,null,function*(){const i=this.normalizePath(t);d(this,c,et).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(H){return N(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:E,keepSearchParameters:L}={}){var pt;if(e(this,R).length)return;const p=this.normalizePath(((pt=this.pathnameModifier)==null?void 0:pt.call(this,t))||t);let{pathname:h,hash:Q,parameters:ft,leaf:Nt}=p;if(e(this,M)===h||e(this,f)===h){e(this,A)||d(this,c,mt).call(this,Q||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}o(this,M,h),e(this,m).forEach(I=>{I.checkCurrent(h)});try{let I=!0;if(this.preprocessor)try{yield new Promise((r,b)=>{var S;(S=this.preprocessor)==null||S.call(this,{pathname:h,resolve:r,reject:b})})}catch(r){r?console.error(r):console.log("Route change canceled"),I=!1}if(!I||e(this,M)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}const rt={pathname:h};F.dispatchEvent(document,"morphNavigation",{detail:rt});const Et=yield d(this,c,et).call(this,e(this,f)),y=yield d(this,c,et).call(this,h,{searchParameters:ft,revalidate:E});if(e(this,M)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}Et.saveScrollState(),Et.saveDocumentState(),e(this,A)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,z).textContent=y.title,document.body.appendChild(e(this,z)),F.dispatchEvent(document,"morphStart",{detail:rt});const gt=Array.from(document.head.children),vt=Array.from(y.document.head.children),St=d(this,c,Ht).call(this,gt,vt),xt=d(this,c,ht).call(this,gt,St),X=d(this,c,ht).call(this,vt,St);X.forEach((r,b)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const S=document.createElement("script");S.type="module",S.src=r.getAttribute("src"),X[b]=S}}),X.forEach(r=>{document.head.appendChild(r)});const nt=X.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ut).call(this,r))return!0});e(this,k).waitForHeadToLoad&&nt.length&&(yield new Promise(r=>N(this,null,function*(){let b=0;try{for(var S=Pt(nt),O,$,yt;O=!($=yield S.next()).done;O=!1){const Z=$.value;Z.onload=()=>{b++,b===nt.length&&r()}}}catch($){yt=[$]}finally{try{O&&($=S.return)&&(yield $.call(S))}finally{if(yt)throw yt[0]}}}))),yield kt.wait(10);const Lt=[];xt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ut).call(this,r)?Lt.push(r):r.remove())});const qt=d(this,c,lt).call(this,y.document.body);e(this,k).morphInsideScrollContainer||d(this,c,dt).call(this,y.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Nt),tt.changeHistory({action:s,pathname:h,searchParameters:ft||(L?location.search:""),hash:Q}),e(this,z).remove(),o(this,G,e(this,f)),o(this,f,h),e(this,W).forEach((r,b)=>{const S=qt[b],O=getComputedStyle(r).getPropertyValue("--morph-duration"),$=[...S.childNodes];if(O){const yt=[...r.childNodes];yt.forEach(g=>{g instanceof HTMLElement&&(this.destroyOldLinks(g),g.classList.add("old"))}),$.forEach(g=>{g instanceof HTMLElement&&(this.findNewLinks(g),g.classList.add("new"))}),r.prepend(...$),Rt.requestIdleCallback(()=>{$.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Z={morphElement:r,pathname:h};F.dispatchEvent(document,"morphNewChildrenAdded",{detail:Z});const Dt=new Promise(g=>{setTimeout(()=>{yt.forEach(_=>_.remove()),$.forEach(_=>{_ instanceof HTMLElement&&_.classList.remove("in","new")}),F.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Z}),g()},(parseFloat(O)||0)*1e3+10)});e(this,R).push(Dt)}else this.destroyOldLinks(r),r.innerHTML="",r.append(...$),this.findNewLinks(r)}),Q?(y.clearScrollState(),d(this,c,mt).call(this,Q,{centerScroll:i,offsetScroll:u})):e(this,A)?y.restoreScrollPosition():y.renewScrollPosition(),yield Promise.all(e(this,R)),Lt.forEach(r=>r.remove()),o(this,R,[]),e(this,W).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const O=document.createElement("script");O.type="module",O.src=S.getAttribute("src"),S.replaceWith(O)})}),F.dispatchEvent(document,"morphComplete",{detail:rt}),window.dispatchEvent(new Event("resize"))}catch(I){console.error(I)}o(this,M,void 0)})}addLink(t){e(this,m).push(new ot(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){o(this,m,e(this,m).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){o(this,m,e(this,m).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,J));e(this,m).push(...s.map(i=>new ot(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,J));e(this,m).forEach(s=>s.destroy()),o(this,m,t.map(s=>new ot(s,this)))}};k=new WeakMap,W=new WeakMap,m=new WeakMap,st=new WeakMap,M=new WeakMap,f=new WeakMap,G=new WeakMap,R=new WeakMap,A=new WeakMap,w=new WeakMap,j=new WeakMap,z=new WeakMap,J=new WeakMap,c=new WeakSet,et=function(t,s){return N(this,null,function*(){let i=e(this,j).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,Mt).call(this,t,s==null?void 0:s.searchParameters)),i})},Mt=function(t,s){return N(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),E=e(this,st).parseFromString(u,"text/html"),L=new At(this,t,E);return e(this,j).set(t,L),L})},lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Ht=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},ht=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ut=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},dt=function(t){var s,i;(s=e(this,w))==null||s.removeEventListener("scroll",e(this,U)),o(this,w,t.querySelector(e(this,k).scrollSelector)||t.documentElement),(i=e(this,w))==null||i.addEventListener("scroll",e(this,U)),e(this,U).call(this)},mt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&kt.scrollToElement(i,{scrollElement:e(this,w),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},it=new WeakMap,U=new WeakMap,K.instance=null;let ct=K;exports.Morph=ct;
|
|
1
|
+
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var g=v=>{try{b(s.next(v))}catch(A){u(A)}},w=v=>{try{b(s.throw(v))}catch(A){u(A)}},b=v=>v.done?i(v.value):Promise.resolve(v.value).then(g,w);b((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=g=>new Promise((w,b,v)=>(g=u.call(n,g),v=g.done,Promise.resolve(g.value).then(A=>w({value:A,done:v}),b)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht extends HTMLElement{connectedCallback(){const t={"aria-live":"assertive","aria-atomic":"true",style:"position: absolute; left: 0; top: 0; clip: rect(0 0 0 0); clip-path: inset(50%); overflow: hidden; white-space: nowrap; width: 1px; height: 1px"};for(const[s,i]of Object.entries(t))this.setAttribute(s,i)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",g=e(this,l).hasAttribute("data-center-scroll"),w=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),b=w?Ot.cssValueParser.parse(w):void 0,v=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:g,offsetScroll:b,revalidate:v,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).normalizePath(e(this,z));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,y,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,y,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,y)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,x).scrollElement.scrollLeft,e(this,y).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,y=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(v){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:g,keepSearchParameters:w,submorph:b}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var S;(S=this.preprocessor)==null||S.call(this,{pathname:m,resolve:r,reject:k})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),L=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:g});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(L.clearScrollState(),L.clearDocumentState()),L.cloneDocument(),e(this,F).textContent=L.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(L.document.head.children),bt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,bt),et=d(this,c,mt).call(this,wt,bt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const S=document.createElement("script");S.type="module",S.src=r.getAttribute("src"),et[k]=S}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var S=kt(lt),Q,D,j;Q=!(D=yield S.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=S.return)&&(yield D.call(S))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const Lt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?Lt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,L.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,L.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(w?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const S=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];b?b.forEach(h=>{const E=r.querySelector(h),H=S.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...S.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),b?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(L.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?L.restoreScrollPosition():L.renewScrollPosition(),yield Promise.all(e(this,B)),Lt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const Q=document.createElement("script");Q.type="module",Q.src=S.getAttribute("src"),S.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),g=e(this,nt).parseFromString(u,"text/html"),w=new Tt(this,t,g);return e(this,G).set(t,w),w})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},pt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Lt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), bt = (n) => {
|
|
2
2
|
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (n, t, s) => (
|
|
6
|
-
var
|
|
7
|
-
var
|
|
4
|
+
var lt = (n, t, s) => t.has(n) || bt("Cannot " + s);
|
|
5
|
+
var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (lt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (lt(n, t, "access private method"), s);
|
|
6
|
+
var q = (n, t, s) => new Promise((i, u) => {
|
|
7
|
+
var g = (S) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
u(
|
|
9
|
+
L(s.next(S));
|
|
10
|
+
} catch (A) {
|
|
11
|
+
u(A);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, w = (S) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
u(
|
|
15
|
+
L(s.throw(S));
|
|
16
|
+
} catch (A) {
|
|
17
|
+
u(A);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, L = (S) => S.done ? i(S.value) : Promise.resolve(S.value).then(g, w);
|
|
20
|
+
L((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { i as
|
|
24
|
-
import { d as
|
|
25
|
-
import { r as
|
|
26
|
-
import { w as
|
|
27
|
-
import { n as
|
|
28
|
-
import { cssValueParser as
|
|
29
|
-
class
|
|
22
|
+
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (g) => new Promise((w, L, S) => (g = u.call(n, g), S = g.done, Promise.resolve(g.value).then((A) => w({ value: A, done: S }), L)))), s("next"), s("return"), t);
|
|
23
|
+
import { i as Tt } from "../index-euf5anj6.js";
|
|
24
|
+
import { d as $ } from "../events-CsVF98U6.js";
|
|
25
|
+
import { r as zt } from "../polyfills-DJrTJQky.js";
|
|
26
|
+
import { w as It, s as Ft } from "../scroll-Benkuq-t.js";
|
|
27
|
+
import { n as Ot, c as At, s as Bt } from "../url-B6BNcw6_.js";
|
|
28
|
+
import { cssValueParser as Vt } from "../css-value-parser/index.js";
|
|
29
|
+
class Mt extends HTMLElement {
|
|
30
30
|
connectedCallback() {
|
|
31
31
|
const t = {
|
|
32
32
|
"aria-live": "assertive",
|
|
@@ -37,362 +37,378 @@ class Ct extends HTMLElement {
|
|
|
37
37
|
this.setAttribute(s, i);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
var
|
|
42
|
-
class
|
|
40
|
+
Tt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Mt);
|
|
41
|
+
var C, l, z, Z, j;
|
|
42
|
+
class ht {
|
|
43
43
|
constructor(t, s) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
o(this, C);
|
|
45
|
+
o(this, l);
|
|
46
|
+
o(this, z);
|
|
47
|
+
o(this, Z, (t) => {
|
|
48
|
+
var i;
|
|
49
|
+
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, C).previousPathname)
|
|
49
50
|
history.back();
|
|
50
51
|
else {
|
|
51
|
-
const
|
|
52
|
+
const u = e(this, l).getAttribute(
|
|
52
53
|
"data-history-action"
|
|
53
|
-
) || "push",
|
|
54
|
+
) || "push", g = e(this, l).hasAttribute("data-center-scroll"), w = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), L = w ? Vt.parse(w) : void 0, S = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
|
|
54
55
|
"data-keep-search-parameters"
|
|
55
|
-
);
|
|
56
|
-
e(this,
|
|
57
|
-
historyAction:
|
|
58
|
-
centerScroll:
|
|
59
|
-
offsetScroll:
|
|
60
|
-
revalidate:
|
|
61
|
-
keepSearchParameters:
|
|
56
|
+
), m = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((V) => V.trim());
|
|
57
|
+
e(this, C).navigate(e(this, z), {
|
|
58
|
+
historyAction: u,
|
|
59
|
+
centerScroll: g,
|
|
60
|
+
offsetScroll: L,
|
|
61
|
+
revalidate: S,
|
|
62
|
+
keepSearchParameters: A,
|
|
63
|
+
submorph: m
|
|
62
64
|
});
|
|
63
65
|
}
|
|
64
66
|
});
|
|
65
|
-
|
|
66
|
-
const t = e(this,
|
|
67
|
-
e(this,
|
|
67
|
+
o(this, j, () => {
|
|
68
|
+
const t = e(this, l).hasAttribute("data-revalidate");
|
|
69
|
+
e(this, C).prefetch(e(this, z), t), e(this, l).removeEventListener("pointerenter", e(this, j));
|
|
68
70
|
});
|
|
69
|
-
|
|
71
|
+
a(this, C, s), a(this, l, t), a(this, z, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, Z)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, j));
|
|
70
72
|
}
|
|
71
73
|
get element() {
|
|
72
|
-
return e(this,
|
|
74
|
+
return e(this, l);
|
|
73
75
|
}
|
|
74
76
|
checkCurrent(t) {
|
|
75
|
-
const s = e(this,
|
|
76
|
-
e(this,
|
|
77
|
+
const s = e(this, C).normalizePath(t), i = e(this, C).normalizePath(e(this, z));
|
|
78
|
+
e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
77
79
|
}
|
|
78
80
|
destroy() {
|
|
79
|
-
e(this,
|
|
81
|
+
e(this, l).removeEventListener("click", e(this, Z)), e(this, l).removeEventListener("pointerenter", e(this, j)), e(this, l).classList.remove("current");
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
var
|
|
84
|
+
C = new WeakMap(), l = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), j = new WeakMap();
|
|
85
|
+
var N, K, y, I, F, x;
|
|
84
86
|
class kt {
|
|
85
87
|
constructor(t, s, i) {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
o(this, N);
|
|
89
|
+
o(this, K);
|
|
90
|
+
o(this, y, { x: 0, y: 0 });
|
|
91
|
+
o(this, I);
|
|
92
|
+
o(this, F, null);
|
|
93
|
+
o(this, x, null);
|
|
94
|
+
a(this, N, t), a(this, K, s), a(this, I, i.cloneNode(!0));
|
|
93
95
|
}
|
|
94
96
|
get pathname() {
|
|
95
|
-
return e(this,
|
|
97
|
+
return e(this, K);
|
|
96
98
|
}
|
|
97
99
|
get scrollState() {
|
|
98
|
-
return e(this,
|
|
100
|
+
return e(this, y);
|
|
99
101
|
}
|
|
100
102
|
get document() {
|
|
101
|
-
return e(this,
|
|
103
|
+
return e(this, x);
|
|
102
104
|
}
|
|
103
105
|
cloneDocument() {
|
|
104
|
-
|
|
106
|
+
a(this, x, (e(this, F) || e(this, I)).cloneNode(!0));
|
|
105
107
|
}
|
|
106
108
|
get title() {
|
|
107
109
|
let t = "";
|
|
108
|
-
if (e(this,
|
|
109
|
-
t = e(this,
|
|
110
|
+
if (e(this, x).title)
|
|
111
|
+
t = e(this, x).title;
|
|
110
112
|
else {
|
|
111
|
-
const s = e(this,
|
|
112
|
-
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this,
|
|
113
|
+
const s = e(this, x).querySelector("h1");
|
|
114
|
+
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, K);
|
|
113
115
|
}
|
|
114
116
|
return t;
|
|
115
117
|
}
|
|
116
118
|
clearScrollState() {
|
|
117
|
-
e(this,
|
|
119
|
+
e(this, y).x = 0, e(this, y).y = 0;
|
|
118
120
|
}
|
|
119
121
|
clearDocumentState() {
|
|
120
|
-
|
|
122
|
+
a(this, F, null);
|
|
121
123
|
}
|
|
122
124
|
saveScrollState() {
|
|
123
|
-
e(this,
|
|
125
|
+
e(this, I).documentElement.hasAttribute(
|
|
124
126
|
"data-no-scroll-restoration"
|
|
125
|
-
) ? (e(this,
|
|
127
|
+
) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this, N).scrollElement.scrollLeft, e(this, y).y = e(this, N).scrollElement.scrollTop);
|
|
126
128
|
}
|
|
127
129
|
saveDocumentState() {
|
|
128
|
-
e(this,
|
|
130
|
+
e(this, I).documentElement.hasAttribute(
|
|
129
131
|
"data-no-page-restoration"
|
|
130
|
-
) ?
|
|
132
|
+
) ? a(this, F, null) : a(this, F, document.cloneNode(!0));
|
|
131
133
|
}
|
|
132
134
|
restoreScrollPosition() {
|
|
133
|
-
e(this,
|
|
134
|
-
top: e(this,
|
|
135
|
-
left: e(this,
|
|
135
|
+
e(this, N).scrollElement.scroll({
|
|
136
|
+
top: e(this, y).y,
|
|
137
|
+
left: e(this, y).x
|
|
136
138
|
});
|
|
137
139
|
}
|
|
138
140
|
renewScrollPosition() {
|
|
139
|
-
e(this,
|
|
141
|
+
e(this, N).scrollElement.scroll({
|
|
140
142
|
top: 0,
|
|
141
143
|
left: 0,
|
|
142
144
|
behavior: "instant"
|
|
143
145
|
});
|
|
144
146
|
}
|
|
145
147
|
}
|
|
146
|
-
|
|
147
|
-
var
|
|
148
|
-
const
|
|
148
|
+
N = new WeakMap(), K = new WeakMap(), y = new WeakMap(), I = new WeakMap(), F = new WeakMap(), x = new WeakMap();
|
|
149
|
+
var T, Y, f, rt, D, p, _, O, M, P, G, B, tt, h, it, Ht, ct, Nt, ut, dt, mt, ft, nt, J;
|
|
150
|
+
const X = class X {
|
|
149
151
|
constructor(t) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
152
|
+
o(this, h);
|
|
153
|
+
o(this, T, null);
|
|
154
|
+
o(this, Y, null);
|
|
155
|
+
o(this, f, []);
|
|
156
|
+
o(this, rt, new DOMParser());
|
|
157
|
+
o(this, D);
|
|
158
|
+
o(this, p, null);
|
|
159
|
+
o(this, _);
|
|
160
|
+
o(this, O, []);
|
|
161
|
+
o(this, M, !1);
|
|
162
|
+
o(this, P, null);
|
|
163
|
+
o(this, G, /* @__PURE__ */ new Map());
|
|
164
|
+
o(this, B, null);
|
|
165
|
+
o(this, tt, (t) => {
|
|
164
166
|
var s;
|
|
165
167
|
return ((s = t.getAttribute("href")) == null ? void 0 : s.startsWith("/")) && !t.hasAttribute("download") && !t.hasAttribute("data-morph-skip") && !t.closest("[data-morph-skip]") && t.getAttribute("target") !== "_blank";
|
|
166
168
|
});
|
|
167
|
-
|
|
169
|
+
o(this, nt, (t) => q(this, null, function* () {
|
|
168
170
|
var s;
|
|
169
|
-
(s = t.state) != null && s.path && (t.preventDefault(),
|
|
171
|
+
(s = t.state) != null && s.path && (t.preventDefault(), a(this, M, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, M, !1));
|
|
170
172
|
}));
|
|
171
|
-
|
|
172
|
-
const t = e(this,
|
|
173
|
-
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0),
|
|
173
|
+
o(this, J, () => {
|
|
174
|
+
const t = e(this, P).scrollTop, s = e(this, P).scrollLeft;
|
|
175
|
+
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), $(document, "morphScroll", {
|
|
174
176
|
detail: {
|
|
175
177
|
left: s,
|
|
176
178
|
top: t
|
|
177
179
|
}
|
|
178
180
|
});
|
|
179
181
|
});
|
|
180
|
-
if (
|
|
181
|
-
|
|
182
|
-
base:
|
|
182
|
+
if (Tt && !X.instance) {
|
|
183
|
+
X.instance = this, a(this, T, {
|
|
184
|
+
base: Ot(t == null ? void 0 : t.base),
|
|
183
185
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
184
186
|
cachePages: (t == null ? void 0 : t.cachePages) !== !1,
|
|
185
187
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
186
188
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body",
|
|
187
189
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
188
|
-
}),
|
|
190
|
+
}), a(this, Y, d(this, h, ct).call(this, document.body));
|
|
189
191
|
const s = this.normalizePath(
|
|
190
192
|
location.pathname + location.hash
|
|
191
193
|
);
|
|
192
|
-
|
|
193
|
-
e(this,
|
|
194
|
-
new kt(this, e(this,
|
|
194
|
+
a(this, p, s.pathname), e(this, G).set(
|
|
195
|
+
e(this, p),
|
|
196
|
+
new kt(this, e(this, p), document)
|
|
195
197
|
), document.documentElement.setAttribute(
|
|
196
198
|
"data-current-pathname",
|
|
197
|
-
e(this,
|
|
199
|
+
e(this, p)
|
|
198
200
|
), document.documentElement.setAttribute(
|
|
199
201
|
"data-current-leaf",
|
|
200
202
|
s.leaf
|
|
201
|
-
), this.findLinks(), addEventListener("popstate", e(this,
|
|
203
|
+
), this.findLinks(), addEventListener("popstate", e(this, nt)), At({
|
|
202
204
|
action: "replace",
|
|
203
|
-
pathname: e(this,
|
|
205
|
+
pathname: e(this, p),
|
|
204
206
|
searchParameters: s.parameters || location.search,
|
|
205
207
|
hash: s.hash
|
|
206
|
-
}),
|
|
208
|
+
}), a(this, B, new Mt()), d(this, h, mt).call(this, document);
|
|
207
209
|
}
|
|
208
210
|
}
|
|
209
211
|
get currentPathname() {
|
|
210
|
-
return e(this,
|
|
212
|
+
return e(this, p);
|
|
211
213
|
}
|
|
212
214
|
get previousPathname() {
|
|
213
|
-
return e(this,
|
|
215
|
+
return e(this, _);
|
|
214
216
|
}
|
|
215
217
|
get links() {
|
|
216
|
-
return e(this,
|
|
218
|
+
return e(this, f);
|
|
217
219
|
}
|
|
218
220
|
get scrollElement() {
|
|
219
|
-
return e(this,
|
|
221
|
+
return e(this, P);
|
|
220
222
|
}
|
|
221
223
|
get isPopstateNavigation() {
|
|
222
|
-
return e(this,
|
|
224
|
+
return e(this, M);
|
|
223
225
|
}
|
|
224
226
|
normalizePath(t) {
|
|
225
|
-
return
|
|
226
|
-
base: e(this,
|
|
227
|
-
trailingSlash: e(this,
|
|
227
|
+
return Bt(t, {
|
|
228
|
+
base: e(this, T).base,
|
|
229
|
+
trailingSlash: e(this, T).trailingSlash
|
|
228
230
|
});
|
|
229
231
|
}
|
|
230
232
|
prefetch(t, s) {
|
|
231
|
-
return
|
|
233
|
+
return q(this, null, function* () {
|
|
232
234
|
const i = this.normalizePath(t);
|
|
233
|
-
d(this,
|
|
235
|
+
d(this, h, it).call(this, i.pathname, {
|
|
234
236
|
searchParameters: i.parameters,
|
|
235
237
|
revalidate: s
|
|
236
238
|
});
|
|
237
239
|
});
|
|
238
240
|
}
|
|
239
|
-
navigate(
|
|
240
|
-
return
|
|
241
|
+
navigate(S) {
|
|
242
|
+
return q(this, arguments, function* (t, {
|
|
241
243
|
historyAction: s = "push",
|
|
242
244
|
centerScroll: i,
|
|
243
245
|
offsetScroll: u,
|
|
244
|
-
revalidate:
|
|
245
|
-
keepSearchParameters:
|
|
246
|
+
revalidate: g,
|
|
247
|
+
keepSearchParameters: w,
|
|
248
|
+
submorph: L
|
|
246
249
|
} = {}) {
|
|
247
|
-
var
|
|
248
|
-
if (e(this,
|
|
250
|
+
var Et;
|
|
251
|
+
if (e(this, O).length)
|
|
249
252
|
return;
|
|
250
|
-
const
|
|
251
|
-
let { pathname:
|
|
252
|
-
if (e(this,
|
|
253
|
-
e(this,
|
|
253
|
+
const A = this.normalizePath(((Et = this.pathnameModifier) == null ? void 0 : Et.call(this, t)) || t);
|
|
254
|
+
let { pathname: m, hash: V, parameters: pt, leaf: xt } = A;
|
|
255
|
+
if (e(this, D) === m || e(this, p) === m) {
|
|
256
|
+
e(this, M) || d(this, h, ft).call(this, V || 0, {
|
|
254
257
|
centerScroll: i,
|
|
255
258
|
offsetScroll: u,
|
|
256
259
|
behavior: "smooth"
|
|
257
260
|
});
|
|
258
261
|
return;
|
|
259
262
|
}
|
|
260
|
-
|
|
261
|
-
|
|
263
|
+
a(this, D, m), e(this, f).forEach((W) => {
|
|
264
|
+
W.checkCurrent(m);
|
|
262
265
|
});
|
|
263
266
|
try {
|
|
264
|
-
let
|
|
267
|
+
let W = !0;
|
|
265
268
|
if (this.preprocessor)
|
|
266
269
|
try {
|
|
267
|
-
yield new Promise((r,
|
|
268
|
-
var
|
|
269
|
-
(
|
|
270
|
-
pathname:
|
|
270
|
+
yield new Promise((r, k) => {
|
|
271
|
+
var v;
|
|
272
|
+
(v = this.preprocessor) == null || v.call(this, {
|
|
273
|
+
pathname: m,
|
|
271
274
|
resolve: r,
|
|
272
|
-
reject:
|
|
275
|
+
reject: k
|
|
273
276
|
});
|
|
274
277
|
});
|
|
275
278
|
} catch (r) {
|
|
276
|
-
r ? console.error(r) : console.log("Route change canceled"),
|
|
279
|
+
r ? console.error(r) : console.log("Route change canceled"), W = !1;
|
|
277
280
|
}
|
|
278
|
-
if (!
|
|
279
|
-
e(this,
|
|
280
|
-
r.checkCurrent(e(this,
|
|
281
|
+
if (!W || e(this, D) !== m) {
|
|
282
|
+
e(this, f).forEach((r) => {
|
|
283
|
+
r.checkCurrent(e(this, p));
|
|
281
284
|
});
|
|
282
285
|
return;
|
|
283
286
|
}
|
|
284
|
-
const
|
|
285
|
-
pathname:
|
|
287
|
+
const ot = {
|
|
288
|
+
pathname: m
|
|
286
289
|
};
|
|
287
|
-
|
|
288
|
-
detail:
|
|
290
|
+
$(document, "morphNavigation", {
|
|
291
|
+
detail: ot
|
|
289
292
|
});
|
|
290
|
-
const
|
|
291
|
-
searchParameters:
|
|
292
|
-
revalidate:
|
|
293
|
+
const gt = yield d(this, h, it).call(this, e(this, p)), b = yield d(this, h, it).call(this, m, {
|
|
294
|
+
searchParameters: pt,
|
|
295
|
+
revalidate: g
|
|
293
296
|
});
|
|
294
|
-
if (e(this,
|
|
295
|
-
e(this,
|
|
296
|
-
r.checkCurrent(e(this,
|
|
297
|
+
if (e(this, D) !== m) {
|
|
298
|
+
e(this, f).forEach((r) => {
|
|
299
|
+
r.checkCurrent(e(this, p));
|
|
297
300
|
});
|
|
298
301
|
return;
|
|
299
302
|
}
|
|
300
|
-
|
|
301
|
-
detail:
|
|
303
|
+
gt.saveScrollState(), gt.saveDocumentState(), e(this, M) || (b.clearScrollState(), b.clearDocumentState()), b.cloneDocument(), e(this, B).textContent = b.title, document.body.appendChild(e(this, B)), $(document, "morphStart", {
|
|
304
|
+
detail: ot
|
|
302
305
|
});
|
|
303
|
-
const
|
|
304
|
-
|
|
306
|
+
const St = Array.from(document.head.children), vt = Array.from(b.document.head.children), yt = d(this, h, Nt).call(this, St, vt), Dt = d(this, h, ut).call(this, St, yt), et = d(this, h, ut).call(this, vt, yt);
|
|
307
|
+
et.forEach((r, k) => {
|
|
305
308
|
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
306
|
-
const
|
|
307
|
-
|
|
309
|
+
const v = document.createElement("script");
|
|
310
|
+
v.type = "module", v.src = r.getAttribute("src"), et[k] = v;
|
|
308
311
|
}
|
|
309
|
-
}),
|
|
312
|
+
}), et.forEach((r) => {
|
|
310
313
|
document.head.appendChild(r);
|
|
311
314
|
});
|
|
312
|
-
const
|
|
315
|
+
const at = et.filter((r) => {
|
|
313
316
|
if (r.hasAttribute("data-no-waiting"))
|
|
314
317
|
return !1;
|
|
315
|
-
if (d(this,
|
|
318
|
+
if (d(this, h, dt).call(this, r))
|
|
316
319
|
return !0;
|
|
317
320
|
});
|
|
318
|
-
e(this,
|
|
319
|
-
let
|
|
321
|
+
e(this, T).waitForHeadToLoad && at.length && (yield new Promise((r) => q(this, null, function* () {
|
|
322
|
+
let k = 0;
|
|
320
323
|
try {
|
|
321
|
-
for (var
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
|
|
324
|
+
for (var v = Pt(at), Q, R, U; Q = !(R = yield v.next()).done; Q = !1) {
|
|
325
|
+
const st = R.value;
|
|
326
|
+
st.onload = () => {
|
|
327
|
+
k++, k === at.length && r();
|
|
325
328
|
};
|
|
326
329
|
}
|
|
327
|
-
} catch (
|
|
328
|
-
|
|
330
|
+
} catch (R) {
|
|
331
|
+
U = [R];
|
|
329
332
|
} finally {
|
|
330
333
|
try {
|
|
331
|
-
|
|
334
|
+
Q && (R = v.return) && (yield R.call(v));
|
|
332
335
|
} finally {
|
|
333
|
-
if (
|
|
334
|
-
throw
|
|
336
|
+
if (U)
|
|
337
|
+
throw U[0];
|
|
335
338
|
}
|
|
336
339
|
}
|
|
337
|
-
}))), yield
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
r.hasAttribute("data-permanent") || (d(this,
|
|
340
|
+
}))), yield It(10);
|
|
341
|
+
const wt = [];
|
|
342
|
+
Dt.forEach((r) => {
|
|
343
|
+
r.hasAttribute("data-permanent") || (d(this, h, dt).call(this, r) ? wt.push(r) : r.remove());
|
|
341
344
|
});
|
|
342
|
-
const
|
|
343
|
-
e(this,
|
|
345
|
+
const Rt = d(this, h, ct).call(this, b.document.body);
|
|
346
|
+
e(this, T).morphInsideScrollContainer || d(this, h, mt).call(this, b.document), document.documentElement.setAttribute("data-current-pathname", m), document.documentElement.setAttribute("data-current-leaf", xt), At({
|
|
344
347
|
action: s,
|
|
345
|
-
pathname:
|
|
346
|
-
searchParameters:
|
|
347
|
-
hash:
|
|
348
|
-
}), e(this,
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
348
|
+
pathname: m,
|
|
349
|
+
searchParameters: pt || (w ? location.search : ""),
|
|
350
|
+
hash: V
|
|
351
|
+
}), e(this, B).remove(), a(this, _, e(this, p)), a(this, p, m), e(this, Y).forEach((r, k) => {
|
|
352
|
+
const v = Rt[k], Q = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
353
|
+
let R = [], U = [];
|
|
354
|
+
L ? L.forEach((c) => {
|
|
355
|
+
const E = r.querySelector(c), H = v.querySelector(c);
|
|
356
|
+
E && H && (U.push(E), R.push(H));
|
|
357
|
+
}) : (R.push(...v.childNodes), U.push(...r.childNodes)), U.forEach((c) => {
|
|
358
|
+
c instanceof HTMLElement && (this.destroyOldLinks(c), c.classList.add("old"));
|
|
359
|
+
}), R.forEach((c) => {
|
|
360
|
+
c instanceof HTMLElement && (this.findNewLinks(c), c.classList.add("new"));
|
|
361
|
+
}), L ? R.forEach((c, E) => {
|
|
362
|
+
var H;
|
|
363
|
+
(H = U[E].parentElement) == null || H.insertBefore(
|
|
364
|
+
c,
|
|
365
|
+
U[E]
|
|
366
|
+
);
|
|
367
|
+
}) : r.prepend(...R), zt(() => {
|
|
368
|
+
R.forEach((c) => {
|
|
369
|
+
var E;
|
|
370
|
+
c instanceof HTMLElement && ((E = c.parentElement) == null || E.style.setProperty(
|
|
371
|
+
"--new-content-height",
|
|
372
|
+
c.offsetHeight + "px"
|
|
373
|
+
), c.classList.add("in"));
|
|
367
374
|
});
|
|
368
|
-
const Dt = new Promise((g) => {
|
|
369
|
-
setTimeout(() => {
|
|
370
|
-
Lt.forEach((_) => _.remove()), j.forEach((_) => {
|
|
371
|
-
_ instanceof HTMLElement && _.classList.remove("in", "new");
|
|
372
|
-
}), F(document, "morphOldChildrenRemoved", {
|
|
373
|
-
detail: Z
|
|
374
|
-
}), g();
|
|
375
|
-
}, (parseFloat(O) || 0) * 1e3 + 10);
|
|
376
|
-
});
|
|
377
|
-
e(this, z).push(Dt);
|
|
378
|
-
} else
|
|
379
|
-
this.destroyOldLinks(r), r.innerHTML = "", r.append(...j), this.findNewLinks(r);
|
|
380
|
-
}), Q ? (w.clearScrollState(), d(this, l, ut).call(this, Q, { centerScroll: i, offsetScroll: u })) : e(this, A) ? w.restoreScrollPosition() : w.renewScrollPosition(), yield Promise.all(e(this, z)), vt.forEach((r) => r.remove()), o(this, z, []), e(this, B).forEach((r) => {
|
|
381
|
-
r.querySelectorAll("script").forEach((L) => {
|
|
382
|
-
const O = document.createElement("script");
|
|
383
|
-
O.type = "module", O.src = L.getAttribute("src"), L.replaceWith(O);
|
|
384
375
|
});
|
|
385
|
-
|
|
386
|
-
|
|
376
|
+
const st = {
|
|
377
|
+
morphElement: r,
|
|
378
|
+
pathname: m
|
|
379
|
+
};
|
|
380
|
+
$(document, "morphNewChildrenAdded", {
|
|
381
|
+
detail: st
|
|
382
|
+
});
|
|
383
|
+
const qt = new Promise((c) => {
|
|
384
|
+
setTimeout(() => {
|
|
385
|
+
U.forEach((E) => E.remove()), R.forEach((E) => {
|
|
386
|
+
var H;
|
|
387
|
+
E instanceof HTMLElement && ((H = E.parentElement) == null || H.style.removeProperty(
|
|
388
|
+
"--new-content-height"
|
|
389
|
+
), E.classList.remove("in", "new"));
|
|
390
|
+
}), $(document, "morphOldChildrenRemoved", {
|
|
391
|
+
detail: st
|
|
392
|
+
}), c();
|
|
393
|
+
}, (parseFloat(Q) || 0) * 1e3 + 10);
|
|
394
|
+
});
|
|
395
|
+
e(this, O).push(qt);
|
|
396
|
+
}), V ? (b.clearScrollState(), d(this, h, ft).call(this, V, { centerScroll: i, offsetScroll: u })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, O)), wt.forEach((r) => r.remove()), a(this, O, []), e(this, Y).forEach((r) => {
|
|
397
|
+
r.querySelectorAll("script").forEach((v) => {
|
|
398
|
+
const Q = document.createElement("script");
|
|
399
|
+
Q.type = "module", Q.src = v.getAttribute("src"), v.replaceWith(Q);
|
|
400
|
+
});
|
|
401
|
+
}), $(document, "morphComplete", {
|
|
402
|
+
detail: ot
|
|
387
403
|
}), window.dispatchEvent(new Event("resize"));
|
|
388
|
-
} catch (
|
|
389
|
-
console.error(
|
|
404
|
+
} catch (W) {
|
|
405
|
+
console.error(W);
|
|
390
406
|
}
|
|
391
|
-
|
|
407
|
+
a(this, D, void 0);
|
|
392
408
|
});
|
|
393
409
|
}
|
|
394
410
|
addLink(t) {
|
|
395
|
-
e(this,
|
|
411
|
+
e(this, f).push(new ht(t, this));
|
|
396
412
|
}
|
|
397
413
|
addLinks(t) {
|
|
398
414
|
t.forEach((s) => {
|
|
@@ -400,71 +416,71 @@ const K = class K {
|
|
|
400
416
|
});
|
|
401
417
|
}
|
|
402
418
|
removeLink(t) {
|
|
403
|
-
|
|
419
|
+
a(this, f, e(this, f).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
404
420
|
}
|
|
405
421
|
destroyOldLinks(t) {
|
|
406
|
-
|
|
422
|
+
a(this, f, e(this, f).filter((s) => t.contains(s.element) ? (s.destroy(), !1) : !0));
|
|
407
423
|
}
|
|
408
424
|
findNewLinks(t) {
|
|
409
425
|
const s = [...t.querySelectorAll("a")].filter(
|
|
410
|
-
e(this,
|
|
426
|
+
e(this, tt)
|
|
411
427
|
);
|
|
412
|
-
e(this,
|
|
413
|
-
...s.map((i) => new
|
|
428
|
+
e(this, f).push(
|
|
429
|
+
...s.map((i) => new ht(i, this))
|
|
414
430
|
);
|
|
415
431
|
}
|
|
416
432
|
findLinks() {
|
|
417
433
|
const t = [
|
|
418
434
|
...document.documentElement.querySelectorAll("a")
|
|
419
|
-
].filter(e(this,
|
|
420
|
-
e(this,
|
|
435
|
+
].filter(e(this, tt));
|
|
436
|
+
e(this, f).forEach((s) => s.destroy()), a(this, f, t.map((s) => new ht(s, this)));
|
|
421
437
|
}
|
|
422
438
|
};
|
|
423
|
-
|
|
424
|
-
return
|
|
425
|
-
let i = e(this,
|
|
426
|
-
return (!i || s != null && s.revalidate) && (i = yield d(this,
|
|
439
|
+
T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D = new WeakMap(), p = new WeakMap(), _ = new WeakMap(), O = new WeakMap(), M = new WeakMap(), P = new WeakMap(), G = new WeakMap(), B = new WeakMap(), tt = new WeakMap(), h = new WeakSet(), it = function(t, s) {
|
|
440
|
+
return q(this, null, function* () {
|
|
441
|
+
let i = e(this, G).get(t);
|
|
442
|
+
return (!i || s != null && s.revalidate) && (i = yield d(this, h, Ht).call(this, t, s == null ? void 0 : s.searchParameters)), i;
|
|
427
443
|
});
|
|
428
|
-
},
|
|
429
|
-
return
|
|
444
|
+
}, Ht = function(t, s) {
|
|
445
|
+
return q(this, null, function* () {
|
|
430
446
|
const u = yield (yield fetch(
|
|
431
447
|
`${t}${s ? "?" + s : ""}`
|
|
432
|
-
)).text(),
|
|
433
|
-
return e(this,
|
|
448
|
+
)).text(), g = e(this, rt).parseFromString(u, "text/html"), w = new kt(this, t, g);
|
|
449
|
+
return e(this, G).set(t, w), w;
|
|
434
450
|
});
|
|
435
|
-
},
|
|
451
|
+
}, ct = function(t) {
|
|
436
452
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
437
453
|
return s.length ? s : [t];
|
|
438
|
-
},
|
|
454
|
+
}, Nt = function(t, s) {
|
|
439
455
|
return t.filter(
|
|
440
456
|
(i) => s.find(
|
|
441
457
|
(u) => u.outerHTML === i.outerHTML
|
|
442
458
|
)
|
|
443
459
|
);
|
|
444
|
-
},
|
|
460
|
+
}, ut = function(t, s) {
|
|
445
461
|
return t.filter(
|
|
446
462
|
(i) => !s.find(
|
|
447
463
|
(u) => u.outerHTML === i.outerHTML
|
|
448
464
|
)
|
|
449
465
|
);
|
|
450
|
-
},
|
|
466
|
+
}, dt = function(t) {
|
|
451
467
|
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
452
|
-
},
|
|
468
|
+
}, mt = function(t) {
|
|
453
469
|
var s, i;
|
|
454
|
-
(s = e(this,
|
|
470
|
+
(s = e(this, P)) == null || s.removeEventListener(
|
|
455
471
|
"scroll",
|
|
456
|
-
e(this,
|
|
457
|
-
),
|
|
458
|
-
},
|
|
472
|
+
e(this, J)
|
|
473
|
+
), a(this, P, t.querySelector(e(this, T).scrollSelector) || t.documentElement), (i = e(this, P)) == null || i.addEventListener("scroll", e(this, J)), e(this, J).call(this);
|
|
474
|
+
}, ft = function(t, s) {
|
|
459
475
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
460
|
-
(typeof i == "number" || i) &&
|
|
461
|
-
scrollElement: e(this,
|
|
476
|
+
(typeof i == "number" || i) && Ft(i, {
|
|
477
|
+
scrollElement: e(this, P),
|
|
462
478
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
463
479
|
center: s == null ? void 0 : s.centerScroll,
|
|
464
480
|
offset: s == null ? void 0 : s.offsetScroll
|
|
465
481
|
});
|
|
466
|
-
},
|
|
467
|
-
let
|
|
482
|
+
}, nt = new WeakMap(), J = new WeakMap(), X.instance = null;
|
|
483
|
+
let Ct = X;
|
|
468
484
|
export {
|
|
469
|
-
|
|
485
|
+
Ct as Morph
|
|
470
486
|
};
|