aptechka 0.60.0 → 0.60.1
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 +1 -0
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +78 -76
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface MorphScrollDetail {
|
|
|
36
36
|
top: number;
|
|
37
37
|
}
|
|
38
38
|
export interface MorphEvents {
|
|
39
|
+
morphNavigation: CustomEvent<MorphTransitionEntry>;
|
|
39
40
|
morphStart: CustomEvent<MorphTransitionEntry>;
|
|
40
41
|
morphComplete: CustomEvent<MorphTransitionEntry>;
|
|
41
42
|
morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
|
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 nt=(n,t,s)=>t.has(n)||bt("Cannot "+s);var e=(n,t,s)=>(nt(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)=>(nt(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(nt(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"),$=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,F;class at{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,F,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,P).prefetch(e(this,x),t),e(this,l).removeEventListener("pointerenter",e(this,F))});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,F))}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,F)),e(this,l).classList.remove("current")}}P=new WeakMap,l=new WeakMap,x=new WeakMap,Y=new WeakMap,F=new WeakMap;var C,V,v,q,D,T;class At{constructor(t,s,i){a(this,C);a(this,V);a(this,v,{x:0,y:0});a(this,q);a(this,D,null);a(this,T,null);o(this,C,t),o(this,V,s),o(this,q,i.cloneNode(!0))}get pathname(){return e(this,V)}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,V)}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,V=new WeakMap,v=new WeakMap,q=new WeakMap,D=new WeakMap,T=new WeakMap;var k,B,m,st,M,f,G,R,A,w,W,z,J,c,et,Mt,ct,Ht,lt,ht,ut,dt,it,j;const K=class K{constructor(t){a(this,c);a(this,k,null);a(this,B,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,W,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,j,()=>{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),$.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,B,d(this,c,ct).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);o(this,f,s.pathname),e(this,W).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,ut).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 ft;if(e(this,R).length)return;const p=this.normalizePath(((ft=this.pathnameModifier)==null?void 0:ft.call(this,t))||t);let{pathname:h,hash:Q,parameters:mt,leaf:Nt}=p;if(e(this,M)===h||e(this,f)===h){e(this,A)||d(this,c,dt).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 pt=yield d(this,c,et).call(this,e(this,f)),y=yield d(this,c,et).call(this,h,{searchParameters:mt,revalidate:E});if(e(this,M)!==h){e(this,m).forEach(r=>{r.checkCurrent(e(this,f))});return}pt.saveScrollState(),pt.saveDocumentState(),e(this,A)||(y.clearScrollState(),y.clearDocumentState()),y.cloneDocument(),e(this,z).textContent=y.title,document.body.appendChild(e(this,z));const Et={pathname:h};$.dispatchEvent(document,"morphStart",{detail:Et});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,lt).call(this,gt,St),X=d(this,c,lt).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 rt=X.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ht).call(this,r))return!0});e(this,k).waitForHeadToLoad&&rt.length&&(yield new Promise(r=>N(this,null,function*(){let b=0;try{for(var S=Pt(rt),O,U,yt;O=!(U=yield S.next()).done;O=!1){const Z=U.value;Z.onload=()=>{b++,b===rt.length&&r()}}}catch(U){yt=[U]}finally{try{O&&(U=S.return)&&(yield U.call(S))}finally{if(yt)throw yt[0]}}}))),yield kt.wait(10);const Lt=[];xt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ht).call(this,r)?Lt.push(r):r.remove())});const qt=d(this,c,ct).call(this,y.document.body);e(this,k).morphInsideScrollContainer||d(this,c,ut).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:mt||(L?location.search:""),hash:Q}),e(this,z).remove(),o(this,G,e(this,f)),o(this,f,h),e(this,B).forEach((r,b)=>{const S=qt[b],O=getComputedStyle(r).getPropertyValue("--morph-duration"),U=[...S.childNodes];if(O){const yt=[...r.childNodes];yt.forEach(g=>{g instanceof HTMLElement&&(this.destroyOldLinks(g),g.classList.add("old"))}),U.forEach(g=>{g instanceof HTMLElement&&(this.findNewLinks(g),g.classList.add("new"))}),r.prepend(...U),Rt.requestIdleCallback(()=>{U.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Z={morphElement:r,pathname:h};$.dispatchEvent(document,"morphNewChildrenAdded",{detail:Z});const Dt=new Promise(g=>{setTimeout(()=>{yt.forEach(_=>_.remove()),U.forEach(_=>{_ instanceof HTMLElement&&_.classList.remove("in","new")}),$.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Z}),g()},(parseFloat(O)||0)*1e3+10)});e(this,R).push(Dt)}else this.destroyOldLinks(r),r.innerHTML="",r.append(...U),this.findNewLinks(r)}),Q?(y.clearScrollState(),d(this,c,dt).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,B).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const O=document.createElement("script");O.type="module",O.src=S.getAttribute("src"),S.replaceWith(O)})}),$.dispatchEvent(document,"morphComplete",{detail:Et}),window.dispatchEvent(new Event("resize"))}catch(I){console.error(I)}o(this,M,void 0)})}addLink(t){e(this,m).push(new at(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 at(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 at(s,this)))}};k=new WeakMap,B=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,W=new WeakMap,z=new WeakMap,J=new WeakMap,c=new WeakSet,et=function(t,s){return N(this,null,function*(){let i=e(this,W).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,W).set(t,L),L})},ct=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))},lt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ht=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},ut=function(t){var s,i;(s=e(this,w))==null||s.removeEventListener("scroll",e(this,j)),o(this,w,t.querySelector(e(this,k).scrollSelector)||t.documentElement),(i=e(this,w))==null||i.addEventListener("scroll",e(this,j)),e(this,j).call(this)},dt=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,j=new WeakMap,K.instance=null;let ot=K;exports.Morph=ot;
|
|
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;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var St = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), wt = (n) => {
|
|
2
2
|
throw TypeError(n);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (n, t, s) => (
|
|
4
|
+
var nt = (n, t, s) => t.has(n) || wt("Cannot " + s);
|
|
5
|
+
var e = (n, t, s) => (nt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), a = (n, t, s) => t.has(n) ? wt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), o = (n, t, s, i) => (nt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (nt(n, t, "access private method"), s);
|
|
6
6
|
var N = (n, t, s) => new Promise((i, u) => {
|
|
7
7
|
var E = (p) => {
|
|
8
8
|
try {
|
|
@@ -21,7 +21,7 @@ var N = (n, t, s) => new Promise((i, u) => {
|
|
|
21
21
|
});
|
|
22
22
|
var yt = (n, t, s) => (t = n[St("asyncIterator")]) ? t.call(n) : (n = n[St("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (E) => new Promise((S, M, p) => (E = u.call(n, E), p = E.done, Promise.resolve(E.value).then((h) => S({ value: h, done: p }), M)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as At } from "../index-euf5anj6.js";
|
|
24
|
-
import { d as
|
|
24
|
+
import { d as F } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as Rt } from "../polyfills-DJrTJQky.js";
|
|
26
26
|
import { w as zt, s as It } from "../scroll-Benkuq-t.js";
|
|
27
27
|
import { n as qt, c as bt, s as Ot } from "../url-B6BNcw6_.js";
|
|
@@ -38,8 +38,8 @@ class Ct extends HTMLElement {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
At && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Ct);
|
|
41
|
-
var k, c, x, Y,
|
|
42
|
-
class
|
|
41
|
+
var k, c, x, Y, V;
|
|
42
|
+
class at {
|
|
43
43
|
constructor(t, s) {
|
|
44
44
|
a(this, k);
|
|
45
45
|
a(this, c);
|
|
@@ -62,11 +62,11 @@ class nt {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
-
a(this,
|
|
65
|
+
a(this, V, () => {
|
|
66
66
|
const t = e(this, c).hasAttribute("data-revalidate");
|
|
67
|
-
e(this, k).prefetch(e(this, x), t), e(this, c).removeEventListener("pointerenter", e(this,
|
|
67
|
+
e(this, k).prefetch(e(this, x), t), e(this, c).removeEventListener("pointerenter", e(this, V));
|
|
68
68
|
});
|
|
69
|
-
o(this, k, s), o(this, c, t), o(this, x, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, Y)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this,
|
|
69
|
+
o(this, k, s), o(this, c, t), o(this, x, e(this, c).getAttribute("href") || "/"), e(this, c).addEventListener("click", e(this, Y)), this.checkCurrent(location.pathname), e(this, c).hasAttribute("data-prefetch") && e(this, c).addEventListener("pointerenter", e(this, V));
|
|
70
70
|
}
|
|
71
71
|
get element() {
|
|
72
72
|
return e(this, c);
|
|
@@ -76,23 +76,23 @@ class nt {
|
|
|
76
76
|
e(this, c).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, c).classList.add("current") : i.pathname === s.pathname ? e(this, c).classList.add("current") : e(this, c).classList.remove("current");
|
|
77
77
|
}
|
|
78
78
|
destroy() {
|
|
79
|
-
e(this, c).removeEventListener("click", e(this, Y)), e(this, c).removeEventListener("pointerenter", e(this,
|
|
79
|
+
e(this, c).removeEventListener("click", e(this, Y)), e(this, c).removeEventListener("pointerenter", e(this, V)), e(this, c).classList.remove("current");
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
k = new WeakMap(), c = new WeakMap(), x = new WeakMap(), Y = new WeakMap(),
|
|
83
|
-
var C,
|
|
82
|
+
k = new WeakMap(), c = new WeakMap(), x = new WeakMap(), Y = new WeakMap(), V = new WeakMap();
|
|
83
|
+
var C, W, v, D, R, T;
|
|
84
84
|
class kt {
|
|
85
85
|
constructor(t, s, i) {
|
|
86
86
|
a(this, C);
|
|
87
|
-
a(this,
|
|
87
|
+
a(this, W);
|
|
88
88
|
a(this, v, { x: 0, y: 0 });
|
|
89
89
|
a(this, D);
|
|
90
90
|
a(this, R, null);
|
|
91
91
|
a(this, T, null);
|
|
92
|
-
o(this, C, t), o(this,
|
|
92
|
+
o(this, C, t), o(this, W, s), o(this, D, i.cloneNode(!0));
|
|
93
93
|
}
|
|
94
94
|
get pathname() {
|
|
95
|
-
return e(this,
|
|
95
|
+
return e(this, W);
|
|
96
96
|
}
|
|
97
97
|
get scrollState() {
|
|
98
98
|
return e(this, v);
|
|
@@ -109,7 +109,7 @@ class kt {
|
|
|
109
109
|
t = e(this, T).title;
|
|
110
110
|
else {
|
|
111
111
|
const s = e(this, T).querySelector("h1");
|
|
112
|
-
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this,
|
|
112
|
+
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, W);
|
|
113
113
|
}
|
|
114
114
|
return t;
|
|
115
115
|
}
|
|
@@ -143,13 +143,13 @@ class kt {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
C = new WeakMap(),
|
|
147
|
-
var P,
|
|
146
|
+
C = new WeakMap(), W = new WeakMap(), v = new WeakMap(), D = new WeakMap(), R = new WeakMap(), T = new WeakMap();
|
|
147
|
+
var P, B, m, et, H, f, G, z, A, y, U, I, J, l, tt, Tt, ot, Ht, lt, ct, ht, ut, st, $;
|
|
148
148
|
const K = class K {
|
|
149
149
|
constructor(t) {
|
|
150
150
|
a(this, l);
|
|
151
151
|
a(this, P, null);
|
|
152
|
-
a(this,
|
|
152
|
+
a(this, B, null);
|
|
153
153
|
a(this, m, []);
|
|
154
154
|
a(this, et, new DOMParser());
|
|
155
155
|
a(this, H);
|
|
@@ -158,7 +158,7 @@ const K = class K {
|
|
|
158
158
|
a(this, z, []);
|
|
159
159
|
a(this, A, !1);
|
|
160
160
|
a(this, y, null);
|
|
161
|
-
a(this,
|
|
161
|
+
a(this, U, /* @__PURE__ */ new Map());
|
|
162
162
|
a(this, I, null);
|
|
163
163
|
a(this, J, (t) => {
|
|
164
164
|
var s;
|
|
@@ -168,9 +168,9 @@ const K = class K {
|
|
|
168
168
|
var s;
|
|
169
169
|
(s = t.state) != null && s.path && (t.preventDefault(), o(this, A, !0), yield this.navigate(t.state.path, { historyAction: "none" }), o(this, A, !1));
|
|
170
170
|
}));
|
|
171
|
-
a(this,
|
|
171
|
+
a(this, $, () => {
|
|
172
172
|
const t = e(this, y).scrollTop, s = e(this, y).scrollLeft;
|
|
173
|
-
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0),
|
|
173
|
+
document.documentElement.classList.toggle("top-scrolled", t > 0), document.documentElement.classList.toggle("left-scrolled", s > 0), F(document, "morphScroll", {
|
|
174
174
|
detail: {
|
|
175
175
|
left: s,
|
|
176
176
|
top: t
|
|
@@ -185,11 +185,11 @@ const K = class K {
|
|
|
185
185
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
186
186
|
scrollSelector: (t == null ? void 0 : t.scrollSelector) || "body",
|
|
187
187
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
188
|
-
}), o(this,
|
|
188
|
+
}), o(this, B, d(this, l, ot).call(this, document.body));
|
|
189
189
|
const s = this.normalizePath(
|
|
190
190
|
location.pathname + location.hash
|
|
191
191
|
);
|
|
192
|
-
o(this, f, s.pathname), e(this,
|
|
192
|
+
o(this, f, s.pathname), e(this, U).set(
|
|
193
193
|
e(this, f),
|
|
194
194
|
new kt(this, e(this, f), document)
|
|
195
195
|
), document.documentElement.setAttribute(
|
|
@@ -203,7 +203,7 @@ const K = class K {
|
|
|
203
203
|
pathname: e(this, f),
|
|
204
204
|
searchParameters: s.parameters || location.search,
|
|
205
205
|
hash: s.hash
|
|
206
|
-
}), o(this, I, new Ct()), d(this, l,
|
|
206
|
+
}), o(this, I, new Ct()), d(this, l, ht).call(this, document);
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
get currentPathname() {
|
|
@@ -244,13 +244,13 @@ const K = class K {
|
|
|
244
244
|
revalidate: E,
|
|
245
245
|
keepSearchParameters: S
|
|
246
246
|
} = {}) {
|
|
247
|
-
var
|
|
247
|
+
var mt;
|
|
248
248
|
if (e(this, z).length)
|
|
249
249
|
return;
|
|
250
|
-
const p = this.normalizePath(((
|
|
251
|
-
let { pathname: h, hash: Q, parameters:
|
|
250
|
+
const p = this.normalizePath(((mt = this.pathnameModifier) == null ? void 0 : mt.call(this, t)) || t);
|
|
251
|
+
let { pathname: h, hash: Q, parameters: dt, leaf: Mt } = p;
|
|
252
252
|
if (e(this, H) === h || e(this, f) === h) {
|
|
253
|
-
e(this, A) || d(this, l,
|
|
253
|
+
e(this, A) || d(this, l, ut).call(this, Q || 0, {
|
|
254
254
|
centerScroll: i,
|
|
255
255
|
offsetScroll: u,
|
|
256
256
|
behavior: "smooth"
|
|
@@ -281,8 +281,14 @@ const K = class K {
|
|
|
281
281
|
});
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
const
|
|
285
|
-
|
|
284
|
+
const it = {
|
|
285
|
+
pathname: h
|
|
286
|
+
};
|
|
287
|
+
F(document, "morphNavigation", {
|
|
288
|
+
detail: it
|
|
289
|
+
});
|
|
290
|
+
const ft = yield d(this, l, tt).call(this, e(this, f)), w = yield d(this, l, tt).call(this, h, {
|
|
291
|
+
searchParameters: dt,
|
|
286
292
|
revalidate: E
|
|
287
293
|
});
|
|
288
294
|
if (e(this, H) !== h) {
|
|
@@ -291,14 +297,10 @@ const K = class K {
|
|
|
291
297
|
});
|
|
292
298
|
return;
|
|
293
299
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
pathname: h
|
|
297
|
-
};
|
|
298
|
-
j(document, "morphStart", {
|
|
299
|
-
detail: ft
|
|
300
|
+
ft.saveScrollState(), ft.saveDocumentState(), e(this, A) || (w.clearScrollState(), w.clearDocumentState()), w.cloneDocument(), e(this, I).textContent = w.title, document.body.appendChild(e(this, I)), F(document, "morphStart", {
|
|
301
|
+
detail: it
|
|
300
302
|
});
|
|
301
|
-
const pt = Array.from(document.head.children), Et = Array.from(w.document.head.children), gt = d(this, l, Ht).call(this, pt, Et), Nt = d(this, l,
|
|
303
|
+
const pt = Array.from(document.head.children), Et = Array.from(w.document.head.children), gt = d(this, l, Ht).call(this, pt, Et), Nt = d(this, l, lt).call(this, pt, gt), X = d(this, l, lt).call(this, Et, gt);
|
|
302
304
|
X.forEach((r, b) => {
|
|
303
305
|
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
304
306
|
const L = document.createElement("script");
|
|
@@ -307,26 +309,26 @@ const K = class K {
|
|
|
307
309
|
}), X.forEach((r) => {
|
|
308
310
|
document.head.appendChild(r);
|
|
309
311
|
});
|
|
310
|
-
const
|
|
312
|
+
const rt = X.filter((r) => {
|
|
311
313
|
if (r.hasAttribute("data-no-waiting"))
|
|
312
314
|
return !1;
|
|
313
|
-
if (d(this, l,
|
|
315
|
+
if (d(this, l, ct).call(this, r))
|
|
314
316
|
return !0;
|
|
315
317
|
});
|
|
316
|
-
e(this, P).waitForHeadToLoad &&
|
|
318
|
+
e(this, P).waitForHeadToLoad && rt.length && (yield new Promise((r) => N(this, null, function* () {
|
|
317
319
|
let b = 0;
|
|
318
320
|
try {
|
|
319
|
-
for (var L = yt(
|
|
320
|
-
const Z =
|
|
321
|
+
for (var L = yt(rt), O, j, Lt; O = !(j = yield L.next()).done; O = !1) {
|
|
322
|
+
const Z = j.value;
|
|
321
323
|
Z.onload = () => {
|
|
322
|
-
b++, b ===
|
|
324
|
+
b++, b === rt.length && r();
|
|
323
325
|
};
|
|
324
326
|
}
|
|
325
|
-
} catch (
|
|
326
|
-
Lt = [
|
|
327
|
+
} catch (j) {
|
|
328
|
+
Lt = [j];
|
|
327
329
|
} finally {
|
|
328
330
|
try {
|
|
329
|
-
O && (
|
|
331
|
+
O && (j = L.return) && (yield j.call(L));
|
|
330
332
|
} finally {
|
|
331
333
|
if (Lt)
|
|
332
334
|
throw Lt[0];
|
|
@@ -335,24 +337,24 @@ const K = class K {
|
|
|
335
337
|
}))), yield zt(10);
|
|
336
338
|
const vt = [];
|
|
337
339
|
Nt.forEach((r) => {
|
|
338
|
-
r.hasAttribute("data-permanent") || (d(this, l,
|
|
340
|
+
r.hasAttribute("data-permanent") || (d(this, l, ct).call(this, r) ? vt.push(r) : r.remove());
|
|
339
341
|
});
|
|
340
|
-
const xt = d(this, l,
|
|
341
|
-
e(this, P).morphInsideScrollContainer || d(this, l,
|
|
342
|
+
const xt = d(this, l, ot).call(this, w.document.body);
|
|
343
|
+
e(this, P).morphInsideScrollContainer || d(this, l, ht).call(this, w.document), document.documentElement.setAttribute("data-current-pathname", h), document.documentElement.setAttribute("data-current-leaf", Mt), bt({
|
|
342
344
|
action: s,
|
|
343
345
|
pathname: h,
|
|
344
|
-
searchParameters:
|
|
346
|
+
searchParameters: dt || (S ? location.search : ""),
|
|
345
347
|
hash: Q
|
|
346
|
-
}), e(this, I).remove(), o(this, G, e(this, f)), o(this, f, h), e(this,
|
|
347
|
-
const L = xt[b], O = getComputedStyle(r).getPropertyValue("--morph-duration"),
|
|
348
|
+
}), e(this, I).remove(), o(this, G, e(this, f)), o(this, f, h), e(this, B).forEach((r, b) => {
|
|
349
|
+
const L = xt[b], O = getComputedStyle(r).getPropertyValue("--morph-duration"), j = [...L.childNodes];
|
|
348
350
|
if (O) {
|
|
349
351
|
const Lt = [...r.childNodes];
|
|
350
352
|
Lt.forEach((g) => {
|
|
351
353
|
g instanceof HTMLElement && (this.destroyOldLinks(g), g.classList.add("old"));
|
|
352
|
-
}),
|
|
354
|
+
}), j.forEach((g) => {
|
|
353
355
|
g instanceof HTMLElement && (this.findNewLinks(g), g.classList.add("new"));
|
|
354
|
-
}), r.prepend(
|
|
355
|
-
|
|
356
|
+
}), r.prepend(...j), Rt(() => {
|
|
357
|
+
j.forEach((g) => {
|
|
356
358
|
g instanceof HTMLElement && g.classList.add("in");
|
|
357
359
|
});
|
|
358
360
|
});
|
|
@@ -360,28 +362,28 @@ const K = class K {
|
|
|
360
362
|
morphElement: r,
|
|
361
363
|
pathname: h
|
|
362
364
|
};
|
|
363
|
-
|
|
365
|
+
F(document, "morphNewChildrenAdded", {
|
|
364
366
|
detail: Z
|
|
365
367
|
});
|
|
366
368
|
const Dt = new Promise((g) => {
|
|
367
369
|
setTimeout(() => {
|
|
368
|
-
Lt.forEach((_) => _.remove()),
|
|
370
|
+
Lt.forEach((_) => _.remove()), j.forEach((_) => {
|
|
369
371
|
_ instanceof HTMLElement && _.classList.remove("in", "new");
|
|
370
|
-
}),
|
|
372
|
+
}), F(document, "morphOldChildrenRemoved", {
|
|
371
373
|
detail: Z
|
|
372
374
|
}), g();
|
|
373
375
|
}, (parseFloat(O) || 0) * 1e3 + 10);
|
|
374
376
|
});
|
|
375
377
|
e(this, z).push(Dt);
|
|
376
378
|
} else
|
|
377
|
-
this.destroyOldLinks(r), r.innerHTML = "", r.append(
|
|
378
|
-
}), Q ? (w.clearScrollState(), d(this, l,
|
|
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) => {
|
|
379
381
|
r.querySelectorAll("script").forEach((L) => {
|
|
380
382
|
const O = document.createElement("script");
|
|
381
383
|
O.type = "module", O.src = L.getAttribute("src"), L.replaceWith(O);
|
|
382
384
|
});
|
|
383
|
-
}),
|
|
384
|
-
detail:
|
|
385
|
+
}), F(document, "morphComplete", {
|
|
386
|
+
detail: it
|
|
385
387
|
}), window.dispatchEvent(new Event("resize"));
|
|
386
388
|
} catch (q) {
|
|
387
389
|
console.error(q);
|
|
@@ -390,7 +392,7 @@ const K = class K {
|
|
|
390
392
|
});
|
|
391
393
|
}
|
|
392
394
|
addLink(t) {
|
|
393
|
-
e(this, m).push(new
|
|
395
|
+
e(this, m).push(new at(t, this));
|
|
394
396
|
}
|
|
395
397
|
addLinks(t) {
|
|
396
398
|
t.forEach((s) => {
|
|
@@ -408,19 +410,19 @@ const K = class K {
|
|
|
408
410
|
e(this, J)
|
|
409
411
|
);
|
|
410
412
|
e(this, m).push(
|
|
411
|
-
...s.map((i) => new
|
|
413
|
+
...s.map((i) => new at(i, this))
|
|
412
414
|
);
|
|
413
415
|
}
|
|
414
416
|
findLinks() {
|
|
415
417
|
const t = [
|
|
416
418
|
...document.documentElement.querySelectorAll("a")
|
|
417
419
|
].filter(e(this, J));
|
|
418
|
-
e(this, m).forEach((s) => s.destroy()), o(this, m, t.map((s) => new
|
|
420
|
+
e(this, m).forEach((s) => s.destroy()), o(this, m, t.map((s) => new at(s, this)));
|
|
419
421
|
}
|
|
420
422
|
};
|
|
421
|
-
P = new WeakMap(),
|
|
423
|
+
P = new WeakMap(), B = new WeakMap(), m = new WeakMap(), et = new WeakMap(), H = new WeakMap(), f = new WeakMap(), G = new WeakMap(), z = new WeakMap(), A = new WeakMap(), y = new WeakMap(), U = new WeakMap(), I = new WeakMap(), J = new WeakMap(), l = new WeakSet(), tt = function(t, s) {
|
|
422
424
|
return N(this, null, function* () {
|
|
423
|
-
let i = e(this,
|
|
425
|
+
let i = e(this, U).get(t);
|
|
424
426
|
return (!i || s != null && s.revalidate) && (i = yield d(this, l, Tt).call(this, t, s == null ? void 0 : s.searchParameters)), i;
|
|
425
427
|
});
|
|
426
428
|
}, Tt = function(t, s) {
|
|
@@ -428,9 +430,9 @@ P = new WeakMap(), W = new WeakMap(), m = new WeakMap(), et = new WeakMap(), H =
|
|
|
428
430
|
const u = yield (yield fetch(
|
|
429
431
|
`${t}${s ? "?" + s : ""}`
|
|
430
432
|
)).text(), E = e(this, et).parseFromString(u, "text/html"), S = new kt(this, t, E);
|
|
431
|
-
return e(this,
|
|
433
|
+
return e(this, U).set(t, S), S;
|
|
432
434
|
});
|
|
433
|
-
},
|
|
435
|
+
}, ot = function(t) {
|
|
434
436
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
435
437
|
return s.length ? s : [t];
|
|
436
438
|
}, Ht = function(t, s) {
|
|
@@ -439,21 +441,21 @@ P = new WeakMap(), W = new WeakMap(), m = new WeakMap(), et = new WeakMap(), H =
|
|
|
439
441
|
(u) => u.outerHTML === i.outerHTML
|
|
440
442
|
)
|
|
441
443
|
);
|
|
442
|
-
},
|
|
444
|
+
}, lt = function(t, s) {
|
|
443
445
|
return t.filter(
|
|
444
446
|
(i) => !s.find(
|
|
445
447
|
(u) => u.outerHTML === i.outerHTML
|
|
446
448
|
)
|
|
447
449
|
);
|
|
448
|
-
}, lt = function(t) {
|
|
449
|
-
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
450
450
|
}, ct = function(t) {
|
|
451
|
+
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
452
|
+
}, ht = function(t) {
|
|
451
453
|
var s, i;
|
|
452
454
|
(s = e(this, y)) == null || s.removeEventListener(
|
|
453
455
|
"scroll",
|
|
454
|
-
e(this,
|
|
455
|
-
), o(this, y, t.querySelector(e(this, P).scrollSelector) || t.documentElement), (i = e(this, y)) == null || i.addEventListener("scroll", e(this,
|
|
456
|
-
},
|
|
456
|
+
e(this, $)
|
|
457
|
+
), o(this, y, t.querySelector(e(this, P).scrollSelector) || t.documentElement), (i = e(this, y)) == null || i.addEventListener("scroll", e(this, $)), e(this, $).call(this);
|
|
458
|
+
}, ut = function(t, s) {
|
|
457
459
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
458
460
|
(typeof i == "number" || i) && It(i, {
|
|
459
461
|
scrollElement: e(this, y),
|
|
@@ -461,7 +463,7 @@ P = new WeakMap(), W = new WeakMap(), m = new WeakMap(), et = new WeakMap(), H =
|
|
|
461
463
|
center: s == null ? void 0 : s.centerScroll,
|
|
462
464
|
offset: s == null ? void 0 : s.offsetScroll
|
|
463
465
|
});
|
|
464
|
-
}, st = new WeakMap(),
|
|
466
|
+
}, st = new WeakMap(), $ = new WeakMap(), K.instance = null;
|
|
465
467
|
let Pt = K;
|
|
466
468
|
export {
|
|
467
469
|
Pt as Morph
|