aptechka 0.42.10 → 0.43.0
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/Morph.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ChangeHistoryAction } from '../utils';
|
|
2
|
-
import {
|
|
2
|
+
import { MorphLink } from './MorphLink';
|
|
3
3
|
export interface MorphParameters {
|
|
4
4
|
base?: string;
|
|
5
5
|
waitForHeadToLoad?: boolean;
|
|
@@ -42,7 +42,7 @@ export declare class Morph {
|
|
|
42
42
|
get currentPathname(): string;
|
|
43
43
|
get previousPathname(): string | undefined;
|
|
44
44
|
get currentState(): any;
|
|
45
|
-
get links():
|
|
45
|
+
get links(): MorphLink[];
|
|
46
46
|
normalizePath(path: string): {
|
|
47
47
|
leaf: string;
|
|
48
48
|
pathname: string;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,288 +1,315 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var ct = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), lt = (r) => {
|
|
2
|
+
throw TypeError(r);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var e = (
|
|
6
|
-
var
|
|
7
|
-
var
|
|
4
|
+
var Z = (r, t, s) => t.has(r) || lt("Cannot " + s);
|
|
5
|
+
var e = (r, t, s) => (Z(r, t, "read from private field"), s ? s.call(r) : t.get(r)), a = (r, t, s) => t.has(r) ? lt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), c = (r, t, s, n) => (Z(r, t, "write to private field"), n ? n.call(r, s) : t.set(r, s), s), A = (r, t, s) => (Z(r, t, "access private method"), s);
|
|
6
|
+
var D = (r, t, s) => new Promise((n, l) => {
|
|
7
|
+
var d = (m) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
10
|
-
} catch (
|
|
11
|
-
|
|
9
|
+
E(s.next(m));
|
|
10
|
+
} catch (P) {
|
|
11
|
+
l(P);
|
|
12
12
|
}
|
|
13
|
-
}, o = (
|
|
13
|
+
}, o = (m) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
15
|
+
E(s.throw(m));
|
|
16
|
+
} catch (P) {
|
|
17
|
+
l(P);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, E = (m) => m.done ? n(m.value) : Promise.resolve(m.value).then(d, o);
|
|
20
|
+
E((s = s.apply(r, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var
|
|
23
|
-
import { i as
|
|
24
|
-
import { d as
|
|
25
|
-
import { n as
|
|
26
|
-
import { loading as
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
22
|
+
var dt = (r, t, s) => (t = r[ct("asyncIterator")]) ? t.call(r) : (r = r[ct("iterator")](), t = {}, s = (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)))), s("next"), s("return"), t);
|
|
23
|
+
import { i as wt } from "../browser-0zX67oeU.js";
|
|
24
|
+
import { d as J } from "../events-CsVF98U6.js";
|
|
25
|
+
import { n as At, c as ut, s as yt } from "../url-DqQuzXwT.js";
|
|
26
|
+
import { loading as mt } from "../loading/index.js";
|
|
27
|
+
class pt extends HTMLElement {
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
}
|
|
31
|
+
connectedCallback() {
|
|
32
|
+
const t = {
|
|
33
|
+
"aria-live": "assertive",
|
|
34
|
+
"aria-atomic": "true",
|
|
35
|
+
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"
|
|
36
|
+
};
|
|
37
|
+
for (const [s, n] of Object.entries(t))
|
|
38
|
+
this.setAttribute(s, n);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
customElements.get("morph-announcer") || customElements.define("morph-announcer", pt);
|
|
42
|
+
var T, h, g, O, B, C, F, H;
|
|
43
|
+
class ft {
|
|
44
|
+
constructor(t, s) {
|
|
45
|
+
a(this, T);
|
|
46
|
+
a(this, h);
|
|
47
|
+
a(this, g);
|
|
48
|
+
a(this, O);
|
|
49
|
+
a(this, B);
|
|
50
|
+
a(this, C);
|
|
51
|
+
a(this, F, (t) => {
|
|
52
|
+
t.preventDefault(), e(this, T).links.forEach((s) => {
|
|
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");
|
|
55
|
+
}), e(this, T).navigate(e(this, g), {
|
|
56
|
+
historyAction: e(this, O),
|
|
57
|
+
state: e(this, B)
|
|
43
58
|
});
|
|
44
59
|
});
|
|
45
|
-
|
|
46
|
-
e(this, T).prefetch(e(this,
|
|
60
|
+
a(this, H, () => {
|
|
61
|
+
e(this, T).prefetch(e(this, g)), e(this, h).removeEventListener("pointerenter", e(this, H));
|
|
47
62
|
});
|
|
48
|
-
var
|
|
49
|
-
c(this, T,
|
|
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(
|
|
50
65
|
"data-history-action"
|
|
51
|
-
) || "push"), c(this,
|
|
52
|
-
const
|
|
53
|
-
c(this,
|
|
66
|
+
) || "push"), c(this, B, e(this, h).getAttribute("data-state") || void 0), e(this, h).addEventListener("click", e(this, F));
|
|
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));
|
|
54
69
|
}
|
|
55
70
|
get element() {
|
|
56
71
|
return e(this, h);
|
|
57
72
|
}
|
|
58
73
|
destroy() {
|
|
59
|
-
e(this, h).removeEventListener("click", e(this,
|
|
74
|
+
e(this, h).removeEventListener("click", e(this, F)), e(this, h).removeEventListener("pointerenter", e(this, H)), e(this, h).classList.remove("current");
|
|
60
75
|
}
|
|
61
76
|
}
|
|
62
|
-
T = new WeakMap(), h = new WeakMap(),
|
|
63
|
-
var
|
|
64
|
-
class
|
|
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 {
|
|
65
80
|
constructor(t) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
a(this, u);
|
|
82
|
+
a(this, I, null);
|
|
83
|
+
a(this, _, null);
|
|
84
|
+
a(this, q, null);
|
|
85
|
+
a(this, W, !1);
|
|
86
|
+
a(this, S, null);
|
|
87
|
+
a(this, v, []);
|
|
88
|
+
a(this, Q, new DOMParser());
|
|
89
|
+
a(this, M, /* @__PURE__ */ new Map());
|
|
90
|
+
a(this, y);
|
|
91
|
+
a(this, L, null);
|
|
92
|
+
a(this, Y);
|
|
93
|
+
a(this, j);
|
|
94
|
+
a(this, k, []);
|
|
95
|
+
a(this, b, null);
|
|
96
|
+
a(this, U, (t) => {
|
|
81
97
|
t.state && this.navigate(t.state, { historyAction: "none" });
|
|
82
98
|
});
|
|
83
|
-
if (
|
|
84
|
-
c(this,
|
|
85
|
-
const
|
|
86
|
-
c(this, L,
|
|
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));
|
|
101
|
+
const s = this.normalizePath(location.pathname);
|
|
102
|
+
c(this, L, s.pathname), document.documentElement.setAttribute(
|
|
87
103
|
"data-current-pathname",
|
|
88
104
|
e(this, L)
|
|
89
105
|
), document.documentElement.setAttribute(
|
|
90
106
|
"data-current-leaf",
|
|
91
|
-
|
|
92
|
-
), this.findLinks(), addEventListener("popstate", e(this,
|
|
107
|
+
s.leaf
|
|
108
|
+
), this.findLinks(), addEventListener("popstate", e(this, U)), ut(
|
|
93
109
|
"replace",
|
|
94
110
|
e(this, L),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
), e(this, S).map((
|
|
98
|
-
|
|
99
|
-
});
|
|
111
|
+
s.parameters,
|
|
112
|
+
s.hash
|
|
113
|
+
), e(this, S).map((n) => [...n.children]).flat().forEach((n) => {
|
|
114
|
+
n instanceof HTMLElement && n.classList.add("current");
|
|
115
|
+
}), c(this, b, new pt());
|
|
100
116
|
}
|
|
101
117
|
}
|
|
102
118
|
get currentPathname() {
|
|
103
119
|
return e(this, L);
|
|
104
120
|
}
|
|
105
121
|
get previousPathname() {
|
|
106
|
-
return e(this,
|
|
122
|
+
return e(this, Y);
|
|
107
123
|
}
|
|
108
124
|
get currentState() {
|
|
109
|
-
return e(this,
|
|
125
|
+
return e(this, j);
|
|
110
126
|
}
|
|
111
127
|
get links() {
|
|
112
|
-
return e(this,
|
|
128
|
+
return e(this, v);
|
|
113
129
|
}
|
|
114
130
|
normalizePath(t) {
|
|
115
|
-
return
|
|
131
|
+
return yt(t, e(this, I), e(this, W));
|
|
116
132
|
}
|
|
117
133
|
prefetch(t) {
|
|
118
|
-
return
|
|
119
|
-
const
|
|
120
|
-
return
|
|
134
|
+
return D(this, null, function* () {
|
|
135
|
+
const s = this.normalizePath(t);
|
|
136
|
+
return A(this, u, $).call(this, s.pathname);
|
|
121
137
|
});
|
|
122
138
|
}
|
|
123
|
-
navigate(
|
|
124
|
-
return
|
|
125
|
-
var
|
|
126
|
-
if (e(this,
|
|
139
|
+
navigate(l) {
|
|
140
|
+
return D(this, arguments, function* (t, { historyAction: s = "push", state: n } = {}) {
|
|
141
|
+
var st;
|
|
142
|
+
if (e(this, k).length)
|
|
127
143
|
return;
|
|
128
|
-
const
|
|
129
|
-
let { pathname: o, hash:
|
|
144
|
+
const d = this.normalizePath(t);
|
|
145
|
+
let { pathname: o, hash: E, parameters: m, leaf: P } = d;
|
|
130
146
|
if (e(this, y) === o || e(this, L) === o)
|
|
131
147
|
return;
|
|
132
|
-
c(this,
|
|
133
|
-
const N = e(this,
|
|
148
|
+
c(this, j, n), c(this, y, o);
|
|
149
|
+
const N = e(this, M).has(o);
|
|
134
150
|
try {
|
|
135
|
-
|
|
136
|
-
let
|
|
137
|
-
if (
|
|
151
|
+
mt.add("__morph");
|
|
152
|
+
let K = !0;
|
|
153
|
+
if (J(document, "morphBeforeNavigation", {
|
|
138
154
|
detail: {
|
|
139
155
|
pathname: o,
|
|
140
156
|
isCached: N,
|
|
141
|
-
state:
|
|
157
|
+
state: n
|
|
142
158
|
}
|
|
143
159
|
}), this.preprocessor)
|
|
144
160
|
try {
|
|
145
|
-
yield new Promise((
|
|
161
|
+
yield new Promise((i, f) => {
|
|
146
162
|
var w;
|
|
147
|
-
(w = this.preprocessor) == null || w.call(this, { pathname: o, resolve:
|
|
163
|
+
(w = this.preprocessor) == null || w.call(this, { pathname: o, resolve: i, reject: f, isCached: N, state: n });
|
|
148
164
|
});
|
|
149
|
-
} catch (
|
|
150
|
-
|
|
165
|
+
} catch (i) {
|
|
166
|
+
i ? console.error(i) : console.log("Route change canceled"), K = !1;
|
|
151
167
|
}
|
|
152
|
-
if (!
|
|
168
|
+
if (!K || e(this, y) !== o)
|
|
153
169
|
return;
|
|
154
|
-
const
|
|
170
|
+
const x = e(this, M).get(o) || (yield A(this, u, $).call(this, o));
|
|
155
171
|
if (e(this, y) !== o)
|
|
156
172
|
return;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
173
|
+
if (x.title)
|
|
174
|
+
e(this, b).textContent = x.title;
|
|
175
|
+
else {
|
|
176
|
+
const i = x.querySelector("h1"), f = (i == null ? void 0 : i.innerText) || (i == null ? void 0 : i.textContent) || o;
|
|
177
|
+
e(this, b).textContent = f;
|
|
178
|
+
}
|
|
179
|
+
document.body.appendChild(e(this, b));
|
|
180
|
+
const it = Array.from(document.head.children), nt = Array.from(
|
|
181
|
+
x.head.cloneNode(!0).children
|
|
182
|
+
), 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
|
+
V.forEach((i, f) => {
|
|
184
|
+
if (i.tagName === "SCRIPT" && i.getAttribute("src")) {
|
|
162
185
|
const w = document.createElement("script");
|
|
163
|
-
w.type = "module", w.src =
|
|
186
|
+
w.type = "module", w.src = i.getAttribute("src"), V[f] = w;
|
|
164
187
|
}
|
|
165
|
-
}),
|
|
166
|
-
document.head.appendChild(
|
|
188
|
+
}), V.forEach((i) => {
|
|
189
|
+
document.head.appendChild(i);
|
|
167
190
|
});
|
|
168
|
-
const
|
|
169
|
-
(
|
|
191
|
+
const X = V.filter(
|
|
192
|
+
(i) => !i.hasAttribute("data-no-waiting") && (i.tagName === "STYLE" || i.tagName === "SCRIPT" || i.tagName === "LINK") && i.getAttribute("rel") !== "canonical"
|
|
170
193
|
);
|
|
171
|
-
e(this,
|
|
172
|
-
let
|
|
194
|
+
e(this, _) && X.length && (yield new Promise((i) => D(this, null, function* () {
|
|
195
|
+
let f = 0;
|
|
173
196
|
try {
|
|
174
|
-
for (var w =
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
for (var w = dt(X), ot, z, ht; ot = !(z = yield w.next()).done; ot = !1) {
|
|
198
|
+
const G = z.value;
|
|
199
|
+
G.onload = () => {
|
|
200
|
+
f++, f === X.length && i();
|
|
178
201
|
};
|
|
179
202
|
}
|
|
180
|
-
} catch (
|
|
181
|
-
|
|
203
|
+
} catch (z) {
|
|
204
|
+
ht = [z];
|
|
182
205
|
} finally {
|
|
183
206
|
try {
|
|
184
|
-
|
|
207
|
+
ot && (z = w.return) && (yield z.call(w));
|
|
185
208
|
} finally {
|
|
186
|
-
if (
|
|
187
|
-
throw
|
|
209
|
+
if (ht)
|
|
210
|
+
throw ht[0];
|
|
188
211
|
}
|
|
189
212
|
}
|
|
190
|
-
})))
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}),
|
|
203
|
-
|
|
204
|
-
|
|
213
|
+
})));
|
|
214
|
+
const at = [];
|
|
215
|
+
Lt.forEach((i) => {
|
|
216
|
+
i.hasAttribute("data-permanent") || (i.tagName === "SCRIPT" || i.tagName === "STYLE" || i.getAttribute("rel") === "stylesheet" ? at.push(i) : i.remove());
|
|
217
|
+
}), 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) => {
|
|
220
|
+
const w = Et[f++], ot = getComputedStyle(i).getPropertyValue("--morph-duration"), z = [...w.childNodes];
|
|
221
|
+
if (ot) {
|
|
222
|
+
const ht = [...i.childNodes];
|
|
223
|
+
ht.forEach((p) => {
|
|
224
|
+
p instanceof HTMLElement && p.classList.add("old");
|
|
225
|
+
}), z.forEach((p) => {
|
|
226
|
+
p instanceof HTMLElement && p.classList.add("new");
|
|
227
|
+
}), i.append(...z), setTimeout(() => {
|
|
228
|
+
z.forEach((p) => {
|
|
229
|
+
p instanceof HTMLElement && p.classList.add("in");
|
|
205
230
|
});
|
|
206
231
|
}, 10);
|
|
207
|
-
const
|
|
208
|
-
element:
|
|
232
|
+
const G = {
|
|
233
|
+
element: i,
|
|
209
234
|
pathname: o,
|
|
210
235
|
isCached: N,
|
|
211
|
-
state:
|
|
236
|
+
state: n
|
|
212
237
|
};
|
|
213
|
-
|
|
214
|
-
detail:
|
|
238
|
+
J(document, "morphBeforeElementOut", {
|
|
239
|
+
detail: G
|
|
240
|
+
});
|
|
241
|
+
const vt = new Promise((p) => {
|
|
242
|
+
setTimeout(() => {
|
|
243
|
+
ht.forEach((R) => R.remove()), z.forEach((R) => {
|
|
244
|
+
R instanceof HTMLElement && (R.classList.remove("new", "in"), R.classList.add("current"));
|
|
245
|
+
}), J(document, "morphAfterElementOut", {
|
|
246
|
+
detail: G
|
|
247
|
+
}), p();
|
|
248
|
+
}, (parseFloat(ot) || 0) * 1e3 + 10);
|
|
215
249
|
});
|
|
216
|
-
|
|
217
|
-
at.forEach((l) => l.remove()), C.forEach((l) => {
|
|
218
|
-
l instanceof HTMLElement && (l.classList.remove("new", "in"), l.classList.add("current"));
|
|
219
|
-
}), Y(document, "morphAfterElementOut", {
|
|
220
|
-
detail: V
|
|
221
|
-
}), c(this, v, e(this, v).filter((l) => l !== rt));
|
|
222
|
-
}, (parseFloat(nt) || 0) * 1e3 + 10);
|
|
223
|
-
e(this, v).push(rt);
|
|
250
|
+
e(this, k).push(vt);
|
|
224
251
|
} else
|
|
225
|
-
|
|
226
|
-
}), this.findLinks(), document.documentElement.setAttribute("data-current-pathname", o), document.documentElement.setAttribute("data-current-leaf", b), (
|
|
252
|
+
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", {
|
|
227
254
|
detail: {
|
|
228
255
|
pathname: o,
|
|
229
256
|
isCached: N,
|
|
230
|
-
state:
|
|
257
|
+
state: n
|
|
231
258
|
}
|
|
232
|
-
}),
|
|
233
|
-
} catch (
|
|
234
|
-
console.error(
|
|
259
|
+
}), mt.complete("__morph");
|
|
260
|
+
} catch (K) {
|
|
261
|
+
console.error(K);
|
|
235
262
|
}
|
|
236
263
|
c(this, y, void 0);
|
|
237
264
|
});
|
|
238
265
|
}
|
|
239
266
|
addLink(t) {
|
|
240
|
-
e(this,
|
|
267
|
+
e(this, v).push(new ft(t, this));
|
|
241
268
|
}
|
|
242
269
|
addLinks(t) {
|
|
243
|
-
t.forEach((
|
|
244
|
-
this.addLink(
|
|
270
|
+
t.forEach((s) => {
|
|
271
|
+
this.addLink(s);
|
|
245
272
|
});
|
|
246
273
|
}
|
|
247
274
|
removeLink(t) {
|
|
248
|
-
c(this,
|
|
275
|
+
c(this, v, e(this, v).filter((s) => s.element === t ? (s.destroy(), !1) : !0));
|
|
249
276
|
}
|
|
250
277
|
findLinks() {
|
|
251
278
|
const t = [
|
|
252
279
|
...document.documentElement.querySelectorAll("a")
|
|
253
280
|
].filter(
|
|
254
|
-
(
|
|
255
|
-
var
|
|
256
|
-
return ((
|
|
281
|
+
(s) => {
|
|
282
|
+
var n;
|
|
283
|
+
return ((n = s.getAttribute("href")) == null ? void 0 : n.startsWith("/")) && !s.hasAttribute("download") && !s.hasAttribute("data-morph-skip") && !s.closest("[data-morph-skip]");
|
|
257
284
|
}
|
|
258
285
|
);
|
|
259
|
-
e(this,
|
|
286
|
+
e(this, v).forEach((s) => s.destroy()), c(this, v, t.map((s) => new ft(s, this)));
|
|
260
287
|
}
|
|
261
288
|
}
|
|
262
|
-
|
|
263
|
-
return
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
266
|
-
return
|
|
267
|
-
const
|
|
268
|
-
return e(this,
|
|
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
|
+
return D(this, null, function* () {
|
|
291
|
+
const s = e(this, M).get(t);
|
|
292
|
+
if (s)
|
|
293
|
+
return s;
|
|
294
|
+
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;
|
|
269
296
|
});
|
|
270
|
-
},
|
|
271
|
-
const
|
|
272
|
-
return
|
|
273
|
-
},
|
|
297
|
+
}, tt = function(t) {
|
|
298
|
+
const s = [...t.querySelectorAll("[data-morph]")];
|
|
299
|
+
return s.length ? s : [t];
|
|
300
|
+
}, gt = function(t, s) {
|
|
274
301
|
return t.filter(
|
|
275
|
-
(
|
|
276
|
-
(
|
|
302
|
+
(n) => s.find(
|
|
303
|
+
(l) => l.outerHTML === n.outerHTML
|
|
277
304
|
)
|
|
278
305
|
);
|
|
279
|
-
},
|
|
306
|
+
}, et = function(t, s) {
|
|
280
307
|
return t.filter(
|
|
281
|
-
(
|
|
282
|
-
(
|
|
308
|
+
(n) => !s.find(
|
|
309
|
+
(l) => l.outerHTML === n.outerHTML
|
|
283
310
|
)
|
|
284
311
|
);
|
|
285
|
-
},
|
|
312
|
+
}, U = new WeakMap();
|
|
286
313
|
export {
|
|
287
|
-
|
|
314
|
+
Ct as Morph
|
|
288
315
|
};
|