aptechka 0.4.39 → 0.4.41

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.
@@ -20,6 +20,7 @@ export declare class Morph {
20
20
  preprocessor?: MorphPreprocessor;
21
21
  postprocessor?: MorphPostprocessor;
22
22
  constructor(parameters?: MorphParameters);
23
+ get currentPathname(): string;
23
24
  normalizePath(path: string): {
24
25
  leaf: string;
25
26
  pathname: string;
@@ -1 +1 @@
1
- "use strict";var rt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n);var J=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var s=(n,t,e)=>(J(n,t,"read from private field"),e?e.call(n):t.get(n)),o=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},a=(n,t,e,r)=>(J(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e);var m=(n,t,e)=>(J(n,t,"access private method"),e);var H=(n,t,e)=>new Promise((r,i)=>{var c=u=>{try{f(e.next(u))}catch(d){i(d)}},L=u=>{try{f(e.throw(u))}catch(d){i(d)}},f=u=>u.done?r(u.value):Promise.resolve(u.value).then(c,L);f((e=e.apply(n,t)).next())});var ot=(n,t,e)=>(t=n[rt("asyncIterator")])?t.call(n):(n=n[rt("iterator")](),t={},e=(r,i)=>(i=n[r])&&(t[r]=c=>new Promise((L,f,u)=>(c=i.call(n,c),u=c.done,Promise.resolve(c.value).then(d=>L({value:d,done:u}),f)))),e("next"),e("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ht=require("../notifier/index.cjs"),mt=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var y,l,b,A,N,M;class pt{constructor(t,e){o(this,y,void 0);o(this,l,void 0);o(this,b,void 0);o(this,A,void 0);o(this,N,t=>{t.preventDefault(),s(this,y).navigate(s(this,b),s(this,A))});o(this,M,()=>{s(this,y).prefetch(s(this,b)),s(this,l).removeEventListener("pointerenter",s(this,M))});a(this,y,e),a(this,l,t),a(this,b,s(this,l).getAttribute("href")||"/"),a(this,A,s(this,l).getAttribute("data-history-action")||"push"),s(this,l).addEventListener("click",s(this,N));const r=e.normalizePath(s(this,b)),i=e.normalizePath(location.pathname);s(this,l).hasAttribute("data-include")?i.pathname.includes(r.pathname)&&s(this,l).classList.add("current"):r.pathname===i.pathname&&s(this,l).classList.add("current"),s(this,l).hasAttribute("data-prefetch")&&s(this,l).addEventListener("pointerenter",s(this,M))}destroy(){s(this,l).removeEventListener("click",s(this,N)),s(this,l).removeEventListener("pointerenter",s(this,M)),s(this,l).classList.remove("current")}}y=new WeakMap,l=new WeakMap,b=new WeakMap,A=new WeakMap,N=new WeakMap,M=new WeakMap;var p,S,C,k,W,$,w,v,P,q,x,z,Q,D,U,R,V,j,at,F,X,B;class gt{constructor(t){o(this,z);o(this,D);o(this,R);o(this,j);o(this,F);o(this,p,null);o(this,S,null);o(this,C,null);o(this,k,null);o(this,W,[]);o(this,$,new DOMParser);o(this,w,new Map);o(this,v,void 0);o(this,P,null);o(this,q,new ht.Notifier);o(this,x,new ht.Notifier);o(this,B,t=>{t.state&&this.navigate(t.state,"none")});mt.isBrowser&&(a(this,p,(t==null?void 0:t.base)||"/"),t!=null&&t.base?(a(this,p,t.base),t.base.endsWith("/")||a(this,p,s(this,p)+"/")):a(this,p,"/"),a(this,S,(t==null?void 0:t.waitForHeadToLoad)!==!1),a(this,C,(t==null?void 0:t.cachePages)!==!1),a(this,k,m(this,R,V).call(this,document.body)),a(this,P,location.pathname),m(this,D,U).call(this),addEventListener("popstate",s(this,B)))}normalizePath(t){t=t.replace(s(this,p),""),t.startsWith("/")&&(t=t.slice(1));const e=t.split("#"),r=e[0].split("?"),i=r[0].endsWith("/")?r[0].slice(0,-1):r[0],c=s(this,p)+i,L=r==null?void 0:r[1],f=e==null?void 0:e[1];return{leaf:i,pathname:c,parameters:L,hash:f}}beforeNavigationEvent(t){return s(this,q).subscribe(t)}afterNavigationEvent(t){return s(this,x).subscribe(t)}prefetch(t){return H(this,null,function*(){const e=this.normalizePath(t);return m(this,z,Q).call(this,e.pathname)})}navigate(t,e="push"){return H(this,null,function*(){var u;const r=this.normalizePath(t);let{pathname:i,hash:c,parameters:L}=r;if(s(this,v)===i||s(this,P)===i)return;a(this,v,i);const f=s(this,w).has(i);try{let d=!0;if(s(this,q).notify({pathname:i,isCached:f}),this.preprocessor)try{yield new Promise((h,g)=>{var E;(E=this.preprocessor)==null||E.call(this,{pathname:i,resolve:h,reject:g,isCached:f})})}catch(h){h?console.error(h):console.log("Route change canceled"),d=!1}if(!d||s(this,v)!==i)return;const Z=s(this,w).get(i)||(yield m(this,z,Q).call(this,i));if(s(this,v)!==i)return;const tt=Array.from(document.head.children),et=Array.from(Z.head.cloneNode(!0).children),st=m(this,j,at).call(this,tt,et),ct=m(this,F,X).call(this,tt,st),I=m(this,F,X).call(this,et,st);ct.forEach(h=>{h.hasAttribute("data-permanent")||h.remove()}),I.forEach((h,g)=>{if(h.tagName==="SCRIPT"&&h.getAttribute("src")){const E=document.createElement("script");E.type="module",E.src=h.getAttribute("src"),I[g]=E}}),I.forEach(h=>{document.head.appendChild(h)});const K=I.filter(h=>h.tagName==="STYLE"||h.tagName==="SCRIPT"||h.tagName==="LINK");s(this,S)&&K.length&&(yield new Promise(h=>H(this,null,function*(){let g=0;try{for(var E=ot(K),dt,Y,T;dt=!(Y=yield E.next()).done;dt=!1){const _=Y.value;_.onload=()=>{g++,g===K.length&&h()}}}catch(Y){T=[Y]}finally{try{dt&&(Y=E.return)&&(yield Y.call(E))}finally{if(T)throw T[0]}}}))),a(this,P,i);const O=L||location.search,lt=c?c.startsWith("#")?c:"#"+c:"",ut=O?O.startsWith("?")?O:"?"+O:"",it=`${i}${lt}${ut}`;e==="push"?history.pushState(i,"",it):e==="replace"&&history.replaceState(i,"",it);const ft=m(this,R,V).call(this,Z.body.cloneNode(!0));s(this,k).forEach((h,g)=>{const E=ft[g];let dt=[...h.childNodes],Y=[...E.childNodes];dt.forEach(T=>{if(T instanceof HTMLElement){const _=T.hasAttribute("data-remain");let nt;Y=Y.filter(G=>G instanceof HTMLElement&&G.outerHTML===T.outerHTML?(nt=G,!1):!0),_&&nt||T.remove()}else T.remove()}),h.append(...Y)}),m(this,D,U).call(this),(u=this.postprocessor)==null||u.call(this,{pathname:i,isCached:f}),s(this,x).notify({pathname:i,isCached:f})}catch(d){console.error(d)}a(this,v,void 0)})}}p=new WeakMap,S=new WeakMap,C=new WeakMap,k=new WeakMap,W=new WeakMap,$=new WeakMap,w=new WeakMap,v=new WeakMap,P=new WeakMap,q=new WeakMap,x=new WeakMap,z=new WeakSet,Q=function(t){return H(this,null,function*(){const e=s(this,w).get(t);if(e)return e;const i=yield(yield fetch(t)).text(),c=s(this,$).parseFromString(i,"text/html");return s(this,C)&&s(this,w).set(t,c),c})},D=new WeakSet,U=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(e=>{var r;return(r=e.getAttribute("href"))==null?void 0:r.startsWith("/")});s(this,W).forEach(e=>e.destroy()),a(this,W,t.map(e=>new pt(e,this)))},R=new WeakSet,V=function(t){return[...t.querySelectorAll("[data-morph]")]},j=new WeakSet,at=function(t,e){return t.filter(r=>e.find(i=>i.outerHTML===r.outerHTML))},F=new WeakSet,X=function(t,e){return t.filter(r=>!e.find(i=>i.outerHTML===r.outerHTML))},B=new WeakMap;exports.Morph=gt;
1
+ "use strict";var rt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n);var J=(n,t,e)=>{if(!t.has(n))throw TypeError("Cannot "+e)};var i=(n,t,e)=>(J(n,t,"read from private field"),e?e.call(n):t.get(n)),o=(n,t,e)=>{if(t.has(n))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(n):t.set(n,e)},c=(n,t,e,r)=>(J(n,t,"write to private field"),r?r.call(n,e):t.set(n,e),e);var p=(n,t,e)=>(J(n,t,"access private method"),e);var T=(n,t,e)=>new Promise((r,s)=>{var h=d=>{try{u(e.next(d))}catch(m){s(m)}},f=d=>{try{u(e.throw(d))}catch(m){s(m)}},u=d=>d.done?r(d.value):Promise.resolve(d.value).then(h,f);u((e=e.apply(n,t)).next())});var ot=(n,t,e)=>(t=n[rt("asyncIterator")])?t.call(n):(n=n[rt("iterator")](),t={},e=(r,s)=>(s=n[r])&&(t[r]=h=>new Promise((f,u,d)=>(h=s.call(n,h),d=h.done,Promise.resolve(h.value).then(m=>f({value:m,done:d}),u)))),e("next"),e("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const at=require("../notifier/index.cjs"),mt=require("../browser-CpzFX2xg.cjs");require("../path-data-polyfill-CXsOR7Oc.cjs");var P,l,w,H,N,M;class pt{constructor(t,e){o(this,P,void 0);o(this,l,void 0);o(this,w,void 0);o(this,H,void 0);o(this,N,t=>{t.preventDefault(),i(this,P).navigate(i(this,w),i(this,H))});o(this,M,()=>{i(this,P).prefetch(i(this,w)),i(this,l).removeEventListener("pointerenter",i(this,M))});var f;c(this,P,e),c(this,l,t),c(this,w,i(this,l).getAttribute("href")||"/"),c(this,H,i(this,l).getAttribute("data-history-action")||"push"),i(this,l).addEventListener("click",i(this,N));const r=e.normalizePath(i(this,w)),s=e.normalizePath(location.pathname),h=(f=i(this,l).getAttribute("data-match-paths"))==null?void 0:f.split(",").map(u=>e.normalizePath(u.trim()).pathname);i(this,l).hasAttribute("data-include")?s.pathname.includes(r.pathname)&&i(this,l).classList.add("current"):(r.pathname===s.pathname||h!=null&&h.includes(s.pathname))&&i(this,l).classList.add("current"),i(this,l).hasAttribute("data-prefetch")&&i(this,l).addEventListener("pointerenter",i(this,M))}destroy(){i(this,l).removeEventListener("click",i(this,N)),i(this,l).removeEventListener("pointerenter",i(this,M)),i(this,l).classList.remove("current")}}P=new WeakMap,l=new WeakMap,w=new WeakMap,H=new WeakMap,N=new WeakMap,M=new WeakMap;var g,S,C,k,z,$,y,v,L,W,q,x,Q,D,U,R,V,j,ht,F,X,B;class gt{constructor(t){o(this,x);o(this,D);o(this,R);o(this,j);o(this,F);o(this,g,null);o(this,S,null);o(this,C,null);o(this,k,null);o(this,z,[]);o(this,$,new DOMParser);o(this,y,new Map);o(this,v,void 0);o(this,L,null);o(this,W,new at.Notifier);o(this,q,new at.Notifier);o(this,B,t=>{t.state&&this.navigate(t.state,"none")});mt.isBrowser&&(c(this,g,(t==null?void 0:t.base)||"/"),t!=null&&t.base?(c(this,g,t.base),t.base.endsWith("/")||c(this,g,i(this,g)+"/")):c(this,g,"/"),c(this,S,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,C,(t==null?void 0:t.cachePages)!==!1),c(this,k,p(this,R,V).call(this,document.body)),c(this,L,this.normalizePath(location.pathname).pathname),document.documentElement.setAttribute("data-current-pathname",i(this,L)),p(this,D,U).call(this),addEventListener("popstate",i(this,B)))}get currentPathname(){return i(this,L)}normalizePath(t){t=t.replace(i(this,g),""),t.startsWith("/")&&(t=t.slice(1));const e=t.split("#"),r=e[0].split("?"),s=r[0].endsWith("/")?r[0].slice(0,-1):r[0],h=i(this,g)+s,f=r==null?void 0:r[1],u=e==null?void 0:e[1];return{leaf:s,pathname:h,parameters:f,hash:u}}beforeNavigationEvent(t){return i(this,W).subscribe(t)}afterNavigationEvent(t){return i(this,q).subscribe(t)}prefetch(t){return T(this,null,function*(){const e=this.normalizePath(t);return p(this,x,Q).call(this,e.pathname)})}navigate(t,e="push"){return T(this,null,function*(){var d;const r=this.normalizePath(t);let{pathname:s,hash:h,parameters:f}=r;if(i(this,v)===s||i(this,L)===s)return;c(this,v,s);const u=i(this,y).has(s);try{let m=!0;if(i(this,W).notify({pathname:s,isCached:u}),this.preprocessor)try{yield new Promise((a,E)=>{var b;(b=this.preprocessor)==null||b.call(this,{pathname:s,resolve:a,reject:E,isCached:u})})}catch(a){a?console.error(a):console.log("Route change canceled"),m=!1}if(!m||i(this,v)!==s)return;const Z=i(this,y).get(s)||(yield p(this,x,Q).call(this,s));if(i(this,v)!==s)return;const tt=Array.from(document.head.children),et=Array.from(Z.head.cloneNode(!0).children),it=p(this,j,ht).call(this,tt,et),ct=p(this,F,X).call(this,tt,it),I=p(this,F,X).call(this,et,it);ct.forEach(a=>{a.hasAttribute("data-permanent")||a.remove()}),I.forEach((a,E)=>{if(a.tagName==="SCRIPT"&&a.getAttribute("src")){const b=document.createElement("script");b.type="module",b.src=a.getAttribute("src"),I[E]=b}}),I.forEach(a=>{document.head.appendChild(a)});const K=I.filter(a=>a.tagName==="STYLE"||a.tagName==="SCRIPT"||a.tagName==="LINK");i(this,S)&&K.length&&(yield new Promise(a=>T(this,null,function*(){let E=0;try{for(var b=ot(K),ft,Y,A;ft=!(Y=yield b.next()).done;ft=!1){const _=Y.value;_.onload=()=>{E++,E===K.length&&a()}}}catch(Y){A=[Y]}finally{try{ft&&(Y=b.return)&&(yield Y.call(b))}finally{if(A)throw A[0]}}}))),c(this,L,s);const O=f||location.search,lt=h?h.startsWith("#")?h:"#"+h:"",ut=O?O.startsWith("?")?O:"?"+O:"",st=`${s}${lt}${ut}`;e==="push"?history.pushState(s,"",st):e==="replace"&&history.replaceState(s,"",st);const dt=p(this,R,V).call(this,Z.body.cloneNode(!0));i(this,k).forEach((a,E)=>{const b=dt[E];let ft=[...a.childNodes],Y=[...b.childNodes];ft.forEach(A=>{if(A instanceof HTMLElement){const _=A.hasAttribute("data-remain");let nt;Y=Y.filter(G=>G instanceof HTMLElement&&G.outerHTML===A.outerHTML?(nt=G,!1):!0),_&&nt||A.remove()}else A.remove()}),a.append(...Y)}),p(this,D,U).call(this),document.documentElement.setAttribute("data-current-pathname",s),(d=this.postprocessor)==null||d.call(this,{pathname:s,isCached:u}),i(this,q).notify({pathname:s,isCached:u})}catch(m){console.error(m)}c(this,v,void 0)})}}g=new WeakMap,S=new WeakMap,C=new WeakMap,k=new WeakMap,z=new WeakMap,$=new WeakMap,y=new WeakMap,v=new WeakMap,L=new WeakMap,W=new WeakMap,q=new WeakMap,x=new WeakSet,Q=function(t){return T(this,null,function*(){const e=i(this,y).get(t);if(e)return e;const s=yield(yield fetch(t)).text(),h=i(this,$).parseFromString(s,"text/html");return i(this,C)&&i(this,y).set(t,h),h})},D=new WeakSet,U=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(e=>{var r;return(r=e.getAttribute("href"))==null?void 0:r.startsWith("/")});i(this,z).forEach(e=>e.destroy()),c(this,z,t.map(e=>new pt(e,this)))},R=new WeakSet,V=function(t){return[...t.querySelectorAll("[data-morph]")]},j=new WeakSet,ht=function(t,e){return t.filter(r=>e.find(s=>s.outerHTML===r.outerHTML))},F=new WeakSet,X=function(t,e){return t.filter(r=>!e.find(s=>s.outerHTML===r.outerHTML))},B=new WeakMap;exports.Morph=gt;
@@ -3,197 +3,204 @@ var Q = (n, t, e) => {
3
3
  if (!t.has(n))
4
4
  throw TypeError("Cannot " + e);
5
5
  };
6
- var s = (n, t, e) => (Q(n, t, "read from private field"), e ? e.call(n) : t.get(n)), o = (n, t, e) => {
6
+ var s = (n, t, e) => (Q(n, t, "read from private field"), e ? e.call(n) : t.get(n)), a = (n, t, e) => {
7
7
  if (t.has(n))
8
8
  throw TypeError("Cannot add the same private member more than once");
9
9
  t instanceof WeakSet ? t.add(n) : t.set(n, e);
10
- }, a = (n, t, e, r) => (Q(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e);
11
- var m = (n, t, e) => (Q(n, t, "access private method"), e);
12
- var T = (n, t, e) => new Promise((r, i) => {
13
- var c = (u) => {
10
+ }, c = (n, t, e, r) => (Q(n, t, "write to private field"), r ? r.call(n, e) : t.set(n, e), e);
11
+ var p = (n, t, e) => (Q(n, t, "access private method"), e);
12
+ var H = (n, t, e) => new Promise((r, i) => {
13
+ var h = (d) => {
14
14
  try {
15
- f(e.next(u));
16
- } catch (d) {
17
- i(d);
15
+ u(e.next(d));
16
+ } catch (m) {
17
+ i(m);
18
18
  }
19
- }, v = (u) => {
19
+ }, f = (d) => {
20
20
  try {
21
- f(e.throw(u));
22
- } catch (d) {
23
- i(d);
21
+ u(e.throw(d));
22
+ } catch (m) {
23
+ i(m);
24
24
  }
25
- }, f = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(c, v);
26
- f((e = e.apply(n, t)).next());
25
+ }, u = (d) => d.done ? r(d.value) : Promise.resolve(d.value).then(h, f);
26
+ u((e = e.apply(n, t)).next());
27
27
  });
28
- var ot = (n, t, e) => (t = n[rt("asyncIterator")]) ? t.call(n) : (n = n[rt("iterator")](), t = {}, e = (r, i) => (i = n[r]) && (t[r] = (c) => new Promise((v, f, u) => (c = i.call(n, c), u = c.done, Promise.resolve(c.value).then((d) => v({ value: d, done: u }), f)))), e("next"), e("return"), t);
29
- import { Notifier as ht } from "../notifier/index.js";
28
+ var at = (n, t, e) => (t = n[rt("asyncIterator")]) ? t.call(n) : (n = n[rt("iterator")](), t = {}, e = (r, i) => (i = n[r]) && (t[r] = (h) => new Promise((f, u, d) => (h = i.call(n, h), d = h.done, Promise.resolve(h.value).then((m) => f({ value: m, done: d }), u)))), e("next"), e("return"), t);
29
+ import { Notifier as ot } from "../notifier/index.js";
30
30
  import { i as mt } from "../browser-0zX67oeU.js";
31
31
  import "../path-data-polyfill-DgeDWYeI.js";
32
- var y, l, w, A, N, M;
32
+ var P, l, w, T, N, A;
33
33
  class pt {
34
34
  constructor(t, e) {
35
- o(this, y, void 0);
36
- o(this, l, void 0);
37
- o(this, w, void 0);
38
- o(this, A, void 0);
39
- o(this, N, (t) => {
40
- t.preventDefault(), s(this, y).navigate(s(this, w), s(this, A));
35
+ a(this, P, void 0);
36
+ a(this, l, void 0);
37
+ a(this, w, void 0);
38
+ a(this, T, void 0);
39
+ a(this, N, (t) => {
40
+ t.preventDefault(), s(this, P).navigate(s(this, w), s(this, T));
41
41
  });
42
- o(this, M, () => {
43
- s(this, y).prefetch(s(this, w)), s(this, l).removeEventListener("pointerenter", s(this, M));
42
+ a(this, A, () => {
43
+ s(this, P).prefetch(s(this, w)), s(this, l).removeEventListener("pointerenter", s(this, A));
44
44
  });
45
- a(this, y, e), a(this, l, t), a(this, w, s(this, l).getAttribute("href") || "/"), a(this, A, s(this, l).getAttribute(
45
+ var f;
46
+ c(this, P, e), c(this, l, t), c(this, w, s(this, l).getAttribute("href") || "/"), c(this, T, s(this, l).getAttribute(
46
47
  "data-history-action"
47
48
  ) || "push"), s(this, l).addEventListener("click", s(this, N));
48
- const r = e.normalizePath(s(this, w)), i = e.normalizePath(location.pathname);
49
- s(this, l).hasAttribute("data-include") ? i.pathname.includes(r.pathname) && s(this, l).classList.add("current") : r.pathname === i.pathname && s(this, l).classList.add("current"), s(this, l).hasAttribute("data-prefetch") && s(this, l).addEventListener("pointerenter", s(this, M));
49
+ const r = e.normalizePath(s(this, w)), i = e.normalizePath(location.pathname), h = (f = s(this, l).getAttribute("data-match-paths")) == null ? void 0 : f.split(",").map((u) => e.normalizePath(u.trim()).pathname);
50
+ s(this, l).hasAttribute("data-include") ? i.pathname.includes(r.pathname) && s(this, l).classList.add("current") : (r.pathname === i.pathname || h != null && h.includes(i.pathname)) && s(this, l).classList.add("current"), s(this, l).hasAttribute("data-prefetch") && s(this, l).addEventListener("pointerenter", s(this, A));
50
51
  }
51
52
  destroy() {
52
- s(this, l).removeEventListener("click", s(this, N)), s(this, l).removeEventListener("pointerenter", s(this, M)), s(this, l).classList.remove("current");
53
+ s(this, l).removeEventListener("click", s(this, N)), s(this, l).removeEventListener("pointerenter", s(this, A)), s(this, l).classList.remove("current");
53
54
  }
54
55
  }
55
- y = new WeakMap(), l = new WeakMap(), w = new WeakMap(), A = new WeakMap(), N = new WeakMap(), M = new WeakMap();
56
- var p, C, S, k, W, O, b, L, P, x, z, D, U, R, V, F, X, B, at, I, Z, K;
57
- class wt {
56
+ P = new WeakMap(), l = new WeakMap(), w = new WeakMap(), T = new WeakMap(), N = new WeakMap(), A = new WeakMap();
57
+ var E, C, S, k, z, O, y, v, b, W, x, D, U, R, V, F, X, B, ht, I, Z, K;
58
+ class bt {
58
59
  constructor(t) {
59
- o(this, D);
60
- o(this, R);
61
- o(this, F);
62
- o(this, B);
63
- o(this, I);
64
- o(this, p, null);
65
- o(this, C, null);
66
- o(this, S, null);
67
- o(this, k, null);
68
- o(this, W, []);
69
- o(this, O, new DOMParser());
70
- o(this, b, /* @__PURE__ */ new Map());
71
- o(this, L, void 0);
72
- o(this, P, null);
73
- o(this, x, new ht());
74
- o(this, z, new ht());
75
- o(this, K, (t) => {
60
+ a(this, D);
61
+ a(this, R);
62
+ a(this, F);
63
+ a(this, B);
64
+ a(this, I);
65
+ a(this, E, null);
66
+ a(this, C, null);
67
+ a(this, S, null);
68
+ a(this, k, null);
69
+ a(this, z, []);
70
+ a(this, O, new DOMParser());
71
+ a(this, y, /* @__PURE__ */ new Map());
72
+ a(this, v, void 0);
73
+ a(this, b, null);
74
+ a(this, W, new ot());
75
+ a(this, x, new ot());
76
+ a(this, K, (t) => {
76
77
  t.state && this.navigate(t.state, "none");
77
78
  });
78
- mt && (a(this, p, (t == null ? void 0 : t.base) || "/"), t != null && t.base ? (a(this, p, t.base), t.base.endsWith("/") || a(this, p, s(this, p) + "/")) : a(this, p, "/"), a(this, C, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), a(this, S, (t == null ? void 0 : t.cachePages) !== !1), a(this, k, m(this, F, X).call(this, document.body)), a(this, P, location.pathname), m(this, R, V).call(this), addEventListener("popstate", s(this, K)));
79
+ mt && (c(this, E, (t == null ? void 0 : t.base) || "/"), t != null && t.base ? (c(this, E, t.base), t.base.endsWith("/") || c(this, E, s(this, E) + "/")) : c(this, E, "/"), c(this, C, (t == null ? void 0 : t.waitForHeadToLoad) !== !1), c(this, S, (t == null ? void 0 : t.cachePages) !== !1), c(this, k, p(this, F, X).call(this, document.body)), c(this, b, this.normalizePath(location.pathname).pathname), document.documentElement.setAttribute(
80
+ "data-current-pathname",
81
+ s(this, b)
82
+ ), p(this, R, V).call(this), addEventListener("popstate", s(this, K)));
83
+ }
84
+ get currentPathname() {
85
+ return s(this, b);
79
86
  }
80
87
  normalizePath(t) {
81
- t = t.replace(s(this, p), ""), t.startsWith("/") && (t = t.slice(1));
82
- const e = t.split("#"), r = e[0].split("?"), i = r[0].endsWith("/") ? r[0].slice(0, -1) : r[0], c = s(this, p) + i, v = r == null ? void 0 : r[1], f = e == null ? void 0 : e[1];
88
+ t = t.replace(s(this, E), ""), t.startsWith("/") && (t = t.slice(1));
89
+ const e = t.split("#"), r = e[0].split("?"), i = r[0].endsWith("/") ? r[0].slice(0, -1) : r[0], h = s(this, E) + i, f = r == null ? void 0 : r[1], u = e == null ? void 0 : e[1];
83
90
  return {
84
91
  leaf: i,
85
- pathname: c,
86
- parameters: v,
87
- hash: f
92
+ pathname: h,
93
+ parameters: f,
94
+ hash: u
88
95
  };
89
96
  }
90
97
  beforeNavigationEvent(t) {
91
- return s(this, x).subscribe(t);
98
+ return s(this, W).subscribe(t);
92
99
  }
93
100
  afterNavigationEvent(t) {
94
- return s(this, z).subscribe(t);
101
+ return s(this, x).subscribe(t);
95
102
  }
96
103
  prefetch(t) {
97
- return T(this, null, function* () {
104
+ return H(this, null, function* () {
98
105
  const e = this.normalizePath(t);
99
- return m(this, D, U).call(this, e.pathname);
106
+ return p(this, D, U).call(this, e.pathname);
100
107
  });
101
108
  }
102
109
  navigate(t, e = "push") {
103
- return T(this, null, function* () {
104
- var u;
110
+ return H(this, null, function* () {
111
+ var d;
105
112
  const r = this.normalizePath(t);
106
- let { pathname: i, hash: c, parameters: v } = r;
107
- if (s(this, L) === i || s(this, P) === i)
113
+ let { pathname: i, hash: h, parameters: f } = r;
114
+ if (s(this, v) === i || s(this, b) === i)
108
115
  return;
109
- a(this, L, i);
110
- const f = s(this, b).has(i);
116
+ c(this, v, i);
117
+ const u = s(this, y).has(i);
111
118
  try {
112
- let d = !0;
113
- if (s(this, x).notify({
119
+ let m = !0;
120
+ if (s(this, W).notify({
114
121
  pathname: i,
115
- isCached: f
122
+ isCached: u
116
123
  }), this.preprocessor)
117
124
  try {
118
- yield new Promise((h, E) => {
119
- var g;
120
- (g = this.preprocessor) == null || g.call(this, { pathname: i, resolve: h, reject: E, isCached: f });
125
+ yield new Promise((o, g) => {
126
+ var L;
127
+ (L = this.preprocessor) == null || L.call(this, { pathname: i, resolve: o, reject: g, isCached: u });
121
128
  });
122
- } catch (h) {
123
- h ? console.error(h) : console.log("Route change canceled"), d = !1;
129
+ } catch (o) {
130
+ o ? console.error(o) : console.log("Route change canceled"), m = !1;
124
131
  }
125
- if (!d || s(this, L) !== i)
132
+ if (!m || s(this, v) !== i)
126
133
  return;
127
- const _ = s(this, b).get(i) || (yield m(this, D, U).call(this, i));
128
- if (s(this, L) !== i)
134
+ const _ = s(this, y).get(i) || (yield p(this, D, U).call(this, i));
135
+ if (s(this, v) !== i)
129
136
  return;
130
137
  const tt = Array.from(document.head.children), et = Array.from(
131
138
  _.head.cloneNode(!0).children
132
- ), st = m(this, B, at).call(this, tt, et), ct = m(this, I, Z).call(this, tt, st), $ = m(this, I, Z).call(this, et, st);
133
- ct.forEach((h) => {
134
- h.hasAttribute("data-permanent") || h.remove();
135
- }), $.forEach((h, E) => {
136
- if (h.tagName === "SCRIPT" && h.getAttribute("src")) {
137
- const g = document.createElement("script");
138
- g.type = "module", g.src = h.getAttribute("src"), $[E] = g;
139
+ ), st = p(this, B, ht).call(this, tt, et), ct = p(this, I, Z).call(this, tt, st), $ = p(this, I, Z).call(this, et, st);
140
+ ct.forEach((o) => {
141
+ o.hasAttribute("data-permanent") || o.remove();
142
+ }), $.forEach((o, g) => {
143
+ if (o.tagName === "SCRIPT" && o.getAttribute("src")) {
144
+ const L = document.createElement("script");
145
+ L.type = "module", L.src = o.getAttribute("src"), $[g] = L;
139
146
  }
140
- }), $.forEach((h) => {
141
- document.head.appendChild(h);
147
+ }), $.forEach((o) => {
148
+ document.head.appendChild(o);
142
149
  });
143
150
  const Y = $.filter(
144
- (h) => h.tagName === "STYLE" || h.tagName === "SCRIPT" || h.tagName === "LINK"
151
+ (o) => o.tagName === "STYLE" || o.tagName === "SCRIPT" || o.tagName === "LINK"
145
152
  );
146
- s(this, C) && Y.length && (yield new Promise((h) => T(this, null, function* () {
147
- let E = 0;
153
+ s(this, C) && Y.length && (yield new Promise((o) => H(this, null, function* () {
154
+ let g = 0;
148
155
  try {
149
- for (var g = ot(Y), dt, j, H; dt = !(j = yield g.next()).done; dt = !1) {
156
+ for (var L = at(Y), ft, j, M; ft = !(j = yield L.next()).done; ft = !1) {
150
157
  const G = j.value;
151
158
  G.onload = () => {
152
- E++, E === Y.length && h();
159
+ g++, g === Y.length && o();
153
160
  };
154
161
  }
155
162
  } catch (j) {
156
- H = [j];
163
+ M = [j];
157
164
  } finally {
158
165
  try {
159
- dt && (j = g.return) && (yield j.call(g));
166
+ ft && (j = L.return) && (yield j.call(L));
160
167
  } finally {
161
- if (H)
162
- throw H[0];
168
+ if (M)
169
+ throw M[0];
163
170
  }
164
171
  }
165
- }))), a(this, P, i);
166
- const q = v || location.search, lt = c ? c.startsWith("#") ? c : "#" + c : "", ut = q ? q.startsWith("?") ? q : "?" + q : "", it = `${i}${lt}${ut}`;
172
+ }))), c(this, b, i);
173
+ const q = f || location.search, lt = h ? h.startsWith("#") ? h : "#" + h : "", ut = q ? q.startsWith("?") ? q : "?" + q : "", it = `${i}${lt}${ut}`;
167
174
  e === "push" ? history.pushState(i, "", it) : e === "replace" && history.replaceState(i, "", it);
168
- const ft = m(this, F, X).call(this, _.body.cloneNode(!0));
169
- s(this, k).forEach((h, E) => {
170
- const g = ft[E];
171
- let dt = [...h.childNodes], j = [...g.childNodes];
172
- dt.forEach((H) => {
173
- if (H instanceof HTMLElement) {
174
- const G = H.hasAttribute("data-remain");
175
+ const dt = p(this, F, X).call(this, _.body.cloneNode(!0));
176
+ s(this, k).forEach((o, g) => {
177
+ const L = dt[g];
178
+ let ft = [...o.childNodes], j = [...L.childNodes];
179
+ ft.forEach((M) => {
180
+ if (M instanceof HTMLElement) {
181
+ const G = M.hasAttribute("data-remain");
175
182
  let nt;
176
183
  j = j.filter(
177
- (J) => J instanceof HTMLElement && J.outerHTML === H.outerHTML ? (nt = J, !1) : !0
178
- ), G && nt || H.remove();
184
+ (J) => J instanceof HTMLElement && J.outerHTML === M.outerHTML ? (nt = J, !1) : !0
185
+ ), G && nt || M.remove();
179
186
  } else
180
- H.remove();
181
- }), h.append(...j);
182
- }), m(this, R, V).call(this), (u = this.postprocessor) == null || u.call(this, { pathname: i, isCached: f }), s(this, z).notify({ pathname: i, isCached: f });
183
- } catch (d) {
184
- console.error(d);
187
+ M.remove();
188
+ }), o.append(...j);
189
+ }), p(this, R, V).call(this), document.documentElement.setAttribute("data-current-pathname", i), (d = this.postprocessor) == null || d.call(this, { pathname: i, isCached: u }), s(this, x).notify({ pathname: i, isCached: u });
190
+ } catch (m) {
191
+ console.error(m);
185
192
  }
186
- a(this, L, void 0);
193
+ c(this, v, void 0);
187
194
  });
188
195
  }
189
196
  }
190
- p = new WeakMap(), C = new WeakMap(), S = new WeakMap(), k = new WeakMap(), W = new WeakMap(), O = new WeakMap(), b = new WeakMap(), L = new WeakMap(), P = new WeakMap(), x = new WeakMap(), z = new WeakMap(), D = new WeakSet(), U = function(t) {
191
- return T(this, null, function* () {
192
- const e = s(this, b).get(t);
197
+ E = new WeakMap(), C = new WeakMap(), S = new WeakMap(), k = new WeakMap(), z = new WeakMap(), O = new WeakMap(), y = new WeakMap(), v = new WeakMap(), b = new WeakMap(), W = new WeakMap(), x = new WeakMap(), D = new WeakSet(), U = function(t) {
198
+ return H(this, null, function* () {
199
+ const e = s(this, y).get(t);
193
200
  if (e)
194
201
  return e;
195
- const i = yield (yield fetch(t)).text(), c = s(this, O).parseFromString(i, "text/html");
196
- return s(this, S) && s(this, b).set(t, c), c;
202
+ const i = yield (yield fetch(t)).text(), h = s(this, O).parseFromString(i, "text/html");
203
+ return s(this, S) && s(this, y).set(t, h), h;
197
204
  });
198
205
  }, R = new WeakSet(), V = function() {
199
206
  const t = [
@@ -202,10 +209,10 @@ p = new WeakMap(), C = new WeakMap(), S = new WeakMap(), k = new WeakMap(), W =
202
209
  var r;
203
210
  return (r = e.getAttribute("href")) == null ? void 0 : r.startsWith("/");
204
211
  });
205
- s(this, W).forEach((e) => e.destroy()), a(this, W, t.map((e) => new pt(e, this)));
212
+ s(this, z).forEach((e) => e.destroy()), c(this, z, t.map((e) => new pt(e, this)));
206
213
  }, F = new WeakSet(), X = function(t) {
207
214
  return [...t.querySelectorAll("[data-morph]")];
208
- }, B = new WeakSet(), at = function(t, e) {
215
+ }, B = new WeakSet(), ht = function(t, e) {
209
216
  return t.filter(
210
217
  (r) => e.find(
211
218
  (i) => i.outerHTML === r.outerHTML
@@ -219,5 +226,5 @@ p = new WeakMap(), C = new WeakMap(), S = new WeakMap(), k = new WeakMap(), W =
219
226
  );
220
227
  }, K = new WeakMap();
221
228
  export {
222
- wt as Morph
229
+ bt as Morph
223
230
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aptechka",
3
- "version": "0.4.39",
3
+ "version": "0.4.41",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/denisavitski/aptechka.git"