aptechka 0.45.1 → 0.45.2
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/index.cjs +1 -1
- package/lib/morph/index.js +21 -21
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ft=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),pt=i=>{throw TypeError(i)};var $=(i,t,s)=>t.has(i)||pt("Cannot "+s);var e=(i,t,s)=>($(i,t,"read from private field"),s?s.call(i):t.get(i)),o=(i,t,s)=>t.has(i)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),a=(i,t,s,r)=>($(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),d=(i,t,s)=>($(i,t,"access private method"),s);var M=(i,t,s)=>new Promise((r,u)=>{var m=l=>{try{A(s.next(l))}catch(g){u(g)}},V=l=>{try{A(s.throw(l))}catch(g){u(g)}},A=l=>l.done?r(l.value):Promise.resolve(l.value).then(m,V);A((s=s.apply(i,t)).next())});var Et=(i,t,s)=>(t=i[ft("asyncIterator")])?t.call(i):(i=i[ft("iterator")](),t={},s=(r,u)=>(u=i[r])&&(t[r]=m=>new Promise((V,A,l)=>(m=u.call(i,m),l=m.done,Promise.resolve(m.value).then(g=>V({value:g,done:l}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Tt=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DPDSZypW.cjs"),Q=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class yt 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,r]of Object.entries(t))this.setAttribute(s,r)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",yt);var R,h,T,O,q;class gt{constructor(t,s){o(this,R);o(this,h);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,h).getAttribute("data-history-action")||"push",r=e(this,h).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),m=u?Ht.cssValueParser.parse(u):void 0,V=e(this,h).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:r,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,h).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,h,t),a(this,T,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,O));const r=s.normalizePath(e(this,T)),u=s.normalizePath(location.pathname);e(this,h).hasAttribute("data-include")&&u.pathname.includes(r.pathname)?e(this,h).classList.add("current"):r.pathname===u.pathname&&e(this,h).classList.add("current"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,q))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,O)),e(this,h).removeEventListener("pointerenter",e(this,q)),e(this,h).classList.remove("current")}}R=new WeakMap,h=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,w;class vt{constructor(t,s,r){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,w,null);a(this,C,t),a(this,z,s),a(this,H,r.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,w)}cloneDocument(){a(this,w,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,w).title)t=e(this,w).title;else{const s=e(this,w).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,k,null)}saveScrollState(){e(this,H).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,C).scrollElement.scrollLeft,e(this,p).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,H).documentElement.hasAttribute("data-no-page-restoration")?a(this,k,null):a(this,k,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}C=new WeakMap,z=new WeakMap,p=new WeakMap,H=new WeakMap,k=new WeakMap,w=new WeakMap;var b,W,v,U,P,f,j,x,N,F,I,D,c,tt,et,st,Lt,it,nt,rt,X;class kt{constructor(t){o(this,c);o(this,b,null);o(this,W,null);o(this,v,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,x,[]);o(this,N,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,N,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,N,!1))}));if(St.isBrowser){a(this,b,{base:Q.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"}),a(this,W,d(this,c,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,I).set(e(this,f),new vt(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,X)),Q.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters,hash:s.hash}),a(this,D,new yt),d(this,c,rt).call(this)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,v)}get scrollElement(){return e(this,F)}normalizePath(t){return Q.splitPath(t,{base:e(this,b).base,trailingSlash:e(this,b).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,c,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:r,offsetScroll:u,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:l,hash:g,parameters:wt,leaf:bt}=A;if(!(e(this,P)===l||e(this,f)===l)){a(this,P,l);try{let _=!0;if(this.preprocessor)try{yield new Promise((n,y)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:n,reject:y})})}catch(n){n?console.error(n):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==l)return;const ot=yield d(this,c,tt).call(this,e(this,f)),S=yield d(this,c,tt).call(this,l,m);if(e(this,P)!==l)return;ot.saveScrollState(),ot.saveDocumentState(),e(this,N)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),e(this,D).textContent=S.title,document.body.appendChild(e(this,D));const at={pathname:l};J.dispatchEvent(document,"morphStart",{detail:at});const lt=Array.from(document.head.children),ct=Array.from(S.document.head.children),ht=d(this,c,Lt).call(this,lt,ct),Pt=d(this,c,it).call(this,lt,ht),K=d(this,c,it).call(this,ct,ht);K.forEach((n,y)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=n.getAttribute("src"),K[y]=L}}),K.forEach(n=>{document.head.appendChild(n)});const Z=K.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,c,nt).call(this,n))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(n=>M(this,null,function*(){let y=0;try{for(var L=Et(Z),dt,B,mt;dt=!(B=yield L.next()).done;dt=!1){const Y=B.value;Y.onload=()=>{y++,y===Z.length&&n()}}}catch(B){mt=[B]}finally{try{dt&&(B=L.return)&&(yield B.call(L))}finally{if(mt)throw mt[0]}}})));const ut=[];Pt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,c,nt).call(this,n)?ut.push(n):n.remove())});const At=d(this,c,st).call(this,S.document.body);if(e(this,W).forEach((n,y)=>{const L=At[y],dt=getComputedStyle(n).getPropertyValue("--morph-duration"),B=[...L.childNodes];if(dt){const mt=[...n.childNodes];mt.forEach(E=>{E instanceof HTMLElement&&E.classList.add("old")}),B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("new")}),n.prepend(...B),Tt.requestIdleCallback(()=>{B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("in")})});const Y={morphElement:n,pathname:l};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Mt=new Promise(E=>{setTimeout(()=>{mt.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),E()},(parseFloat(dt)||0)*1e3+10)});e(this,x).push(Mt)}else n.innerHTML="",n.append(...B)}),d(this,c,rt).call(this),g){S.clearScrollState();const n=document.getElementById(g);n instanceof HTMLElement&&Ct.scrollToElement(n,{scrollElement:e(this,F),behaviour:"instant",center:r,offset:u})}else e(this,N)&&S.restoreScrollPosition();yield Promise.all(e(this,x)),ut.forEach(n=>n.remove()),a(this,j,e(this,f)),a(this,f,l),a(this,x,[]),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",bt),e(this,D).remove(),Q.changeHistory({action:s,pathname:l,searchParameters:wt,hash:g}),J.dispatchEvent(document,"morphComplete",{detail:at})}catch(_){console.error(_)}a(this,P,void 0)}})}addLink(t){e(this,v).push(new gt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var r;return((r=s.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,v).forEach(s=>s.destroy()),a(this,v,t.map(s=>new gt(s,this)))}}b=new WeakMap,W=new WeakMap,v=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,x=new WeakMap,N=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,c=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let r=e(this,I).get(t);return(!r||s)&&(r=yield d(this,c,et).call(this,t)),r})},et=function(t){return M(this,null,function*(){const r=yield(yield fetch(t)).text(),u=e(this,U).parseFromString(r,"text/html"),m=new vt(this,t,u);return e(this,I).set(t,m),m})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(r=>s.find(u=>u.outerHTML===r.outerHTML))},it=function(t,s){return t.filter(r=>!s.find(u=>u.outerHTML===r.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(){a(this,F,document.querySelector(e(this,b).scrollSelector)||document.documentElement)},X=new WeakMap;exports.Morph=kt;
|
|
1
|
+
"use strict";var ft=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i),pt=i=>{throw TypeError(i)};var $=(i,t,s)=>t.has(i)||pt("Cannot "+s);var e=(i,t,s)=>($(i,t,"read from private field"),s?s.call(i):t.get(i)),o=(i,t,s)=>t.has(i)?pt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,s),a=(i,t,s,r)=>($(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s),d=(i,t,s)=>($(i,t,"access private method"),s);var M=(i,t,s)=>new Promise((r,u)=>{var m=l=>{try{A(s.next(l))}catch(g){u(g)}},V=l=>{try{A(s.throw(l))}catch(g){u(g)}},A=l=>l.done?r(l.value):Promise.resolve(l.value).then(m,V);A((s=s.apply(i,t)).next())});var Et=(i,t,s)=>(t=i[ft("asyncIterator")])?t.call(i):(i=i[ft("iterator")](),t={},s=(r,u)=>(u=i[r])&&(t[r]=m=>new Promise((V,A,l)=>(m=u.call(i,m),l=m.done,Promise.resolve(m.value).then(g=>V({value:g,done:l}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Tt=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DPDSZypW.cjs"),Q=require("../url-CLvdjbII.cjs"),Ht=require("../css-value-parser/index.cjs");class yt 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,r]of Object.entries(t))this.setAttribute(s,r)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",yt);var R,h,T,O,q;class gt{constructor(t,s){o(this,R);o(this,h);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,h).getAttribute("data-history-action")||"push",r=e(this,h).hasAttribute("data-center-scroll"),u=getComputedStyle(e(this,h)).getPropertyValue("--offset-scroll").trim(),m=u?Ht.cssValueParser.parse(u):void 0,V=e(this,h).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:r,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,h).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,h,t),a(this,T,e(this,h).getAttribute("href")||"/"),e(this,h).addEventListener("click",e(this,O));const r=s.normalizePath(e(this,T)),u=s.normalizePath(location.pathname);e(this,h).hasAttribute("data-include")&&u.pathname.includes(r.pathname)?e(this,h).classList.add("current"):r.pathname===u.pathname&&e(this,h).classList.add("current"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,q))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,O)),e(this,h).removeEventListener("pointerenter",e(this,q)),e(this,h).classList.remove("current")}}R=new WeakMap,h=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,w;class vt{constructor(t,s,r){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,w,null);a(this,C,t),a(this,z,s),a(this,H,r.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,w)}cloneDocument(){a(this,w,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,w).title)t=e(this,w).title;else{const s=e(this,w).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,p).x=0,e(this,p).y=0}clearDocumentState(){a(this,k,null)}saveScrollState(){e(this,H).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,C).scrollElement.scrollLeft,e(this,p).y=e(this,C).scrollElement.scrollTop)}saveDocumentState(){e(this,H).documentElement.hasAttribute("data-no-page-restoration")?a(this,k,null):a(this,k,document.cloneNode(!0))}restoreScrollPosition(){e(this,C).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}C=new WeakMap,z=new WeakMap,p=new WeakMap,H=new WeakMap,k=new WeakMap,w=new WeakMap;var b,W,v,U,P,f,j,x,N,F,I,D,c,tt,et,st,Lt,it,nt,rt,X;class kt{constructor(t){o(this,c);o(this,b,null);o(this,W,null);o(this,v,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,x,[]);o(this,N,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>M(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,N,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,N,!1))}));if(St.isBrowser){a(this,b,{base:Q.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"}),a(this,W,d(this,c,st).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,f,s.pathname),e(this,I).set(e(this,f),new vt(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,X)),Q.changeHistory({action:"replace",pathname:e(this,f),searchParameters:s.parameters,hash:s.hash}),a(this,D,new yt),d(this,c,rt).call(this)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,v)}get scrollElement(){return e(this,F)}normalizePath(t){return Q.splitPath(t,{base:e(this,b).base,trailingSlash:e(this,b).trailingSlash})}prefetch(t){return M(this,null,function*(){const s=this.normalizePath(t);d(this,c,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:r,offsetScroll:u,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:l,hash:g,parameters:wt,leaf:bt}=A;if(!(e(this,P)===l||e(this,f)===l)){a(this,P,l);try{let _=!0;if(this.preprocessor)try{yield new Promise((n,y)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:l,resolve:n,reject:y})})}catch(n){n?console.error(n):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==l)return;const ot=yield d(this,c,tt).call(this,e(this,f)),S=yield d(this,c,tt).call(this,l,m);if(e(this,P)!==l)return;ot.saveScrollState(),ot.saveDocumentState(),e(this,N)||(S.clearScrollState(),S.clearDocumentState()),S.cloneDocument(),e(this,D).textContent=S.title,document.body.appendChild(e(this,D));const at={pathname:l};J.dispatchEvent(document,"morphStart",{detail:at});const lt=Array.from(document.head.children),ct=Array.from(S.document.head.children),ht=d(this,c,Lt).call(this,lt,ct),Pt=d(this,c,it).call(this,lt,ht),K=d(this,c,it).call(this,ct,ht);K.forEach((n,y)=>{if(n.tagName==="SCRIPT"&&n.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=n.getAttribute("src"),K[y]=L}}),K.forEach(n=>{document.head.appendChild(n)});const Z=K.filter(n=>{if(n.hasAttribute("data-no-waiting"))return!1;if(d(this,c,nt).call(this,n))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(n=>M(this,null,function*(){let y=0;try{for(var L=Et(Z),dt,B,mt;dt=!(B=yield L.next()).done;dt=!1){const Y=B.value;Y.onload=()=>{y++,y===Z.length&&n()}}}catch(B){mt=[B]}finally{try{dt&&(B=L.return)&&(yield B.call(L))}finally{if(mt)throw mt[0]}}})));const ut=[];Pt.forEach(n=>{n.hasAttribute("data-permanent")||(d(this,c,nt).call(this,n)?ut.push(n):n.remove())});const At=d(this,c,st).call(this,S.document.body);if(e(this,W).forEach((n,y)=>{const L=At[y],dt=getComputedStyle(n).getPropertyValue("--morph-duration"),B=[...L.childNodes];if(dt){const mt=[...n.childNodes];mt.forEach(E=>{E instanceof HTMLElement&&E.classList.add("old")}),B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("new")}),n.prepend(...B),Tt.requestIdleCallback(()=>{B.forEach(E=>{E instanceof HTMLElement&&E.classList.add("in")})});const Y={morphElement:n,pathname:l};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Mt=new Promise(E=>{setTimeout(()=>{mt.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),E()},(parseFloat(dt)||0)*1e3+10)});e(this,x).push(Mt)}else n.innerHTML="",n.append(...B)}),d(this,c,rt).call(this),g){S.clearScrollState();const n=document.getElementById(g);n instanceof HTMLElement&&Ct.scrollToElement(n,{scrollElement:e(this,F),behaviour:"instant",center:r,offset:u})}else e(this,N)&&S.restoreScrollPosition();yield Promise.all(e(this,x)),ut.forEach(n=>n.remove()),a(this,j,e(this,f)),a(this,f,l),a(this,x,[]),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",l),document.documentElement.setAttribute("data-current-leaf",bt),e(this,D).remove(),Q.changeHistory({action:s,pathname:l,searchParameters:wt,hash:g}),J.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(_){console.error(_)}a(this,P,void 0)}})}addLink(t){e(this,v).push(new gt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var r;return((r=s.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,v).forEach(s=>s.destroy()),a(this,v,t.map(s=>new gt(s,this)))}}b=new WeakMap,W=new WeakMap,v=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,x=new WeakMap,N=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,c=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let r=e(this,I).get(t);return(!r||s)&&(r=yield d(this,c,et).call(this,t)),r})},et=function(t){return M(this,null,function*(){const r=yield(yield fetch(t)).text(),u=e(this,U).parseFromString(r,"text/html"),m=new vt(this,t,u);return e(this,I).set(t,m),m})},st=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Lt=function(t,s){return t.filter(r=>s.find(u=>u.outerHTML===r.outerHTML))},it=function(t,s){return t.filter(r=>!s.find(u=>u.outerHTML===r.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(){a(this,F,document.querySelector(e(this,b).scrollSelector)||document.documentElement)},X=new WeakMap;exports.Morph=kt;
|
package/lib/morph/index.js
CHANGED
|
@@ -71,7 +71,7 @@ class gt {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
R = new WeakMap(), c = new WeakMap(), T = new WeakMap(), O = new WeakMap(), z = new WeakMap();
|
|
74
|
-
var C, q, p, H, k,
|
|
74
|
+
var C, q, p, H, k, y;
|
|
75
75
|
class Lt {
|
|
76
76
|
constructor(t, s, o) {
|
|
77
77
|
r(this, C);
|
|
@@ -79,7 +79,7 @@ class Lt {
|
|
|
79
79
|
r(this, p, { x: 0, y: 0 });
|
|
80
80
|
r(this, H);
|
|
81
81
|
r(this, k, null);
|
|
82
|
-
r(this,
|
|
82
|
+
r(this, y, null);
|
|
83
83
|
a(this, C, t), a(this, q, s), a(this, H, o.cloneNode(!0));
|
|
84
84
|
}
|
|
85
85
|
get pathname() {
|
|
@@ -89,17 +89,17 @@ class Lt {
|
|
|
89
89
|
return e(this, p);
|
|
90
90
|
}
|
|
91
91
|
get document() {
|
|
92
|
-
return e(this,
|
|
92
|
+
return e(this, y);
|
|
93
93
|
}
|
|
94
94
|
cloneDocument() {
|
|
95
|
-
a(this,
|
|
95
|
+
a(this, y, (e(this, k) || e(this, H)).cloneNode(!0));
|
|
96
96
|
}
|
|
97
97
|
get title() {
|
|
98
98
|
let t = "";
|
|
99
|
-
if (e(this,
|
|
100
|
-
t = e(this,
|
|
99
|
+
if (e(this, y).title)
|
|
100
|
+
t = e(this, y).title;
|
|
101
101
|
else {
|
|
102
|
-
const s = e(this,
|
|
102
|
+
const s = e(this, y).querySelector("h1");
|
|
103
103
|
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, q);
|
|
104
104
|
}
|
|
105
105
|
return t;
|
|
@@ -127,8 +127,8 @@ class Lt {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
C = new WeakMap(), q = new WeakMap(), p = new WeakMap(), H = new WeakMap(), k = new WeakMap(),
|
|
131
|
-
var b, W, L, U, P, f, j, x, N, F, I, D, h, $, tt, et,
|
|
130
|
+
C = new WeakMap(), q = new WeakMap(), p = new WeakMap(), H = new WeakMap(), k = new WeakMap(), y = new WeakMap();
|
|
131
|
+
var b, W, L, U, P, f, j, x, N, F, I, D, h, $, tt, et, wt, st, it, nt, X;
|
|
132
132
|
class Vt {
|
|
133
133
|
constructor(t) {
|
|
134
134
|
r(this, h);
|
|
@@ -210,7 +210,7 @@ class Vt {
|
|
|
210
210
|
if (e(this, x).length)
|
|
211
211
|
return;
|
|
212
212
|
const A = this.normalizePath(t);
|
|
213
|
-
let { pathname: l, hash: g, parameters:
|
|
213
|
+
let { pathname: l, hash: g, parameters: yt, leaf: bt } = A;
|
|
214
214
|
if (!(e(this, P) === l || e(this, f) === l)) {
|
|
215
215
|
a(this, P, l);
|
|
216
216
|
try {
|
|
@@ -218,8 +218,8 @@ class Vt {
|
|
|
218
218
|
if (this.preprocessor)
|
|
219
219
|
try {
|
|
220
220
|
yield new Promise((n, v) => {
|
|
221
|
-
var
|
|
222
|
-
(
|
|
221
|
+
var w;
|
|
222
|
+
(w = this.preprocessor) == null || w.call(this, {
|
|
223
223
|
pathname: l,
|
|
224
224
|
resolve: n,
|
|
225
225
|
reject: v
|
|
@@ -240,11 +240,11 @@ class Vt {
|
|
|
240
240
|
Q(document, "morphStart", {
|
|
241
241
|
detail: rt
|
|
242
242
|
});
|
|
243
|
-
const at = Array.from(document.head.children), lt = Array.from(S.document.head.children), ht = d(this, h,
|
|
243
|
+
const at = Array.from(document.head.children), lt = Array.from(S.document.head.children), ht = d(this, h, wt).call(this, at, lt), Pt = d(this, h, st).call(this, at, ht), Y = d(this, h, st).call(this, lt, ht);
|
|
244
244
|
Y.forEach((n, v) => {
|
|
245
245
|
if (n.tagName === "SCRIPT" && n.getAttribute("src")) {
|
|
246
|
-
const
|
|
247
|
-
|
|
246
|
+
const w = document.createElement("script");
|
|
247
|
+
w.type = "module", w.src = n.getAttribute("src"), Y[v] = w;
|
|
248
248
|
}
|
|
249
249
|
}), Y.forEach((n) => {
|
|
250
250
|
document.head.appendChild(n);
|
|
@@ -258,7 +258,7 @@ class Vt {
|
|
|
258
258
|
e(this, b).waitForHeadToLoad && Z.length && (yield new Promise((n) => M(this, null, function* () {
|
|
259
259
|
let v = 0;
|
|
260
260
|
try {
|
|
261
|
-
for (var
|
|
261
|
+
for (var w = pt(Z), ut, B, dt; ut = !(B = yield w.next()).done; ut = !1) {
|
|
262
262
|
const G = B.value;
|
|
263
263
|
G.onload = () => {
|
|
264
264
|
v++, v === Z.length && n();
|
|
@@ -268,7 +268,7 @@ class Vt {
|
|
|
268
268
|
dt = [B];
|
|
269
269
|
} finally {
|
|
270
270
|
try {
|
|
271
|
-
ut && (B =
|
|
271
|
+
ut && (B = w.return) && (yield B.call(w));
|
|
272
272
|
} finally {
|
|
273
273
|
if (dt)
|
|
274
274
|
throw dt[0];
|
|
@@ -281,7 +281,7 @@ class Vt {
|
|
|
281
281
|
});
|
|
282
282
|
const At = d(this, h, et).call(this, S.document.body);
|
|
283
283
|
if (e(this, W).forEach((n, v) => {
|
|
284
|
-
const
|
|
284
|
+
const w = At[v], ut = getComputedStyle(n).getPropertyValue("--morph-duration"), B = [...w.childNodes];
|
|
285
285
|
if (ut) {
|
|
286
286
|
const dt = [...n.childNodes];
|
|
287
287
|
dt.forEach((E) => {
|
|
@@ -325,11 +325,11 @@ class Vt {
|
|
|
325
325
|
yield Promise.all(e(this, x)), ct.forEach((n) => n.remove()), a(this, j, e(this, f)), a(this, f, l), a(this, x, []), this.findLinks(), document.documentElement.setAttribute("data-current-pathname", l), document.documentElement.setAttribute("data-current-leaf", bt), e(this, D).remove(), Et({
|
|
326
326
|
action: s,
|
|
327
327
|
pathname: l,
|
|
328
|
-
searchParameters:
|
|
328
|
+
searchParameters: yt,
|
|
329
329
|
hash: g
|
|
330
330
|
}), Q(document, "morphComplete", {
|
|
331
331
|
detail: rt
|
|
332
|
-
});
|
|
332
|
+
}), window.dispatchEvent(new Event("resize"));
|
|
333
333
|
} catch (K) {
|
|
334
334
|
console.error(K);
|
|
335
335
|
}
|
|
@@ -373,7 +373,7 @@ b = new WeakMap(), W = new WeakMap(), L = new WeakMap(), U = new WeakMap(), P =
|
|
|
373
373
|
}, et = function(t) {
|
|
374
374
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
375
375
|
return s.length ? s : [t];
|
|
376
|
-
},
|
|
376
|
+
}, wt = function(t, s) {
|
|
377
377
|
return t.filter(
|
|
378
378
|
(o) => s.find(
|
|
379
379
|
(u) => u.outerHTML === o.outerHTML
|