aptechka 0.4.16 → 0.4.17

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