aptechka 0.43.0 → 0.43.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.
@@ -11,7 +11,10 @@ export interface MorphNavigationEntry {
11
11
  isCached: boolean;
12
12
  state?: any;
13
13
  }
14
- export interface MorphElementSwitchEntry {
14
+ export interface MorphNavigationDocumentEntry extends MorphNavigationEntry {
15
+ newDocument: Document;
16
+ }
17
+ export interface MorphChildrenActionEntry {
15
18
  element: HTMLElement;
16
19
  pathname: string;
17
20
  isCached: boolean;
@@ -29,10 +32,10 @@ export interface MorphNavigateOptions {
29
32
  state?: any;
30
33
  }
31
34
  export interface MorphEvents {
32
- morphBeforeNavigation: CustomEvent<MorphNavigationEntry>;
33
- morphAfterNavigation: CustomEvent<MorphNavigationEntry>;
34
- morphBeforeElementOut: CustomEvent<MorphElementSwitchEntry>;
35
- morphAfterElementOut: CustomEvent<MorphElementSwitchEntry>;
35
+ morphBeforeNavigation: CustomEvent<MorphNavigationDocumentEntry>;
36
+ morphAfterNavigation: CustomEvent<MorphNavigationDocumentEntry>;
37
+ morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
38
+ morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
36
39
  }
37
40
  export declare class Morph {
38
41
  #private;
@@ -1 +1 @@
1
- "use strict";var lt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),dt=r=>{throw TypeError(r)};var $=(r,t,s)=>t.has(r)||dt("Cannot "+s);var e=(r,t,s)=>($(r,t,"read from private field"),s?s.call(r):t.get(r)),a=(r,t,s)=>t.has(r)?dt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),c=(r,t,s,n)=>($(r,t,"write to private field"),n?n.call(r,s):t.set(r,s),s),y=(r,t,s)=>($(r,t,"access private method"),s);var O=(r,t,s)=>new Promise((n,l)=>{var d=m=>{try{L(s.next(m))}catch(P){l(P)}},o=m=>{try{L(s.throw(m))}catch(P){l(P)}},L=m=>m.done?n(m.value):Promise.resolve(m.value).then(d,o);L((s=s.apply(r,t)).next())});var ut=(r,t,s)=>(t=r[lt("asyncIterator")])?t.call(r):(r=r[lt("iterator")](),t={},s=(n,l)=>(l=r[n])&&(t[n]=d=>new Promise((o,L,m)=>(d=l.call(r,d),m=d.done,Promise.resolve(d.value).then(P=>o({value:P,done:m}),L)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wt=require("../browser-CpzFX2xg.cjs"),J=require("../events-KVanG9sR.cjs"),Q=require("../url-CHQeS8b5.cjs"),mt=require("../loading/index.cjs");class pt extends HTMLElement{constructor(){super()}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,n]of Object.entries(t))this.setAttribute(s,n)}}customElements.get("morph-announcer")||customElements.define("morph-announcer",pt);var T,h,g,R,D,k,_,H;class ft{constructor(t,s){a(this,T);a(this,h);a(this,g);a(this,R);a(this,D);a(this,k);a(this,_,t=>{t.preventDefault(),e(this,T).links.forEach(s=>{var n;e(this,g)===e(s,g)||(n=e(s,k))!=null&&n.includes(e(this,g))?e(s,h).classList.add("clicked"):e(s,h).classList.remove("clicked")}),e(this,T).navigate(e(this,g),{historyAction:e(this,R),state:e(this,D)})});a(this,H,()=>{e(this,T).prefetch(e(this,g)),e(this,h).removeEventListener("pointerenter",e(this,H))});var d,o;c(this,T,s),c(this,h,t),c(this,g,e(this,h).getAttribute("href")||"/"),c(this,R,e(this,h).getAttribute("data-history-action")||"push"),c(this,D,e(this,h).getAttribute("data-state")||void 0),e(this,h).addEventListener("click",e(this,_));const n=s.normalizePath(e(this,g)),l=s.normalizePath(location.pathname);c(this,k,(d=e(this,h).getAttribute("data-match-paths"))==null?void 0:d.split(",").map(L=>s.normalizePath(L.trim()).pathname)),e(this,h).hasAttribute("data-include")?l.pathname.includes(n.pathname)&&e(this,h).classList.add("current"):n.pathname===l.pathname||(o=e(this,k))!=null&&o.includes(l.pathname)?(e(this,h).classList.add("current"),e(this,h).classList.add("clicked")):e(this,h).classList.remove("clicked"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,H))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,_)),e(this,h).removeEventListener("pointerenter",e(this,H)),e(this,h).classList.remove("current")}}T=new WeakMap,h=new WeakMap,g=new WeakMap,R=new WeakMap,D=new WeakMap,k=new WeakMap,_=new WeakMap,H=new WeakMap;var B,F,I,j,C,v,U,M,b,E,W,Y,S,A,u,tt,et,gt,st,X;class yt{constructor(t){a(this,u);a(this,B,null);a(this,F,null);a(this,I,null);a(this,j,!1);a(this,C,null);a(this,v,[]);a(this,U,new DOMParser);a(this,M,new Map);a(this,b);a(this,E,null);a(this,W);a(this,Y);a(this,S,[]);a(this,A,null);a(this,X,t=>{t.state&&this.navigate(t.state,{historyAction:"none"})});if(wt.isBrowser){c(this,B,Q.normalizeBase(t==null?void 0:t.base)),c(this,F,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,I,(t==null?void 0:t.cachePages)!==!1),c(this,j,(t==null?void 0:t.trailingSlash)||!1),c(this,C,y(this,u,et).call(this,document.body));const s=this.normalizePath(location.pathname);c(this,E,s.pathname),document.documentElement.setAttribute("data-current-pathname",e(this,E)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),Q.changeHistory("replace",e(this,E),s.parameters,s.hash),e(this,C).map(n=>[...n.children]).flat().forEach(n=>{n instanceof HTMLElement&&n.classList.add("current")}),c(this,A,new pt)}}get currentPathname(){return e(this,E)}get previousPathname(){return e(this,W)}get currentState(){return e(this,Y)}get links(){return e(this,v)}normalizePath(t){return Q.splitPath(t,e(this,B),e(this,j))}prefetch(t){return O(this,null,function*(){const s=this.normalizePath(t);return y(this,u,tt).call(this,s.pathname)})}navigate(l){return O(this,arguments,function*(t,{historyAction:s="push",state:n}={}){var it;if(e(this,S).length)return;const d=this.normalizePath(t);let{pathname:o,hash:L,parameters:m,leaf:P}=d;if(e(this,b)===o||e(this,E)===o)return;c(this,Y,n),c(this,b,o);const N=e(this,M).has(o);try{mt.loading.add("__morph");let K=!0;if(J.dispatchEvent(document,"morphBeforeNavigation",{detail:{pathname:o,isCached:N,state:n}}),this.preprocessor)try{yield new Promise((i,f)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:o,resolve:i,reject:f,isCached:N,state:n})})}catch(i){i?console.error(i):console.log("Route change canceled"),K=!1}if(!K||e(this,b)!==o)return;const x=e(this,M).get(o)||(yield y(this,u,tt).call(this,o));if(e(this,b)!==o)return;if(x.title)e(this,A).textContent=x.title;else{const i=x.querySelector("h1"),f=(i==null?void 0:i.innerText)||(i==null?void 0:i.textContent)||o;e(this,A).textContent=f}document.body.appendChild(e(this,A));const nt=Array.from(document.head.children),rt=Array.from(x.head.cloneNode(!0).children),at=y(this,u,gt).call(this,nt,rt),Et=y(this,u,st).call(this,nt,at),V=y(this,u,st).call(this,rt,at);V.forEach((i,f)=>{if(i.tagName==="SCRIPT"&&i.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=i.getAttribute("src"),V[f]=w}}),V.forEach(i=>{document.head.appendChild(i)});const Z=V.filter(i=>!i.hasAttribute("data-no-waiting")&&(i.tagName==="STYLE"||i.tagName==="SCRIPT"||i.tagName==="LINK")&&i.getAttribute("rel")!=="canonical");e(this,F)&&Z.length&&(yield new Promise(i=>O(this,null,function*(){let f=0;try{for(var w=ut(Z),ht,z,ct;ht=!(z=yield w.next()).done;ht=!1){const G=z.value;G.onload=()=>{f++,f===Z.length&&i()}}}catch(z){ct=[z]}finally{try{ht&&(z=w.return)&&(yield z.call(w))}finally{if(ct)throw ct[0]}}})));const ot=[];Et.forEach(i=>{i.hasAttribute("data-permanent")||(i.tagName==="SCRIPT"||i.tagName==="STYLE"||i.getAttribute("rel")==="stylesheet"?ot.push(i):i.remove())}),c(this,W,e(this,E)),c(this,E,o),Q.changeHistory(s,o,m,L);const Lt=y(this,u,et).call(this,x.body.cloneNode(!0));e(this,C).forEach((i,f)=>{const w=Lt[f++],ht=getComputedStyle(i).getPropertyValue("--morph-duration"),z=[...w.childNodes];if(ht){const ct=[...i.childNodes];ct.forEach(p=>{p instanceof HTMLElement&&p.classList.add("old")}),z.forEach(p=>{p instanceof HTMLElement&&p.classList.add("new")}),i.append(...z),setTimeout(()=>{z.forEach(p=>{p instanceof HTMLElement&&p.classList.add("in")})},10);const G={element:i,pathname:o,isCached:N,state:n};J.dispatchEvent(document,"morphBeforeElementOut",{detail:G});const vt=new Promise(p=>{setTimeout(()=>{ct.forEach(q=>q.remove()),z.forEach(q=>{q instanceof HTMLElement&&(q.classList.remove("new","in"),q.classList.add("current"))}),J.dispatchEvent(document,"morphAfterElementOut",{detail:G}),p()},(parseFloat(ht)||0)*1e3+10)});e(this,S).push(vt)}else i.innerHTML="",i.append(...z)}),yield Promise.all(e(this,S)),ot.forEach(i=>i.remove()),c(this,S,[]),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",o),document.documentElement.setAttribute("data-current-leaf",P),e(this,A).remove(),(it=this.postprocessor)==null||it.call(this,{pathname:o,isCached:N,state:n}),J.dispatchEvent(document,"morphAfterNavigation",{detail:{pathname:o,isCached:N,state:n}}),mt.loading.complete("__morph")}catch(K){console.error(K)}c(this,b,void 0)})}addLink(t){e(this,v).push(new ft(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){c(this,v,e(this,v).filter(s=>s.element===t?(s.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(s=>{var n;return((n=s.getAttribute("href"))==null?void 0:n.startsWith("/"))&&!s.hasAttribute("download")&&!s.hasAttribute("data-morph-skip")&&!s.closest("[data-morph-skip]")});e(this,v).forEach(s=>s.destroy()),c(this,v,t.map(s=>new ft(s,this)))}}B=new WeakMap,F=new WeakMap,I=new WeakMap,j=new WeakMap,C=new WeakMap,v=new WeakMap,U=new WeakMap,M=new WeakMap,b=new WeakMap,E=new WeakMap,W=new WeakMap,Y=new WeakMap,S=new WeakMap,A=new WeakMap,u=new WeakSet,tt=function(t){return O(this,null,function*(){const s=e(this,M).get(t);if(s)return s;const l=yield(yield fetch(t)).text(),d=e(this,U).parseFromString(l,"text/html");return e(this,I)&&e(this,M).set(t,d),d})},et=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},gt=function(t,s){return t.filter(n=>s.find(l=>l.outerHTML===n.outerHTML))},st=function(t,s){return t.filter(n=>!s.find(l=>l.outerHTML===n.outerHTML))},X=new WeakMap;exports.Morph=yt;
1
+ "use strict";var lt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),dt=r=>{throw TypeError(r)};var $=(r,t,i)=>t.has(r)||dt("Cannot "+i);var e=(r,t,i)=>($(r,t,"read from private field"),i?i.call(r):t.get(r)),a=(r,t,i)=>t.has(r)?dt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,i),c=(r,t,i,n)=>($(r,t,"write to private field"),n?n.call(r,i):t.set(r,i),i),y=(r,t,i)=>($(r,t,"access private method"),i);var R=(r,t,i)=>new Promise((n,l)=>{var d=m=>{try{E(i.next(m))}catch(P){l(P)}},o=m=>{try{E(i.throw(m))}catch(P){l(P)}},E=m=>m.done?n(m.value):Promise.resolve(m.value).then(d,o);E((i=i.apply(r,t)).next())});var ut=(r,t,i)=>(t=r[lt("asyncIterator")])?t.call(r):(r=r[lt("iterator")](),t={},i=(n,l)=>(l=r[n])&&(t[n]=d=>new Promise((o,E,m)=>(d=l.call(r,d),m=d.done,Promise.resolve(d.value).then(P=>o({value:P,done:m}),E)))),i("next"),i("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const wt=require("../browser-CpzFX2xg.cjs"),J=require("../events-KVanG9sR.cjs"),Q=require("../url-CHQeS8b5.cjs"),mt=require("../loading/index.cjs");class pt extends HTMLElement{constructor(){super()}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[i,n]of Object.entries(t))this.setAttribute(i,n)}}customElements.get("morph-announcer")||customElements.define("morph-announcer",pt);var T,h,g,D,O,k,_,H;class ft{constructor(t,i){a(this,T);a(this,h);a(this,g);a(this,D);a(this,O);a(this,k);a(this,_,t=>{t.preventDefault(),e(this,T).links.forEach(i=>{var n;e(this,g)===e(i,g)||(n=e(i,k))!=null&&n.includes(e(this,g))?e(i,h).classList.add("clicked"):e(i,h).classList.remove("clicked")}),e(this,T).navigate(e(this,g),{historyAction:e(this,D),state:e(this,O)})});a(this,H,()=>{e(this,T).prefetch(e(this,g)),e(this,h).removeEventListener("pointerenter",e(this,H))});var d,o;c(this,T,i),c(this,h,t),c(this,g,e(this,h).getAttribute("href")||"/"),c(this,D,e(this,h).getAttribute("data-history-action")||"push"),c(this,O,e(this,h).getAttribute("data-state")||void 0),e(this,h).addEventListener("click",e(this,_));const n=i.normalizePath(e(this,g)),l=i.normalizePath(location.pathname);c(this,k,(d=e(this,h).getAttribute("data-match-paths"))==null?void 0:d.split(",").map(E=>i.normalizePath(E.trim()).pathname)),e(this,h).hasAttribute("data-include")?l.pathname.includes(n.pathname)&&e(this,h).classList.add("current"):n.pathname===l.pathname||(o=e(this,k))!=null&&o.includes(l.pathname)?(e(this,h).classList.add("current"),e(this,h).classList.add("clicked")):e(this,h).classList.remove("clicked"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,H))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,_)),e(this,h).removeEventListener("pointerenter",e(this,H)),e(this,h).classList.remove("current")}}T=new WeakMap,h=new WeakMap,g=new WeakMap,D=new WeakMap,O=new WeakMap,k=new WeakMap,_=new WeakMap,H=new WeakMap;var F,I,B,j,N,v,U,M,b,L,W,Y,C,A,u,tt,et,gt,it,X;class yt{constructor(t){a(this,u);a(this,F,null);a(this,I,null);a(this,B,null);a(this,j,!1);a(this,N,null);a(this,v,[]);a(this,U,new DOMParser);a(this,M,new Map);a(this,b);a(this,L,null);a(this,W);a(this,Y);a(this,C,[]);a(this,A,null);a(this,X,t=>{t.state&&this.navigate(t.state,{historyAction:"none"})});if(wt.isBrowser){c(this,F,Q.normalizeBase(t==null?void 0:t.base)),c(this,I,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,B,(t==null?void 0:t.cachePages)!==!1),c(this,j,(t==null?void 0:t.trailingSlash)||!1),c(this,N,y(this,u,et).call(this,document.body));const i=this.normalizePath(location.pathname);c(this,L,i.pathname),document.documentElement.setAttribute("data-current-pathname",e(this,L)),document.documentElement.setAttribute("data-current-leaf",i.leaf),this.findLinks(),addEventListener("popstate",e(this,X)),Q.changeHistory("replace",e(this,L),i.parameters,i.hash),e(this,N).map(n=>[...n.children]).flat().forEach(n=>{n instanceof HTMLElement&&n.classList.add("current")}),c(this,A,new pt)}}get currentPathname(){return e(this,L)}get previousPathname(){return e(this,W)}get currentState(){return e(this,Y)}get links(){return e(this,v)}normalizePath(t){return Q.splitPath(t,e(this,F),e(this,j))}prefetch(t){return R(this,null,function*(){const i=this.normalizePath(t);return y(this,u,tt).call(this,i.pathname)})}navigate(l){return R(this,arguments,function*(t,{historyAction:i="push",state:n}={}){var st;if(e(this,C).length)return;const d=this.normalizePath(t);let{pathname:o,hash:E,parameters:m,leaf:P}=d;if(e(this,b)===o||e(this,L)===o)return;c(this,Y,n),c(this,b,o);const x=e(this,M).has(o);try{mt.loading.add("__morph");let K=!0;if(this.preprocessor)try{yield new Promise((s,f)=>{var w;(w=this.preprocessor)==null||w.call(this,{pathname:o,resolve:s,reject:f,isCached:x,state:n})})}catch(s){s?console.error(s):console.log("Route change canceled"),K=!1}if(!K||e(this,b)!==o)return;const S=e(this,M).get(o)||(yield y(this,u,tt).call(this,o));if(e(this,b)!==o)return;if(S.title)e(this,A).textContent=S.title;else{const s=S.querySelector("h1"),f=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||o;e(this,A).textContent=f}document.body.appendChild(e(this,A)),J.dispatchEvent(document,"morphBeforeNavigation",{detail:{pathname:o,isCached:x,state:n,newDocument:S}});const nt=Array.from(document.head.children),rt=Array.from(S.head.cloneNode(!0).children),at=y(this,u,gt).call(this,nt,rt),Lt=y(this,u,it).call(this,nt,at),V=y(this,u,it).call(this,rt,at);V.forEach((s,f)=>{if(s.tagName==="SCRIPT"&&s.getAttribute("src")){const w=document.createElement("script");w.type="module",w.src=s.getAttribute("src"),V[f]=w}}),V.forEach(s=>{document.head.appendChild(s)});const Z=V.filter(s=>!s.hasAttribute("data-no-waiting")&&(s.tagName==="STYLE"||s.tagName==="SCRIPT"||s.tagName==="LINK")&&s.getAttribute("rel")!=="canonical");e(this,I)&&Z.length&&(yield new Promise(s=>R(this,null,function*(){let f=0;try{for(var w=ut(Z),ht,z,ct;ht=!(z=yield w.next()).done;ht=!1){const G=z.value;G.onload=()=>{f++,f===Z.length&&s()}}}catch(z){ct=[z]}finally{try{ht&&(z=w.return)&&(yield z.call(w))}finally{if(ct)throw ct[0]}}})));const ot=[];Lt.forEach(s=>{s.hasAttribute("data-permanent")||(s.tagName==="SCRIPT"||s.tagName==="STYLE"||s.getAttribute("rel")==="stylesheet"?ot.push(s):s.remove())}),c(this,W,e(this,L)),c(this,L,o),Q.changeHistory(i,o,m,E);const Et=y(this,u,et).call(this,S.body.cloneNode(!0));e(this,N).forEach((s,f)=>{const w=Et[f++],ht=getComputedStyle(s).getPropertyValue("--morph-duration"),z=[...w.childNodes];if(ht){const ct=[...s.childNodes];ct.forEach(p=>{p instanceof HTMLElement&&p.classList.add("old")}),z.forEach(p=>{p instanceof HTMLElement&&p.classList.add("new")}),s.append(...z),setTimeout(()=>{z.forEach(p=>{p instanceof HTMLElement&&p.classList.add("in")})},10);const G={element:s,pathname:o,isCached:x,state:n};J.dispatchEvent(document,"morphNewChildrenAdded",{detail:G});const vt=new Promise(p=>{setTimeout(()=>{ct.forEach(q=>q.remove()),z.forEach(q=>{q instanceof HTMLElement&&(q.classList.remove("new","in"),q.classList.add("current"))}),J.dispatchEvent(document,"morphOldChildrenRemoved",{detail:G}),p()},(parseFloat(ht)||0)*1e3+10)});e(this,C).push(vt)}else s.innerHTML="",s.append(...z)}),yield Promise.all(e(this,C)),ot.forEach(s=>s.remove()),c(this,C,[]),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",o),document.documentElement.setAttribute("data-current-leaf",P),e(this,A).remove(),(st=this.postprocessor)==null||st.call(this,{pathname:o,isCached:x,state:n}),J.dispatchEvent(document,"morphAfterNavigation",{detail:{pathname:o,isCached:x,state:n}}),mt.loading.complete("__morph")}catch(K){console.error(K)}c(this,b,void 0)})}addLink(t){e(this,v).push(new ft(t,this))}addLinks(t){t.forEach(i=>{this.addLink(i)})}removeLink(t){c(this,v,e(this,v).filter(i=>i.element===t?(i.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(i=>{var n;return((n=i.getAttribute("href"))==null?void 0:n.startsWith("/"))&&!i.hasAttribute("download")&&!i.hasAttribute("data-morph-skip")&&!i.closest("[data-morph-skip]")});e(this,v).forEach(i=>i.destroy()),c(this,v,t.map(i=>new ft(i,this)))}}F=new WeakMap,I=new WeakMap,B=new WeakMap,j=new WeakMap,N=new WeakMap,v=new WeakMap,U=new WeakMap,M=new WeakMap,b=new WeakMap,L=new WeakMap,W=new WeakMap,Y=new WeakMap,C=new WeakMap,A=new WeakMap,u=new WeakSet,tt=function(t){return R(this,null,function*(){const i=e(this,M).get(t);if(i)return i;const l=yield(yield fetch(t)).text(),d=e(this,U).parseFromString(l,"text/html");return e(this,B)&&e(this,M).set(t,d),d})},et=function(t){const i=[...t.querySelectorAll("[data-morph]")];return i.length?i:[t]},gt=function(t,i){return t.filter(n=>i.find(l=>l.outerHTML===n.outerHTML))},it=function(t,i){return t.filter(n=>!i.find(l=>l.outerHTML===n.outerHTML))},X=new WeakMap;exports.Morph=yt;
@@ -39,65 +39,65 @@ class pt extends HTMLElement {
39
39
  }
40
40
  }
41
41
  customElements.get("morph-announcer") || customElements.define("morph-announcer", pt);
42
- var T, h, g, O, B, C, F, H;
42
+ var T, h, g, F, I, H, O, S;
43
43
  class ft {
44
44
  constructor(t, s) {
45
45
  a(this, T);
46
46
  a(this, h);
47
47
  a(this, g);
48
- a(this, O);
49
- a(this, B);
50
- a(this, C);
51
- a(this, F, (t) => {
48
+ a(this, F);
49
+ a(this, I);
50
+ a(this, H);
51
+ a(this, O, (t) => {
52
52
  t.preventDefault(), e(this, T).links.forEach((s) => {
53
53
  var n;
54
- e(this, g) === e(s, g) || (n = e(s, C)) != null && n.includes(e(this, g)) ? e(s, h).classList.add("clicked") : e(s, h).classList.remove("clicked");
54
+ e(this, g) === e(s, g) || (n = e(s, H)) != null && n.includes(e(this, g)) ? e(s, h).classList.add("clicked") : e(s, h).classList.remove("clicked");
55
55
  }), e(this, T).navigate(e(this, g), {
56
- historyAction: e(this, O),
57
- state: e(this, B)
56
+ historyAction: e(this, F),
57
+ state: e(this, I)
58
58
  });
59
59
  });
60
- a(this, H, () => {
61
- e(this, T).prefetch(e(this, g)), e(this, h).removeEventListener("pointerenter", e(this, H));
60
+ a(this, S, () => {
61
+ e(this, T).prefetch(e(this, g)), e(this, h).removeEventListener("pointerenter", e(this, S));
62
62
  });
63
63
  var d, o;
64
- c(this, T, s), c(this, h, t), c(this, g, e(this, h).getAttribute("href") || "/"), c(this, O, e(this, h).getAttribute(
64
+ c(this, T, s), c(this, h, t), c(this, g, e(this, h).getAttribute("href") || "/"), c(this, F, e(this, h).getAttribute(
65
65
  "data-history-action"
66
- ) || "push"), c(this, B, e(this, h).getAttribute("data-state") || void 0), e(this, h).addEventListener("click", e(this, F));
66
+ ) || "push"), c(this, I, e(this, h).getAttribute("data-state") || void 0), e(this, h).addEventListener("click", e(this, O));
67
67
  const n = s.normalizePath(e(this, g)), l = s.normalizePath(location.pathname);
68
- c(this, C, (d = e(this, h).getAttribute("data-match-paths")) == null ? void 0 : d.split(",").map((E) => s.normalizePath(E.trim()).pathname)), e(this, h).hasAttribute("data-include") ? l.pathname.includes(n.pathname) && e(this, h).classList.add("current") : n.pathname === l.pathname || (o = e(this, C)) != null && o.includes(l.pathname) ? (e(this, h).classList.add("current"), e(this, h).classList.add("clicked")) : e(this, h).classList.remove("clicked"), e(this, h).hasAttribute("data-prefetch") && e(this, h).addEventListener("pointerenter", e(this, H));
68
+ c(this, H, (d = e(this, h).getAttribute("data-match-paths")) == null ? void 0 : d.split(",").map((E) => s.normalizePath(E.trim()).pathname)), e(this, h).hasAttribute("data-include") ? l.pathname.includes(n.pathname) && e(this, h).classList.add("current") : n.pathname === l.pathname || (o = e(this, H)) != null && o.includes(l.pathname) ? (e(this, h).classList.add("current"), e(this, h).classList.add("clicked")) : e(this, h).classList.remove("clicked"), e(this, h).hasAttribute("data-prefetch") && e(this, h).addEventListener("pointerenter", e(this, S));
69
69
  }
70
70
  get element() {
71
71
  return e(this, h);
72
72
  }
73
73
  destroy() {
74
- e(this, h).removeEventListener("click", e(this, F)), e(this, h).removeEventListener("pointerenter", e(this, H)), e(this, h).classList.remove("current");
74
+ e(this, h).removeEventListener("click", e(this, O)), e(this, h).removeEventListener("pointerenter", e(this, S)), e(this, h).classList.remove("current");
75
75
  }
76
76
  }
77
- T = new WeakMap(), h = new WeakMap(), g = new WeakMap(), O = new WeakMap(), B = new WeakMap(), C = new WeakMap(), F = new WeakMap(), H = new WeakMap();
78
- var I, _, q, W, S, v, Q, M, y, L, Y, j, k, b, u, $, tt, gt, et, U;
79
- class Ct {
77
+ T = new WeakMap(), h = new WeakMap(), g = new WeakMap(), F = new WeakMap(), I = new WeakMap(), H = new WeakMap(), O = new WeakMap(), S = new WeakMap();
78
+ var _, q, B, W, N, v, Q, C, y, L, Y, j, M, b, u, $, tt, gt, et, U;
79
+ class kt {
80
80
  constructor(t) {
81
81
  a(this, u);
82
- a(this, I, null);
83
82
  a(this, _, null);
84
83
  a(this, q, null);
84
+ a(this, B, null);
85
85
  a(this, W, !1);
86
- a(this, S, null);
86
+ a(this, N, null);
87
87
  a(this, v, []);
88
88
  a(this, Q, new DOMParser());
89
- a(this, M, /* @__PURE__ */ new Map());
89
+ a(this, C, /* @__PURE__ */ new Map());
90
90
  a(this, y);
91
91
  a(this, L, null);
92
92
  a(this, Y);
93
93
  a(this, j);
94
- a(this, k, []);
94
+ a(this, M, []);
95
95
  a(this, b, null);
96
96
  a(this, U, (t) => {
97
97
  t.state && this.navigate(t.state, { historyAction: "none" });
98
98
  });
99
99
  if (wt) {
100
- c(this, I, At(t == null ? void 0 : t.base)), c(this, _, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), c(this, q, (t == null ? void 0 : t.cachePages) !== !1), c(this, W, (t == null ? void 0 : t.trailingSlash) || !1), c(this, S, A(this, u, tt).call(this, document.body));
100
+ c(this, _, At(t == null ? void 0 : t.base)), c(this, q, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), c(this, B, (t == null ? void 0 : t.cachePages) !== !1), c(this, W, (t == null ? void 0 : t.trailingSlash) || !1), c(this, N, A(this, u, tt).call(this, document.body));
101
101
  const s = this.normalizePath(location.pathname);
102
102
  c(this, L, s.pathname), document.documentElement.setAttribute(
103
103
  "data-current-pathname",
@@ -110,7 +110,7 @@ class Ct {
110
110
  e(this, L),
111
111
  s.parameters,
112
112
  s.hash
113
- ), e(this, S).map((n) => [...n.children]).flat().forEach((n) => {
113
+ ), e(this, N).map((n) => [...n.children]).flat().forEach((n) => {
114
114
  n instanceof HTMLElement && n.classList.add("current");
115
115
  }), c(this, b, new pt());
116
116
  }
@@ -128,7 +128,7 @@ class Ct {
128
128
  return e(this, v);
129
129
  }
130
130
  normalizePath(t) {
131
- return yt(t, e(this, I), e(this, W));
131
+ return yt(t, e(this, _), e(this, W));
132
132
  }
133
133
  prefetch(t) {
134
134
  return D(this, null, function* () {
@@ -139,46 +139,47 @@ class Ct {
139
139
  navigate(l) {
140
140
  return D(this, arguments, function* (t, { historyAction: s = "push", state: n } = {}) {
141
141
  var st;
142
- if (e(this, k).length)
142
+ if (e(this, M).length)
143
143
  return;
144
144
  const d = this.normalizePath(t);
145
145
  let { pathname: o, hash: E, parameters: m, leaf: P } = d;
146
146
  if (e(this, y) === o || e(this, L) === o)
147
147
  return;
148
148
  c(this, j, n), c(this, y, o);
149
- const N = e(this, M).has(o);
149
+ const x = e(this, C).has(o);
150
150
  try {
151
151
  mt.add("__morph");
152
152
  let K = !0;
153
- if (J(document, "morphBeforeNavigation", {
154
- detail: {
155
- pathname: o,
156
- isCached: N,
157
- state: n
158
- }
159
- }), this.preprocessor)
153
+ if (this.preprocessor)
160
154
  try {
161
155
  yield new Promise((i, f) => {
162
156
  var w;
163
- (w = this.preprocessor) == null || w.call(this, { pathname: o, resolve: i, reject: f, isCached: N, state: n });
157
+ (w = this.preprocessor) == null || w.call(this, { pathname: o, resolve: i, reject: f, isCached: x, state: n });
164
158
  });
165
159
  } catch (i) {
166
160
  i ? console.error(i) : console.log("Route change canceled"), K = !1;
167
161
  }
168
162
  if (!K || e(this, y) !== o)
169
163
  return;
170
- const x = e(this, M).get(o) || (yield A(this, u, $).call(this, o));
164
+ const k = e(this, C).get(o) || (yield A(this, u, $).call(this, o));
171
165
  if (e(this, y) !== o)
172
166
  return;
173
- if (x.title)
174
- e(this, b).textContent = x.title;
167
+ if (k.title)
168
+ e(this, b).textContent = k.title;
175
169
  else {
176
- const i = x.querySelector("h1"), f = (i == null ? void 0 : i.innerText) || (i == null ? void 0 : i.textContent) || o;
170
+ const i = k.querySelector("h1"), f = (i == null ? void 0 : i.innerText) || (i == null ? void 0 : i.textContent) || o;
177
171
  e(this, b).textContent = f;
178
172
  }
179
- document.body.appendChild(e(this, b));
173
+ document.body.appendChild(e(this, b)), J(document, "morphBeforeNavigation", {
174
+ detail: {
175
+ pathname: o,
176
+ isCached: x,
177
+ state: n,
178
+ newDocument: k
179
+ }
180
+ });
180
181
  const it = Array.from(document.head.children), nt = Array.from(
181
- x.head.cloneNode(!0).children
182
+ k.head.cloneNode(!0).children
182
183
  ), rt = A(this, u, gt).call(this, it, nt), Lt = A(this, u, et).call(this, it, rt), V = A(this, u, et).call(this, nt, rt);
183
184
  V.forEach((i, f) => {
184
185
  if (i.tagName === "SCRIPT" && i.getAttribute("src")) {
@@ -191,7 +192,7 @@ class Ct {
191
192
  const X = V.filter(
192
193
  (i) => !i.hasAttribute("data-no-waiting") && (i.tagName === "STYLE" || i.tagName === "SCRIPT" || i.tagName === "LINK") && i.getAttribute("rel") !== "canonical"
193
194
  );
194
- e(this, _) && X.length && (yield new Promise((i) => D(this, null, function* () {
195
+ e(this, q) && X.length && (yield new Promise((i) => D(this, null, function* () {
195
196
  let f = 0;
196
197
  try {
197
198
  for (var w = dt(X), ot, z, ht; ot = !(z = yield w.next()).done; ot = !1) {
@@ -215,8 +216,8 @@ class Ct {
215
216
  Lt.forEach((i) => {
216
217
  i.hasAttribute("data-permanent") || (i.tagName === "SCRIPT" || i.tagName === "STYLE" || i.getAttribute("rel") === "stylesheet" ? at.push(i) : i.remove());
217
218
  }), c(this, Y, e(this, L)), c(this, L, o), ut(s, o, m, E);
218
- const Et = A(this, u, tt).call(this, x.body.cloneNode(!0));
219
- e(this, S).forEach((i, f) => {
219
+ const Et = A(this, u, tt).call(this, k.body.cloneNode(!0));
220
+ e(this, N).forEach((i, f) => {
220
221
  const w = Et[f++], ot = getComputedStyle(i).getPropertyValue("--morph-duration"), z = [...w.childNodes];
221
222
  if (ot) {
222
223
  const ht = [...i.childNodes];
@@ -232,28 +233,28 @@ class Ct {
232
233
  const G = {
233
234
  element: i,
234
235
  pathname: o,
235
- isCached: N,
236
+ isCached: x,
236
237
  state: n
237
238
  };
238
- J(document, "morphBeforeElementOut", {
239
+ J(document, "morphNewChildrenAdded", {
239
240
  detail: G
240
241
  });
241
242
  const vt = new Promise((p) => {
242
243
  setTimeout(() => {
243
244
  ht.forEach((R) => R.remove()), z.forEach((R) => {
244
245
  R instanceof HTMLElement && (R.classList.remove("new", "in"), R.classList.add("current"));
245
- }), J(document, "morphAfterElementOut", {
246
+ }), J(document, "morphOldChildrenRemoved", {
246
247
  detail: G
247
248
  }), p();
248
249
  }, (parseFloat(ot) || 0) * 1e3 + 10);
249
250
  });
250
- e(this, k).push(vt);
251
+ e(this, M).push(vt);
251
252
  } else
252
253
  i.innerHTML = "", i.append(...z);
253
- }), yield Promise.all(e(this, k)), at.forEach((i) => i.remove()), c(this, k, []), this.findLinks(), document.documentElement.setAttribute("data-current-pathname", o), document.documentElement.setAttribute("data-current-leaf", P), e(this, b).remove(), (st = this.postprocessor) == null || st.call(this, { pathname: o, isCached: N, state: n }), J(document, "morphAfterNavigation", {
254
+ }), yield Promise.all(e(this, M)), at.forEach((i) => i.remove()), c(this, M, []), this.findLinks(), document.documentElement.setAttribute("data-current-pathname", o), document.documentElement.setAttribute("data-current-leaf", P), e(this, b).remove(), (st = this.postprocessor) == null || st.call(this, { pathname: o, isCached: x, state: n }), J(document, "morphAfterNavigation", {
254
255
  detail: {
255
256
  pathname: o,
256
- isCached: N,
257
+ isCached: x,
257
258
  state: n
258
259
  }
259
260
  }), mt.complete("__morph");
@@ -286,13 +287,13 @@ class Ct {
286
287
  e(this, v).forEach((s) => s.destroy()), c(this, v, t.map((s) => new ft(s, this)));
287
288
  }
288
289
  }
289
- I = new WeakMap(), _ = new WeakMap(), q = new WeakMap(), W = new WeakMap(), S = new WeakMap(), v = new WeakMap(), Q = new WeakMap(), M = new WeakMap(), y = new WeakMap(), L = new WeakMap(), Y = new WeakMap(), j = new WeakMap(), k = new WeakMap(), b = new WeakMap(), u = new WeakSet(), $ = function(t) {
290
+ _ = new WeakMap(), q = new WeakMap(), B = new WeakMap(), W = new WeakMap(), N = new WeakMap(), v = new WeakMap(), Q = new WeakMap(), C = new WeakMap(), y = new WeakMap(), L = new WeakMap(), Y = new WeakMap(), j = new WeakMap(), M = new WeakMap(), b = new WeakMap(), u = new WeakSet(), $ = function(t) {
290
291
  return D(this, null, function* () {
291
- const s = e(this, M).get(t);
292
+ const s = e(this, C).get(t);
292
293
  if (s)
293
294
  return s;
294
295
  const l = yield (yield fetch(t)).text(), d = e(this, Q).parseFromString(l, "text/html");
295
- return e(this, q) && e(this, M).set(t, d), d;
296
+ return e(this, B) && e(this, C).set(t, d), d;
296
297
  });
297
298
  }, tt = function(t) {
298
299
  const s = [...t.querySelectorAll("[data-morph]")];
@@ -311,5 +312,5 @@ I = new WeakMap(), _ = new WeakMap(), q = new WeakMap(), W = new WeakMap(), S =
311
312
  );
312
313
  }, U = new WeakMap();
313
314
  export {
314
- Ct as Morph
315
+ kt as Morph
315
316
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"