aptechka 0.42.5 → 0.42.7
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 +18 -18
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ot=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),ht=n=>{throw TypeError(n)};var Q=(n,t,i)=>t.has(n)||ht("Cannot "+i);var e=(n,t,i)=>(Q(n,t,"read from private field"),i?i.call(n):t.get(n)),o=(n,t,i)=>t.has(n)?ht("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,i),c=(n,t,i,s)=>(Q(n,t,"write to private field"),s?s.call(n,i):t.set(n,i),i),
|
|
1
|
+
"use strict";var ot=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),ht=n=>{throw TypeError(n)};var Q=(n,t,i)=>t.has(n)||ht("Cannot "+i);var e=(n,t,i)=>(Q(n,t,"read from private field"),i?i.call(n):t.get(n)),o=(n,t,i)=>t.has(n)?ht("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,i),c=(n,t,i,s)=>(Q(n,t,"write to private field"),s?s.call(n,i):t.set(n,i),i),A=(n,t,i)=>(Q(n,t,"access private method"),i);var z=(n,t,i)=>new Promise((s,l)=>{var u=f=>{try{g(i.next(f))}catch(b){l(b)}},a=f=>{try{g(i.throw(f))}catch(b){l(b)}},g=f=>f.done?s(f.value):Promise.resolve(f.value).then(u,a);g((i=i.apply(n,t)).next())});var ct=(n,t,i)=>(t=n[ot("asyncIterator")])?t.call(n):(n=n[ot("iterator")](),t={},i=(s,l)=>(l=n[s])&&(t[s]=u=>new Promise((a,g,f)=>(u=l.call(n,u),f=u.done,Promise.resolve(u.value).then(b=>a({value:b,done:f}),g)))),i("next"),i("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pt=require("../browser-CpzFX2xg.cjs"),K=require("../events-KVanG9sR.cjs"),V=require("../url-BiHPIsKq.cjs"),dt=require("../loading/index.cjs");var T,h,p,q,x,H,D,k;class lt{constructor(t,i){o(this,T);o(this,h);o(this,p);o(this,q);o(this,x);o(this,H);o(this,D,t=>{t.preventDefault(),e(this,T).links.forEach(i=>{var s;e(this,p)===e(i,p)||(s=e(i,H))!=null&&s.includes(e(this,p))?e(i,h).classList.add("clicked"):e(i,h).classList.remove("clicked")}),e(this,T).navigate(e(this,p),{historyAction:e(this,q),state:e(this,x)})});o(this,k,()=>{e(this,T).prefetch(e(this,p)),e(this,h).removeEventListener("pointerenter",e(this,k))});var u,a;c(this,T,i),c(this,h,t),c(this,p,e(this,h).getAttribute("href")||"/"),c(this,q,e(this,h).getAttribute("data-history-action")||"push"),c(this,x,e(this,h).getAttribute("data-state")||void 0),e(this,h).addEventListener("click",e(this,D));const s=i.normalizePath(e(this,p)),l=i.normalizePath(location.pathname);c(this,H,(u=e(this,h).getAttribute("data-match-paths"))==null?void 0:u.split(",").map(g=>i.normalizePath(g.trim()).pathname)),e(this,h).hasAttribute("data-include")?l.pathname.includes(s.pathname)&&e(this,h).classList.add("current"):s.pathname===l.pathname||(a=e(this,H))!=null&&a.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,k))}get element(){return e(this,h)}destroy(){e(this,h).removeEventListener("click",e(this,D)),e(this,h).removeEventListener("pointerenter",e(this,k)),e(this,h).classList.remove("current")}}T=new WeakMap,h=new WeakMap,p=new WeakMap,q=new WeakMap,x=new WeakMap,H=new WeakMap,D=new WeakMap,k=new WeakMap;var I,O,R,S,E,Y,M,P,L,_,B,v,m,U,X,ut,Z,G;class Lt{constructor(t){o(this,m);o(this,I,null);o(this,O,null);o(this,R,null);o(this,S,null);o(this,E,[]);o(this,Y,new DOMParser);o(this,M,new Map);o(this,P);o(this,L,null);o(this,_);o(this,B);o(this,v,[]);o(this,G,t=>{t.state&&this.navigate(t.state,{historyAction:"none"})});if(pt.isBrowser){c(this,I,V.normalizeBase(t==null?void 0:t.base)),c(this,O,(t==null?void 0:t.waitForHeadToLoad)!==!1),c(this,R,(t==null?void 0:t.cachePages)!==!1),c(this,S,A(this,m,X).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,G)),V.changeHistory("replace",e(this,L),i.parameters,i.hash),e(this,S).map(s=>[...s.children]).flat().forEach(s=>{s instanceof HTMLElement&&s.classList.add("current")})}}get currentPathname(){return e(this,L)}get previousPathname(){return e(this,_)}get currentState(){return e(this,B)}get links(){return e(this,E)}normalizePath(t){return V.splitPath(t,e(this,I))}prefetch(t){return z(this,null,function*(){const i=this.normalizePath(t);return A(this,m,U).call(this,i.pathname)})}navigate(l){return z(this,arguments,function*(t,{historyAction:i="push",state:s}={}){var $;if(e(this,v).length)return;const u=this.normalizePath(t);let{pathname:a,hash:g,parameters:f,leaf:b}=u;if(e(this,P)===a||e(this,L)===a)return;c(this,B,s),c(this,P,a);const N=e(this,M).has(a);try{dt.loading.add("__morph");let F=!0;if(K.dispatchEvent(document,"morphBeforeNavigation",{detail:{pathname:a,isCached:N,state:s}}),this.preprocessor)try{yield new Promise((r,w)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:a,resolve:r,reject:w,isCached:N,state:s})})}catch(r){r?console.error(r):console.log("Route change canceled"),F=!1}if(!F||e(this,P)!==a)return;const tt=e(this,M).get(a)||(yield A(this,m,U).call(this,a));if(e(this,P)!==a)return;const et=Array.from(document.head.children),it=Array.from(tt.head.cloneNode(!0).children),st=A(this,m,ut).call(this,et,it),mt=A(this,m,Z).call(this,et,st),W=A(this,m,Z).call(this,it,st);W.forEach((r,w)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),W[w]=y}}),W.forEach(r=>{document.head.appendChild(r)});const J=W.filter(r=>(r.tagName==="STYLE"||r.tagName==="SCRIPT"||r.tagName==="LINK")&&r.getAttribute("rel")!=="canonical");e(this,O)&&J.length&&(yield new Promise(r=>z(this,null,function*(){let w=0;try{for(var y=ct(J),nt,C,rt;nt=!(C=yield y.next()).done;nt=!1){const j=C.value;j.onload=()=>{w++,w===J.length&&r()}}}catch(C){rt=[C]}finally{try{nt&&(C=y.return)&&(yield C.call(y))}finally{if(rt)throw rt[0]}}}))),mt.forEach(r=>{r.hasAttribute("data-permanent")||r.remove()}),c(this,_,e(this,L)),c(this,L,a),V.changeHistory(i,a,f,g);const ft=A(this,m,X).call(this,tt.body.cloneNode(!0));e(this,v).forEach(r=>clearTimeout(r)),c(this,v,[]),e(this,S).forEach((r,w)=>{const y=ft[w],nt=getComputedStyle(r).getPropertyValue("--morph-duration"),C=[...y.childNodes];if(nt){const rt=[...r.childNodes];rt.forEach(d=>{d instanceof HTMLElement&&d.classList.add("old")}),C.forEach(d=>{d instanceof HTMLElement&&d.classList.add("new")}),r.append(...C),setTimeout(()=>{C.forEach(d=>{d instanceof HTMLElement&&d.classList.add("in")})},10);const j={element:r,pathname:a,isCached:N,state:s};K.dispatchEvent(document,"morphBeforeElementOut",{detail:j});const at=setTimeout(()=>{rt.forEach(d=>d.remove()),C.forEach(d=>{d instanceof HTMLElement&&(d.classList.remove("new","in"),d.classList.add("current"))}),K.dispatchEvent(document,"morphAfterElementOut",{detail:j}),c(this,v,e(this,v).filter(d=>d!==at))},(parseFloat(nt)||0)*1e3+10);e(this,v).push(at)}else r.innerHTML="",r.append(...C)}),this.findLinks(),document.documentElement.setAttribute("data-current-pathname",a),document.documentElement.setAttribute("data-current-leaf",b),($=this.postprocessor)==null||$.call(this,{pathname:a,isCached:N,state:s}),K.dispatchEvent(document,"morphAfterNavigation",{detail:{pathname:a,isCached:N,state:s}}),dt.loading.complete("__morph")}catch(F){console.error(F)}c(this,P,void 0)})}addLink(t){e(this,E).push(new lt(t,this))}addLinks(t){t.forEach(i=>{this.addLink(i)})}removeLink(t){c(this,E,e(this,E).filter(i=>i.element===t?(i.destroy(),!1):!0))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(i=>{var s;return((s=i.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!i.hasAttribute("download")&&!i.hasAttribute("data-morph-skip")&&!i.closest("[data-morph-skip]")});e(this,E).forEach(i=>i.destroy()),c(this,E,t.map(i=>new lt(i,this)))}}I=new WeakMap,O=new WeakMap,R=new WeakMap,S=new WeakMap,E=new WeakMap,Y=new WeakMap,M=new WeakMap,P=new WeakMap,L=new WeakMap,_=new WeakMap,B=new WeakMap,v=new WeakMap,m=new WeakSet,U=function(t){return z(this,null,function*(){const i=e(this,M).get(t);if(i)return i;const l=yield(yield fetch(t)).text(),u=e(this,Y).parseFromString(l,"text/html");return e(this,R)&&e(this,M).set(t,u),u})},X=function(t){const i=[...t.querySelectorAll("[data-morph]")];return i.length?i:[t]},ut=function(t,i){return t.filter(s=>i.find(l=>l.outerHTML===s.outerHTML))},Z=function(t,i){return t.filter(s=>!i.find(l=>l.outerHTML===s.outerHTML))},G=new WeakMap;exports.Morph=Lt;
|
package/lib/morph/index.js
CHANGED
|
@@ -6,23 +6,23 @@ var e = (n, t, s) => (J(n, t, "read from private field"), s ? s.call(n) : t.get(
|
|
|
6
6
|
var z = (n, t, s) => new Promise((i, l) => {
|
|
7
7
|
var u = (f) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
E(s.next(f));
|
|
10
10
|
} catch (b) {
|
|
11
11
|
l(b);
|
|
12
12
|
}
|
|
13
13
|
}, r = (f) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
E(s.throw(f));
|
|
16
16
|
} catch (b) {
|
|
17
17
|
l(b);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, E = (f) => f.done ? i(f.value) : Promise.resolve(f.value).then(u, r);
|
|
20
|
+
E((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var ht = (n, t, s) => (t = n[rt("asyncIterator")]) ? t.call(n) : (n = n[rt("iterator")](), t = {}, s = (i, l) => (l = n[i]) && (t[i] = (u) => new Promise((r,
|
|
22
|
+
var ht = (n, t, s) => (t = n[rt("asyncIterator")]) ? t.call(n) : (n = n[rt("iterator")](), t = {}, s = (i, l) => (l = n[i]) && (t[i] = (u) => new Promise((r, E, f) => (u = l.call(n, u), f = u.done, Promise.resolve(u.value).then((b) => r({ value: b, done: f }), E)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as pt } from "../browser-0zX67oeU.js";
|
|
24
24
|
import { d as V } from "../events-CsVF98U6.js";
|
|
25
|
-
import { n as Lt, c as ct, s as
|
|
25
|
+
import { n as Lt, c as ct, s as Et } from "../url-B5eH5z6S.js";
|
|
26
26
|
import { loading as dt } from "../loading/index.js";
|
|
27
27
|
var T, h, p, x, D, H, I, M;
|
|
28
28
|
class lt {
|
|
@@ -50,7 +50,7 @@ class lt {
|
|
|
50
50
|
"data-history-action"
|
|
51
51
|
) || "push"), c(this, D, e(this, h).getAttribute("data-state") || void 0), e(this, h).addEventListener("click", e(this, I));
|
|
52
52
|
const i = s.normalizePath(e(this, p)), l = s.normalizePath(location.pathname);
|
|
53
|
-
c(this, H, (u = e(this, h).getAttribute("data-match-paths")) == null ? void 0 : u.split(",").map((
|
|
53
|
+
c(this, H, (u = e(this, h).getAttribute("data-match-paths")) == null ? void 0 : u.split(",").map((E) => s.normalizePath(E.trim()).pathname)), e(this, h).hasAttribute("data-include") ? l.pathname.includes(i.pathname) && e(this, h).classList.add("current") : i.pathname === l.pathname || (r = e(this, H)) != null && r.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, M));
|
|
54
54
|
}
|
|
55
55
|
get element() {
|
|
56
56
|
return e(this, h);
|
|
@@ -60,7 +60,7 @@ class lt {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
T = new WeakMap(), h = new WeakMap(), p = new WeakMap(), x = new WeakMap(), D = new WeakMap(), H = new WeakMap(), I = new WeakMap(), M = new WeakMap();
|
|
63
|
-
var R, B, F, N,
|
|
63
|
+
var R, B, F, N, g, Y, k, y, L, O, _, v, m, Q, U, ut, X, j;
|
|
64
64
|
class yt {
|
|
65
65
|
constructor(t) {
|
|
66
66
|
o(this, m);
|
|
@@ -68,7 +68,7 @@ class yt {
|
|
|
68
68
|
o(this, B, null);
|
|
69
69
|
o(this, F, null);
|
|
70
70
|
o(this, N, null);
|
|
71
|
-
o(this,
|
|
71
|
+
o(this, g, []);
|
|
72
72
|
o(this, Y, new DOMParser());
|
|
73
73
|
o(this, k, /* @__PURE__ */ new Map());
|
|
74
74
|
o(this, y);
|
|
@@ -108,10 +108,10 @@ class yt {
|
|
|
108
108
|
return e(this, _);
|
|
109
109
|
}
|
|
110
110
|
get links() {
|
|
111
|
-
return e(this,
|
|
111
|
+
return e(this, g);
|
|
112
112
|
}
|
|
113
113
|
normalizePath(t) {
|
|
114
|
-
return
|
|
114
|
+
return Et(t, e(this, R));
|
|
115
115
|
}
|
|
116
116
|
prefetch(t) {
|
|
117
117
|
return z(this, null, function* () {
|
|
@@ -125,7 +125,7 @@ class yt {
|
|
|
125
125
|
if (e(this, v).length)
|
|
126
126
|
return;
|
|
127
127
|
const u = this.normalizePath(t);
|
|
128
|
-
let { pathname: r, hash:
|
|
128
|
+
let { pathname: r, hash: E, parameters: f, leaf: b } = u;
|
|
129
129
|
if (e(this, y) === r || e(this, L) === r)
|
|
130
130
|
return;
|
|
131
131
|
c(this, _, i), c(this, y, r);
|
|
@@ -165,7 +165,7 @@ class yt {
|
|
|
165
165
|
document.head.appendChild(a);
|
|
166
166
|
});
|
|
167
167
|
const G = W.filter(
|
|
168
|
-
(a) =>
|
|
168
|
+
(a) => (a.tagName === "STYLE" || a.tagName === "SCRIPT" || a.tagName === "LINK") && a.getAttribute("rel") !== "canonical"
|
|
169
169
|
);
|
|
170
170
|
e(this, B) && G.length && (yield new Promise((a) => z(this, null, function* () {
|
|
171
171
|
let A = 0;
|
|
@@ -188,7 +188,7 @@ class yt {
|
|
|
188
188
|
}
|
|
189
189
|
}))), mt.forEach((a) => {
|
|
190
190
|
a.hasAttribute("data-permanent") || a.remove();
|
|
191
|
-
}), c(this, O, e(this, L)), c(this, L, r), ct(s, r, f,
|
|
191
|
+
}), c(this, O, e(this, L)), c(this, L, r), ct(s, r, f, E);
|
|
192
192
|
const ft = P(this, m, U).call(this, $.body.cloneNode(!0));
|
|
193
193
|
e(this, v).forEach((a) => clearTimeout(a)), c(this, v, []), e(this, N).forEach((a, A) => {
|
|
194
194
|
const w = ft[A], it = getComputedStyle(a).getPropertyValue("--morph-duration"), S = [...w.childNodes];
|
|
@@ -236,7 +236,7 @@ class yt {
|
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
238
|
addLink(t) {
|
|
239
|
-
e(this,
|
|
239
|
+
e(this, g).push(new lt(t, this));
|
|
240
240
|
}
|
|
241
241
|
addLinks(t) {
|
|
242
242
|
t.forEach((s) => {
|
|
@@ -244,7 +244,7 @@ class yt {
|
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
removeLink(t) {
|
|
247
|
-
c(this,
|
|
247
|
+
c(this, g, e(this, g).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
248
248
|
}
|
|
249
249
|
findLinks() {
|
|
250
250
|
const t = [
|
|
@@ -255,10 +255,10 @@ class yt {
|
|
|
255
255
|
return ((i = s.getAttribute("href")) == null ? void 0 : i.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]");
|
|
256
256
|
}
|
|
257
257
|
);
|
|
258
|
-
e(this,
|
|
258
|
+
e(this, g).forEach((s) => s.destroy()), c(this, g, t.map((s) => new lt(s, this)));
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
|
-
R = new WeakMap(), B = new WeakMap(), F = new WeakMap(), N = new WeakMap(),
|
|
261
|
+
R = new WeakMap(), B = new WeakMap(), F = new WeakMap(), N = new WeakMap(), g = new WeakMap(), Y = new WeakMap(), k = new WeakMap(), y = new WeakMap(), L = new WeakMap(), O = new WeakMap(), _ = new WeakMap(), v = new WeakMap(), m = new WeakSet(), Q = function(t) {
|
|
262
262
|
return z(this, null, function* () {
|
|
263
263
|
const s = e(this, k).get(t);
|
|
264
264
|
if (s)
|