aptechka 0.47.9 → 0.47.10
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 +44 -44
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Et=n=>{throw TypeError(n)};var $=(n,t,s)=>t.has(n)||Et("Cannot "+s);var e=(n,t,s)=>($(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>($(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>($(n,t,"access private method"),s);var M=(n,t,s)=>new Promise((i,c)=>{var m=h=>{try{A(s.next(h))}catch(E){c(E)}},V=h=>{try{A(s.throw(h))}catch(E){c(E)}},A=h=>h.done?i(h.value):Promise.resolve(h.value).then(m,V);A((s=s.apply(n,t)).next())});var gt=(n,t,s)=>(t=n[pt("asyncIterator")])?t.call(n):(n=n[pt("iterator")](),t={},s=(i,c)=>(c=n[i])&&(t[i]=m=>new Promise((V,A,h)=>(m=c.call(n,m),h=m.done,Promise.resolve(m.value).then(E=>V({value:E,done:h}),A)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Ct=require("../polyfills-Df4r-ETT.cjs"),Ht=require("../scroll-H9zqFeML.cjs"),Q=require("../url-CLvdjbII.cjs"),kt=require("../css-value-parser/index.cjs");class wt 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)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",wt);var R,u,T,O,q;class vt{constructor(t,s){o(this,R);o(this,u);o(this,T);o(this,O,t=>{t.preventDefault();const s=e(this,u).getAttribute("data-history-action")||"push",i=e(this,u).hasAttribute("data-center-scroll"),c=getComputedStyle(e(this,u)).getPropertyValue("--offset-scroll").trim(),m=c?kt.cssValueParser.parse(c):void 0,V=e(this,u).hasAttribute("data-revalidate");e(this,R).navigate(e(this,T),{historyAction:s,centerScroll:i,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,T)),e(this,u).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,u,t),a(this,T,e(this,u).getAttribute("href")||"/"),e(this,u).addEventListener("click",e(this,O));const i=s.normalizePath(e(this,T)),c=s.normalizePath(location.pathname);e(this,u).hasAttribute("data-include")&&c.pathname.includes(i.pathname)?e(this,u).classList.add("current"):i.pathname===c.pathname&&e(this,u).classList.add("current"),e(this,u).hasAttribute("data-prefetch")&&e(this,u).addEventListener("pointerenter",e(this,q))}get element(){return e(this,u)}destroy(){e(this,u).removeEventListener("click",e(this,O)),e(this,u).removeEventListener("pointerenter",e(this,q)),e(this,u).classList.remove("current")}}R=new WeakMap,u=new WeakMap,T=new WeakMap,O=new WeakMap,q=new WeakMap;var C,z,p,H,k,L;class yt{constructor(t,s,i){o(this,C);o(this,z);o(this,p,{x:0,y:0});o(this,H);o(this,k,null);o(this,L,null);a(this,C,t),a(this,z,s),a(this,H,i.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,L)}cloneDocument(){a(this,L,(e(this,k)||e(this,H)).cloneNode(!0))}get title(){let t="";if(e(this,L).title)t=e(this,L).title;else{const s=e(this,L).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,L=new WeakMap;var b,W,y,U,P,f,j,x,N,F,I,D,l,tt,et,st,Lt,it,nt,rt,ot,X;class xt{constructor(t){o(this,l);o(this,b,null);o(this,W,null);o(this,y,[]);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,l,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 yt(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 wt),d(this,l,rt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,y)}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,l,et).call(this,s.pathname)})}navigate(V){return M(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:m}={}){if(e(this,x).length)return;const A=this.normalizePath(t);let{pathname:h,hash:E,parameters:bt,leaf:Pt}=A;if(e(this,P)===h||e(this,f)===h){d(this,l,ot).call(this,E||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}a(this,P,h);try{let _=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:h,resolve:r,reject:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==h)return;const at=yield d(this,l,tt).call(this,e(this,f)),v=yield d(this,l,tt).call(this,h,m);if(e(this,P)!==h)return;at.saveScrollState(),at.saveDocumentState(),e(this,N)||(v.clearScrollState(),v.clearDocumentState()),v.cloneDocument(),e(this,D).textContent=v.title,document.body.appendChild(e(this,D));const lt={pathname:h};J.dispatchEvent(document,"morphStart",{detail:lt});const ht=Array.from(document.head.children),ct=Array.from(v.document.head.children),ut=d(this,l,Lt).call(this,ht,ct),At=d(this,l,it).call(this,ht,ut),K=d(this,l,it).call(this,ct,ut);K.forEach((r,S)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=r.getAttribute("src"),K[S]=w}}),K.forEach(r=>{document.head.appendChild(r)});const Z=K.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,l,nt).call(this,r))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(r=>M(this,null,function*(){let S=0;try{for(var w=gt(Z),mt,B,ft;mt=!(B=yield w.next()).done;mt=!1){const Y=B.value;Y.onload=()=>{S++,S===Z.length&&r()}}}catch(B){ft=[B]}finally{try{mt&&(B=w.return)&&(yield B.call(w))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,l,nt).call(this,r)?dt.push(r):r.remove())});const Mt=d(this,l,st).call(this,v.document.body);d(this,l,rt).call(this,v.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Pt),Q.changeHistory({action:s,pathname:h,searchParameters:bt,hash:E}),e(this,D).remove(),a(this,j,e(this,f)),a(this,f,h),e(this,W).forEach((r,S)=>{const w=Mt[S],mt=getComputedStyle(r).getPropertyValue("--morph-duration"),B=[...w.childNodes];if(mt){const ft=[...r.childNodes];ft.forEach(g=>{g instanceof HTMLElement&&g.classList.add("old")}),B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("new")}),r.prepend(...B),Ct.requestIdleCallback(()=>{B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Y={morphElement:r,pathname:h};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Tt=new Promise(g=>{setTimeout(()=>{ft.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),g()},(parseFloat(mt)||0)*1e3+10)});e(this,x).push(Tt)}else r.innerHTML="",r.append(...B)}),E?(v.clearScrollState(),d(this,l,ot).call(this,E,{centerScroll:i,offsetScroll:c})):e(this,N)&&v.restoreScrollPosition(),yield Promise.all(e(this,x)),dt.forEach(r=>r.remove()),a(this,x,[]),this.findLinks(),J.dispatchEvent(document,"morphComplete",{detail:lt}),window.dispatchEvent(new Event("resize"))}catch(_){console.error(_)}a(this,P,void 0)})}addLink(t){e(this,y).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,y,e(this,y).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,y).forEach(s=>s.destroy()),a(this,y,t.map(s=>new vt(s,this)))}}b=new WeakMap,W=new WeakMap,y=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,l=new WeakSet,tt=function(t,s=!1){return M(this,null,function*(){let i=e(this,I).get(t);return(!i||s)&&(i=yield d(this,l,et).call(this,t)),i})},et=function(t){return M(this,null,function*(){const i=yield(yield fetch(t)).text(),c=e(this,U).parseFromString(i,"text/html"),m=new yt(this,t,c);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(i=>s.find(c=>c.outerHTML===i.outerHTML))},it=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,F,t.querySelector(e(this,b).scrollSelector)||t.documentElement)},ot=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ht.scrollToElement(i,{scrollElement:e(this,F),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
|
1
|
+
"use strict";var pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Et=n=>{throw TypeError(n)};var $=(n,t,s)=>t.has(n)||Et("Cannot "+s);var e=(n,t,s)=>($(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Et("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>($(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>($(n,t,"access private method"),s);var T=(n,t,s)=>new Promise((i,c)=>{var m=h=>{try{M(s.next(h))}catch(E){c(E)}},V=h=>{try{M(s.throw(h))}catch(E){c(E)}},M=h=>h.done?i(h.value):Promise.resolve(h.value).then(m,V);M((s=s.apply(n,t)).next())});var gt=(n,t,s)=>(t=n[pt("asyncIterator")])?t.call(n):(n=n[pt("iterator")](),t={},s=(i,c)=>(c=n[i])&&(t[i]=m=>new Promise((V,M,h)=>(m=c.call(n,m),h=m.done,Promise.resolve(m.value).then(E=>V({value:E,done:h}),M)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const St=require("../index-Cqw2NKev.cjs"),J=require("../events-KVanG9sR.cjs"),Ct=require("../polyfills-Df4r-ETT.cjs"),Ht=require("../scroll-H9zqFeML.cjs"),Q=require("../url-CLvdjbII.cjs"),kt=require("../css-value-parser/index.cjs");class wt 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)}}St.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",wt);var R,u,C,O,q;class vt{constructor(t,s){o(this,R);o(this,u);o(this,C);o(this,O,t=>{t.preventDefault();const s=e(this,u).getAttribute("data-history-action")||"push",i=e(this,u).hasAttribute("data-center-scroll"),c=getComputedStyle(e(this,u)).getPropertyValue("--offset-scroll").trim(),m=c?kt.cssValueParser.parse(c):void 0,V=e(this,u).hasAttribute("data-revalidate");e(this,R).navigate(e(this,C),{historyAction:s,centerScroll:i,offsetScroll:m,revalidate:V})});o(this,q,()=>{e(this,R).prefetch(e(this,C)),e(this,u).removeEventListener("pointerenter",e(this,q))});a(this,R,s),a(this,u,t),a(this,C,e(this,u).getAttribute("href")||"/"),e(this,u).addEventListener("click",e(this,O));const i=s.normalizePath(e(this,C)),c=s.normalizePath(location.pathname);e(this,u).hasAttribute("data-include")&&c.pathname.includes(i.pathname)?e(this,u).classList.add("current"):i.pathname===c.pathname&&e(this,u).classList.add("current"),e(this,u).hasAttribute("data-prefetch")&&e(this,u).addEventListener("pointerenter",e(this,q))}get element(){return e(this,u)}destroy(){e(this,u).removeEventListener("click",e(this,O)),e(this,u).removeEventListener("pointerenter",e(this,q)),e(this,u).classList.remove("current")}}R=new WeakMap,u=new WeakMap,C=new WeakMap,O=new WeakMap,q=new WeakMap;var H,z,p,k,x,L;class yt{constructor(t,s,i){o(this,H);o(this,z);o(this,p,{x:0,y:0});o(this,k);o(this,x,null);o(this,L,null);a(this,H,t),a(this,z,s),a(this,k,i.cloneNode(!0))}get pathname(){return e(this,z)}get scrollState(){return e(this,p)}get document(){return e(this,L)}cloneDocument(){a(this,L,(e(this,x)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,L).title)t=e(this,L).title;else{const s=e(this,L).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,x,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,p).x=0,e(this,p).y=0):(e(this,p).x=e(this,H).scrollElement.scrollLeft,e(this,p).y=e(this,H).scrollElement.scrollTop)}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?a(this,x,null):a(this,x,document.cloneNode(!0))}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,p).y,left:e(this,p).x})}}H=new WeakMap,z=new WeakMap,p=new WeakMap,k=new WeakMap,x=new WeakMap,L=new WeakMap;var b,W,y,U,P,f,j,N,A,F,I,D,l,tt,et,st,Lt,it,nt,rt,ot,X;class xt{constructor(t){o(this,l);o(this,b,null);o(this,W,null);o(this,y,[]);o(this,U,new DOMParser);o(this,P);o(this,f,null);o(this,j);o(this,N,[]);o(this,A,!1);o(this,F,null);o(this,I,new Map);o(this,D,null);o(this,X,t=>T(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(a(this,A,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,A,!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,l,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 yt(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 wt),d(this,l,rt).call(this,document)}}get currentPathname(){return e(this,f)}get previousPathname(){return e(this,j)}get links(){return e(this,y)}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 T(this,null,function*(){const s=this.normalizePath(t);d(this,l,et).call(this,s.pathname)})}navigate(V){return T(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:c,revalidate:m}={}){if(e(this,N).length)return;const M=this.normalizePath(t);let{pathname:h,hash:E,parameters:bt,leaf:Pt}=M;if(e(this,P)===h||e(this,f)===h){e(this,A)||d(this,l,ot).call(this,E||0,{centerScroll:i,offsetScroll:c,behavior:"smooth"});return}a(this,P,h);try{let _=!0;if(this.preprocessor)try{yield new Promise((r,S)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:h,resolve:r,reject:S})})}catch(r){r?console.error(r):console.log("Route change canceled"),_=!1}if(!_||e(this,P)!==h)return;const at=yield d(this,l,tt).call(this,e(this,f)),v=yield d(this,l,tt).call(this,h,m);if(e(this,P)!==h)return;at.saveScrollState(),at.saveDocumentState(),e(this,A)||(v.clearScrollState(),v.clearDocumentState()),v.cloneDocument(),e(this,D).textContent=v.title,document.body.appendChild(e(this,D));const lt={pathname:h};J.dispatchEvent(document,"morphStart",{detail:lt});const ht=Array.from(document.head.children),ct=Array.from(v.document.head.children),ut=d(this,l,Lt).call(this,ht,ct),At=d(this,l,it).call(this,ht,ut),K=d(this,l,it).call(this,ct,ut);K.forEach((r,S)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=r.getAttribute("src"),K[S]=w}}),K.forEach(r=>{document.head.appendChild(r)});const Z=K.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,l,nt).call(this,r))return!0});e(this,b).waitForHeadToLoad&&Z.length&&(yield new Promise(r=>T(this,null,function*(){let S=0;try{for(var w=gt(Z),mt,B,ft;mt=!(B=yield w.next()).done;mt=!1){const Y=B.value;Y.onload=()=>{S++,S===Z.length&&r()}}}catch(B){ft=[B]}finally{try{mt&&(B=w.return)&&(yield B.call(w))}finally{if(ft)throw ft[0]}}})));const dt=[];At.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,l,nt).call(this,r)?dt.push(r):r.remove())});const Mt=d(this,l,st).call(this,v.document.body);d(this,l,rt).call(this,v.document),document.documentElement.setAttribute("data-current-pathname",h),document.documentElement.setAttribute("data-current-leaf",Pt),Q.changeHistory({action:s,pathname:h,searchParameters:bt,hash:E}),e(this,D).remove(),a(this,j,e(this,f)),a(this,f,h),e(this,W).forEach((r,S)=>{const w=Mt[S],mt=getComputedStyle(r).getPropertyValue("--morph-duration"),B=[...w.childNodes];if(mt){const ft=[...r.childNodes];ft.forEach(g=>{g instanceof HTMLElement&&g.classList.add("old")}),B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("new")}),r.prepend(...B),Ct.requestIdleCallback(()=>{B.forEach(g=>{g instanceof HTMLElement&&g.classList.add("in")})});const Y={morphElement:r,pathname:h};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:Y});const Tt=new Promise(g=>{setTimeout(()=>{ft.forEach(G=>G.remove()),B.forEach(G=>{G instanceof HTMLElement&&G.classList.remove("in","new")}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:Y}),g()},(parseFloat(mt)||0)*1e3+10)});e(this,N).push(Tt)}else r.innerHTML="",r.append(...B)}),E?(v.clearScrollState(),d(this,l,ot).call(this,E,{centerScroll:i,offsetScroll:c})):e(this,A)&&v.restoreScrollPosition(),yield Promise.all(e(this,N)),dt.forEach(r=>r.remove()),a(this,N,[]),this.findLinks(),J.dispatchEvent(document,"morphComplete",{detail:lt}),window.dispatchEvent(new Event("resize"))}catch(_){console.error(_)}a(this,P,void 0)})}addLink(t){e(this,y).push(new vt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,y,e(this,y).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var i;return((i=s.getAttribute("href"))==null?void 0:i.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,y).forEach(s=>s.destroy()),a(this,y,t.map(s=>new vt(s,this)))}}b=new WeakMap,W=new WeakMap,y=new WeakMap,U=new WeakMap,P=new WeakMap,f=new WeakMap,j=new WeakMap,N=new WeakMap,A=new WeakMap,F=new WeakMap,I=new WeakMap,D=new WeakMap,l=new WeakSet,tt=function(t,s=!1){return T(this,null,function*(){let i=e(this,I).get(t);return(!i||s)&&(i=yield d(this,l,et).call(this,t)),i})},et=function(t){return T(this,null,function*(){const i=yield(yield fetch(t)).text(),c=e(this,U).parseFromString(i,"text/html"),m=new yt(this,t,c);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(i=>s.find(c=>c.outerHTML===i.outerHTML))},it=function(t,s){return t.filter(i=>!s.find(c=>c.outerHTML===i.outerHTML))},nt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},rt=function(t){a(this,F,t.querySelector(e(this,b).scrollSelector)||t.documentElement)},ot=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ht.scrollToElement(i,{scrollElement:e(this,F),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},X=new WeakMap;exports.Morph=xt;
|
package/lib/morph/index.js
CHANGED
|
@@ -3,23 +3,23 @@ var ft = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), pt = (n) =>
|
|
|
3
3
|
};
|
|
4
4
|
var _ = (n, t, s) => t.has(n) || pt("Cannot " + s);
|
|
5
5
|
var e = (n, t, s) => (_(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? pt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (_(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (_(n, t, "access private method"), s);
|
|
6
|
-
var
|
|
6
|
+
var C = (n, t, s) => new Promise((i, c) => {
|
|
7
7
|
var m = (h) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
T(s.next(h));
|
|
10
10
|
} catch (E) {
|
|
11
11
|
c(E);
|
|
12
12
|
}
|
|
13
13
|
}, V = (h) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
T(s.throw(h));
|
|
16
16
|
} catch (E) {
|
|
17
17
|
c(E);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, T = (h) => h.done ? i(h.value) : Promise.resolve(h.value).then(m, V);
|
|
20
|
+
T((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Et = (n, t, s) => (t = n[ft("asyncIterator")]) ? t.call(n) : (n = n[ft("iterator")](), t = {}, s = (i, c) => (c = n[i]) && (t[i] = (m) => new Promise((V,
|
|
22
|
+
var Et = (n, t, s) => (t = n[ft("asyncIterator")]) ? t.call(n) : (n = n[ft("iterator")](), t = {}, s = (i, c) => (c = n[i]) && (t[i] = (m) => new Promise((V, T, h) => (m = c.call(n, m), h = m.done, Promise.resolve(m.value).then((E) => V({ value: E, done: h }), T)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as yt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as Q } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as Mt } from "../polyfills-DJrTJQky.js";
|
|
@@ -38,18 +38,18 @@ class Lt extends HTMLElement {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
yt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Lt);
|
|
41
|
-
var R, u,
|
|
41
|
+
var R, u, M, O, z;
|
|
42
42
|
class vt {
|
|
43
43
|
constructor(t, s) {
|
|
44
44
|
o(this, R);
|
|
45
45
|
o(this, u);
|
|
46
|
-
o(this,
|
|
46
|
+
o(this, M);
|
|
47
47
|
o(this, O, (t) => {
|
|
48
48
|
t.preventDefault();
|
|
49
49
|
const s = e(this, u).getAttribute(
|
|
50
50
|
"data-history-action"
|
|
51
51
|
) || "push", i = e(this, u).hasAttribute("data-center-scroll"), c = getComputedStyle(e(this, u)).getPropertyValue("--offset-scroll").trim(), m = c ? Nt.parse(c) : void 0, V = e(this, u).hasAttribute("data-revalidate");
|
|
52
|
-
e(this, R).navigate(e(this,
|
|
52
|
+
e(this, R).navigate(e(this, M), {
|
|
53
53
|
historyAction: s,
|
|
54
54
|
centerScroll: i,
|
|
55
55
|
offsetScroll: m,
|
|
@@ -57,10 +57,10 @@ class vt {
|
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
59
|
o(this, z, () => {
|
|
60
|
-
e(this, R).prefetch(e(this,
|
|
60
|
+
e(this, R).prefetch(e(this, M)), e(this, u).removeEventListener("pointerenter", e(this, z));
|
|
61
61
|
});
|
|
62
|
-
a(this, R, s), a(this, u, t), a(this,
|
|
63
|
-
const i = s.normalizePath(e(this,
|
|
62
|
+
a(this, R, s), a(this, u, t), a(this, M, e(this, u).getAttribute("href") || "/"), e(this, u).addEventListener("click", e(this, O));
|
|
63
|
+
const i = s.normalizePath(e(this, M)), c = s.normalizePath(location.pathname);
|
|
64
64
|
e(this, u).hasAttribute("data-include") && c.pathname.includes(i.pathname) ? e(this, u).classList.add("current") : i.pathname === c.pathname && e(this, u).classList.add("current"), e(this, u).hasAttribute("data-prefetch") && e(this, u).addEventListener("pointerenter", e(this, z));
|
|
65
65
|
}
|
|
66
66
|
get element() {
|
|
@@ -70,17 +70,17 @@ class vt {
|
|
|
70
70
|
e(this, u).removeEventListener("click", e(this, O)), e(this, u).removeEventListener("pointerenter", e(this, z)), e(this, u).classList.remove("current");
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
R = new WeakMap(), u = new WeakMap(),
|
|
74
|
-
var
|
|
73
|
+
R = new WeakMap(), u = new WeakMap(), M = new WeakMap(), O = new WeakMap(), z = new WeakMap();
|
|
74
|
+
var H, q, p, k, x, w;
|
|
75
75
|
class St {
|
|
76
76
|
constructor(t, s, i) {
|
|
77
|
-
o(this,
|
|
77
|
+
o(this, H);
|
|
78
78
|
o(this, q);
|
|
79
79
|
o(this, p, { x: 0, y: 0 });
|
|
80
|
-
o(this,
|
|
81
|
-
o(this,
|
|
80
|
+
o(this, k);
|
|
81
|
+
o(this, x, null);
|
|
82
82
|
o(this, w, null);
|
|
83
|
-
a(this,
|
|
83
|
+
a(this, H, t), a(this, q, s), a(this, k, i.cloneNode(!0));
|
|
84
84
|
}
|
|
85
85
|
get pathname() {
|
|
86
86
|
return e(this, q);
|
|
@@ -92,7 +92,7 @@ class St {
|
|
|
92
92
|
return e(this, w);
|
|
93
93
|
}
|
|
94
94
|
cloneDocument() {
|
|
95
|
-
a(this, w, (e(this,
|
|
95
|
+
a(this, w, (e(this, x) || e(this, k)).cloneNode(!0));
|
|
96
96
|
}
|
|
97
97
|
get title() {
|
|
98
98
|
let t = "";
|
|
@@ -108,27 +108,27 @@ class St {
|
|
|
108
108
|
e(this, p).x = 0, e(this, p).y = 0;
|
|
109
109
|
}
|
|
110
110
|
clearDocumentState() {
|
|
111
|
-
a(this,
|
|
111
|
+
a(this, x, null);
|
|
112
112
|
}
|
|
113
113
|
saveScrollState() {
|
|
114
|
-
e(this,
|
|
114
|
+
e(this, k).documentElement.hasAttribute(
|
|
115
115
|
"data-no-scroll-restoration"
|
|
116
|
-
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this,
|
|
116
|
+
) ? (e(this, p).x = 0, e(this, p).y = 0) : (e(this, p).x = e(this, H).scrollElement.scrollLeft, e(this, p).y = e(this, H).scrollElement.scrollTop);
|
|
117
117
|
}
|
|
118
118
|
saveDocumentState() {
|
|
119
|
-
e(this,
|
|
119
|
+
e(this, k).documentElement.hasAttribute(
|
|
120
120
|
"data-no-page-restoration"
|
|
121
|
-
) ? a(this,
|
|
121
|
+
) ? a(this, x, null) : a(this, x, document.cloneNode(!0));
|
|
122
122
|
}
|
|
123
123
|
restoreScrollPosition() {
|
|
124
|
-
e(this,
|
|
124
|
+
e(this, H).scrollElement.scroll({
|
|
125
125
|
top: e(this, p).y,
|
|
126
126
|
left: e(this, p).x
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
|
|
131
|
-
var b, W, S, U, P, f, j,
|
|
130
|
+
H = new WeakMap(), q = new WeakMap(), p = new WeakMap(), k = new WeakMap(), x = new WeakMap(), w = new WeakMap();
|
|
131
|
+
var b, W, S, U, P, f, j, N, A, F, I, D, l, $, tt, et, wt, st, it, nt, rt, X;
|
|
132
132
|
class Bt {
|
|
133
133
|
constructor(t) {
|
|
134
134
|
o(this, l);
|
|
@@ -139,14 +139,14 @@ class Bt {
|
|
|
139
139
|
o(this, P);
|
|
140
140
|
o(this, f, null);
|
|
141
141
|
o(this, j);
|
|
142
|
-
o(this,
|
|
143
|
-
o(this,
|
|
142
|
+
o(this, N, []);
|
|
143
|
+
o(this, A, !1);
|
|
144
144
|
o(this, F, null);
|
|
145
145
|
o(this, I, /* @__PURE__ */ new Map());
|
|
146
146
|
o(this, D, null);
|
|
147
|
-
o(this, X, (t) =>
|
|
147
|
+
o(this, X, (t) => C(this, null, function* () {
|
|
148
148
|
var s;
|
|
149
|
-
(s = t.state) != null && s.path && (a(this,
|
|
149
|
+
(s = t.state) != null && s.path && (a(this, A, !0), yield this.navigate(t.state.path, { historyAction: "none" }), a(this, A, !1));
|
|
150
150
|
}));
|
|
151
151
|
if (yt) {
|
|
152
152
|
a(this, b, {
|
|
@@ -195,24 +195,24 @@ class Bt {
|
|
|
195
195
|
});
|
|
196
196
|
}
|
|
197
197
|
prefetch(t) {
|
|
198
|
-
return
|
|
198
|
+
return C(this, null, function* () {
|
|
199
199
|
const s = this.normalizePath(t);
|
|
200
200
|
d(this, l, tt).call(this, s.pathname);
|
|
201
201
|
});
|
|
202
202
|
}
|
|
203
203
|
navigate(V) {
|
|
204
|
-
return
|
|
204
|
+
return C(this, arguments, function* (t, {
|
|
205
205
|
historyAction: s = "push",
|
|
206
206
|
centerScroll: i,
|
|
207
207
|
offsetScroll: c,
|
|
208
208
|
revalidate: m
|
|
209
209
|
} = {}) {
|
|
210
|
-
if (e(this,
|
|
210
|
+
if (e(this, N).length)
|
|
211
211
|
return;
|
|
212
|
-
const
|
|
213
|
-
let { pathname: h, hash: E, parameters: bt, leaf: Pt } =
|
|
212
|
+
const T = this.normalizePath(t);
|
|
213
|
+
let { pathname: h, hash: E, parameters: bt, leaf: Pt } = T;
|
|
214
214
|
if (e(this, P) === h || e(this, f) === h) {
|
|
215
|
-
d(this, l, rt).call(this, E || 0, {
|
|
215
|
+
e(this, A) || d(this, l, rt).call(this, E || 0, {
|
|
216
216
|
centerScroll: i,
|
|
217
217
|
offsetScroll: c,
|
|
218
218
|
behavior: "smooth"
|
|
@@ -240,7 +240,7 @@ class Bt {
|
|
|
240
240
|
const ot = yield d(this, l, $).call(this, e(this, f)), v = yield d(this, l, $).call(this, h, m);
|
|
241
241
|
if (e(this, P) !== h)
|
|
242
242
|
return;
|
|
243
|
-
ot.saveScrollState(), ot.saveDocumentState(), e(this,
|
|
243
|
+
ot.saveScrollState(), ot.saveDocumentState(), e(this, A) || (v.clearScrollState(), v.clearDocumentState()), v.cloneDocument(), e(this, D).textContent = v.title, document.body.appendChild(e(this, D));
|
|
244
244
|
const at = {
|
|
245
245
|
pathname: h
|
|
246
246
|
};
|
|
@@ -262,7 +262,7 @@ class Bt {
|
|
|
262
262
|
if (d(this, l, it).call(this, r))
|
|
263
263
|
return !0;
|
|
264
264
|
});
|
|
265
|
-
e(this, b).waitForHeadToLoad && Z.length && (yield new Promise((r) =>
|
|
265
|
+
e(this, b).waitForHeadToLoad && Z.length && (yield new Promise((r) => C(this, null, function* () {
|
|
266
266
|
let y = 0;
|
|
267
267
|
try {
|
|
268
268
|
for (var L = Et(Z), dt, B, mt; dt = !(B = yield L.next()).done; dt = !1) {
|
|
@@ -321,10 +321,10 @@ class Bt {
|
|
|
321
321
|
}), g();
|
|
322
322
|
}, (parseFloat(dt) || 0) * 1e3 + 10);
|
|
323
323
|
});
|
|
324
|
-
e(this,
|
|
324
|
+
e(this, N).push(Ct);
|
|
325
325
|
} else
|
|
326
326
|
r.innerHTML = "", r.append(...B);
|
|
327
|
-
}), E ? (v.clearScrollState(), d(this, l, rt).call(this, E, { centerScroll: i, offsetScroll: c })) : e(this,
|
|
327
|
+
}), E ? (v.clearScrollState(), d(this, l, rt).call(this, E, { centerScroll: i, offsetScroll: c })) : e(this, A) && v.restoreScrollPosition(), yield Promise.all(e(this, N)), ut.forEach((r) => r.remove()), a(this, N, []), this.findLinks(), Q(document, "morphComplete", {
|
|
328
328
|
detail: at
|
|
329
329
|
}), window.dispatchEvent(new Event("resize"));
|
|
330
330
|
} catch (K) {
|
|
@@ -356,13 +356,13 @@ class Bt {
|
|
|
356
356
|
e(this, S).forEach((s) => s.destroy()), a(this, S, t.map((s) => new vt(s, this)));
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
b = new WeakMap(), W = new WeakMap(), S = new WeakMap(), U = new WeakMap(), P = new WeakMap(), f = new WeakMap(), j = new WeakMap(),
|
|
360
|
-
return
|
|
359
|
+
b = new WeakMap(), W = new WeakMap(), S = new WeakMap(), U = new WeakMap(), P = new WeakMap(), f = new WeakMap(), j = new WeakMap(), N = new WeakMap(), A = new WeakMap(), F = new WeakMap(), I = new WeakMap(), D = new WeakMap(), l = new WeakSet(), $ = function(t, s = !1) {
|
|
360
|
+
return C(this, null, function* () {
|
|
361
361
|
let i = e(this, I).get(t);
|
|
362
362
|
return (!i || s) && (i = yield d(this, l, tt).call(this, t)), i;
|
|
363
363
|
});
|
|
364
364
|
}, tt = function(t) {
|
|
365
|
-
return
|
|
365
|
+
return C(this, null, function* () {
|
|
366
366
|
const i = yield (yield fetch(t)).text(), c = e(this, U).parseFromString(i, "text/html"), m = new St(this, t, c);
|
|
367
367
|
return e(this, I).set(t, m), m;
|
|
368
368
|
});
|