aptechka 0.70.18 → 0.71.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 +21 -4
- package/lib/morph/MorphRoute.d.ts +3 -3
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +300 -288
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChangeHistoryAction, ElementOrSelector } from '../utils';
|
|
1
|
+
import { ChangeHistoryAction, ElementOrSelector, splitPath } from '../utils';
|
|
2
2
|
import { MorphLink } from './MorphLink';
|
|
3
3
|
import { MorphRouteScrollState } from './MorphRoute';
|
|
4
4
|
export interface MorphOptions {
|
|
@@ -9,7 +9,7 @@ export interface MorphOptions {
|
|
|
9
9
|
morphInsideScrollContainer: boolean;
|
|
10
10
|
}
|
|
11
11
|
export interface MorphNavigationEntry {
|
|
12
|
-
|
|
12
|
+
url: ReturnType<typeof splitPath>;
|
|
13
13
|
submorph?: Array<string>;
|
|
14
14
|
}
|
|
15
15
|
export interface MorphNavigationDocumentFetchedEntry extends MorphNavigationEntry {
|
|
@@ -18,6 +18,10 @@ export interface MorphNavigationDocumentFetchedEntry extends MorphNavigationEntr
|
|
|
18
18
|
export interface MorphChildrenActionEntry extends MorphNavigationDocumentFetchedEntry {
|
|
19
19
|
morphElement: HTMLElement;
|
|
20
20
|
}
|
|
21
|
+
export interface MorphURLParametersChangeEntry {
|
|
22
|
+
newURL: ReturnType<typeof splitPath>;
|
|
23
|
+
previousURL: ReturnType<typeof splitPath>;
|
|
24
|
+
}
|
|
21
25
|
export interface MorphPreprocessorEntry extends MorphNavigationEntry {
|
|
22
26
|
resolve: () => void;
|
|
23
27
|
reject: () => void;
|
|
@@ -45,6 +49,7 @@ export interface MorphEvents {
|
|
|
45
49
|
morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
|
|
46
50
|
morphScroll: CustomEvent<MorphScrollDetail>;
|
|
47
51
|
morphBeforeNavigationScroll: CustomEvent<MorphRouteScrollState>;
|
|
52
|
+
morphURLParametersChange: CustomEvent<MorphURLParametersChangeEntry>;
|
|
48
53
|
}
|
|
49
54
|
export interface MorphGetRouteOptions {
|
|
50
55
|
searchParameters?: string;
|
|
@@ -56,8 +61,20 @@ export declare class Morph {
|
|
|
56
61
|
preprocessor?: MorphPreprocessor;
|
|
57
62
|
pathnameModifier?: MorphPathnameModifier;
|
|
58
63
|
constructor(parameters?: Partial<MorphOptions>);
|
|
59
|
-
get
|
|
60
|
-
|
|
64
|
+
get currentURL(): {
|
|
65
|
+
leaf: string;
|
|
66
|
+
pathname: string;
|
|
67
|
+
parameters: string;
|
|
68
|
+
hash: string;
|
|
69
|
+
path: string;
|
|
70
|
+
};
|
|
71
|
+
get previousURL(): {
|
|
72
|
+
leaf: string;
|
|
73
|
+
pathname: string;
|
|
74
|
+
parameters: string;
|
|
75
|
+
hash: string;
|
|
76
|
+
path: string;
|
|
77
|
+
} | undefined;
|
|
61
78
|
get links(): MorphLink[];
|
|
62
79
|
get scrollElement(): HTMLElement | Window;
|
|
63
80
|
get isPopstateNavigation(): boolean;
|
|
@@ -10,13 +10,13 @@ export interface MorphRouteSaveState {
|
|
|
10
10
|
export type MorpRouteSaveParametersArg = string | object | URLSearchParams;
|
|
11
11
|
export declare class MorphRoute {
|
|
12
12
|
#private;
|
|
13
|
-
constructor(morph: Morph,
|
|
14
|
-
get
|
|
13
|
+
constructor(morph: Morph, pathname: string);
|
|
14
|
+
get pathname(): string;
|
|
15
15
|
get scrollState(): MorphRouteScrollState;
|
|
16
16
|
get document(): Document;
|
|
17
17
|
setInitialDocument(document: Document): void;
|
|
18
18
|
abort(): void | undefined;
|
|
19
|
-
fetch(revalidate?: boolean): Promise<void | null>;
|
|
19
|
+
fetch(path: string, revalidate?: boolean): Promise<void | null>;
|
|
20
20
|
cloneDocument(): void;
|
|
21
21
|
get title(): string;
|
|
22
22
|
clearScrollState(): void;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Yt=Object.defineProperty,Xt=Object.defineProperties;var jt=Object.getOwnPropertyDescriptors;var Ht=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var xt=(r,t)=>(t=Symbol[r])?t:Symbol.for("Symbol."+r),qt=r=>{throw TypeError(r)};var Nt=(r,t,s)=>t in r?Yt(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s,pt=(r,t)=>{for(var s in t||(t={}))Ut.call(t,s)&&Nt(r,s,t[s]);if(Ht)for(var s of Ht(t))Kt.call(t,s)&&Nt(r,s,t[s]);return r},Et=(r,t)=>Xt(r,jt(t));var gt=(r,t,s)=>t.has(r)||qt("Cannot "+s);var e=(r,t,s)=>(gt(r,t,"read from private field"),s?s.call(r):t.get(r)),a=(r,t,s)=>t.has(r)?qt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,s),n=(r,t,s,i)=>(gt(r,t,"write to private field"),i?i.call(r,s):t.set(r,s),s),E=(r,t,s)=>(gt(r,t,"access private method"),s);var X=(r,t,s)=>new Promise((i,u)=>{var y=S=>{try{w(s.next(S))}catch(Y){u(Y)}},q=S=>{try{w(s.throw(S))}catch(Y){u(Y)}},w=S=>S.done?i(S.value):Promise.resolve(S.value).then(y,q);w((s=s.apply(r,t)).next())});var Dt=(r,t,s)=>(t=r[xt("asyncIterator")])?t.call(r):(r=r[xt("iterator")](),t={},s=(i,u)=>(u=r[i])&&(t[i]=y=>new Promise((q,w,S)=>(y=u.call(r,y),S=y.done,Promise.resolve(y.value).then(Y=>q({value:Y,done:S}),w)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Vt=require("../index-DekP7OZe.cjs"),j=require("../events-KVanG9sR.cjs"),$t=require("../polyfills-Df4r-ETT.cjs"),It=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const ct=require("../url-BT4fssbO.cjs"),Gt=require("../css-value-parser/index.cjs");class zt extends HTMLElement{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,i]of Object.entries(t))this.setAttribute(s,i)}}Vt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",zt);var M,l,V,st,G;class St{constructor(t,s){a(this,M);a(this,l);a(this,V);a(this,st,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,M).previousPathname)history.back();else{n(this,V,e(this,l).getAttribute("href")||"/");const u=e(this,l).getAttribute("data-history-action")||"push",y=e(this,l).hasAttribute("data-center-scroll"),q=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),w=q?Gt.cssValueParser.parse(q):void 0,S=e(this,l).hasAttribute("data-revalidate"),Y=e(this,l).hasAttribute("data-keep-search-parameters"),d=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(D=>D.trim()),ot=e(this,l).hasAttribute("data-clear-state");e(this,M).navigate(e(this,V),{historyAction:u,centerScroll:y,offsetScroll:w,revalidate:S,keepSearchParameters:Y,submorph:d,clearState:ot})}});a(this,G,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,M).prefetch(e(this,V),t),e(this,l).removeEventListener("pointerenter",e(this,G))});n(this,M,s),n(this,l,t),n(this,V,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,st)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,G))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,M).normalizePath(t),i=e(this,M).normalizePath(e(this,V));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,st)),e(this,l).removeEventListener("pointerenter",e(this,G)),e(this,l).classList.remove("current")}}M=new WeakMap,l=new WeakMap,V=new WeakMap,st=new WeakMap,G=new WeakMap;const Jt=new DOMParser;var H,z,b,k,U,B,J,K,F;class Rt{constructor(t,s){a(this,H);a(this,z);a(this,b,{x:0,y:0});a(this,k,null);a(this,U,null);a(this,B,null);a(this,J,null);a(this,K,null);a(this,F,null);n(this,H,t),n(this,z,s)}get path(){return e(this,z)}get scrollState(){return e(this,b)}get document(){return e(this,B)}setInitialDocument(t){n(this,k,t.cloneNode(!0))}abort(){var t;return(t=e(this,K))==null?void 0:t.abort(`[${e(this,z)}] page loading cancelled`)}fetch(t){return X(this,null,function*(){return e(this,F)||e(this,k)&&e(this,k).documentElement.hasAttribute("data-cache")&&!t||e(this,k)&&e(this,H).isPopstateNavigation?e(this,F):(n(this,F,new Promise(s=>X(this,null,function*(){try{n(this,K,new AbortController);const u=yield(yield fetch(e(this,z),{signal:e(this,K).signal})).text(),y=Jt.parseFromString(u,"text/html");this.setInitialDocument(y)}catch(i){console.warn(i)}finally{n(this,K,null),n(this,F,null),s()}}))),e(this,F))})}cloneDocument(){n(this,B,(e(this,U)||e(this,k)).cloneNode(!0))}get title(){let t="";if(e(this,B).title)t=e(this,B).title;else{const s=e(this,B).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,z)}return t}clearScrollState(){e(this,b).x=0,e(this,b).y=0}clearDocumentState(){n(this,U,null)}saveScrollState(){e(this,k).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,b).x=0,e(this,b).y=0):(e(this,b).x=e(this,H).scrollValue.left,e(this,b).y=e(this,H).scrollValue.top)}restoreScrollPosition(){e(this,H).scrollElement.scroll({top:e(this,b).y,left:e(this,b).x,behavior:"instant"})}saveDocumentState(){e(this,k).documentElement.hasAttribute("data-no-page-restoration")?n(this,U,null):n(this,U,document.cloneNode(!0))}renewScrollPosition(){e(this,H).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){n(this,J,t)}clearState(){const t=e(this,J);return n(this,J,null),t}}H=new WeakMap,z=new WeakMap,b=new WeakMap,k=new WeakMap,U=new WeakMap,B=new WeakMap,J=new WeakMap,K=new WeakMap,F=new WeakMap;var C,Q,g,O,f,it,W,x,P,rt,N,$,Z,_,nt,c,ht,wt,Bt,yt,bt,Lt,Pt,ut,tt;const et=class et{constructor(t){a(this,c);a(this,C,null);a(this,Q,null);a(this,g,[]);a(this,O);a(this,f,null);a(this,it);a(this,W,[]);a(this,x,!1);a(this,P,null);a(this,rt,!1);a(this,N,new Map);a(this,$,null);a(this,Z,0);a(this,_,0);a(this,nt,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});a(this,ut,t=>X(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),n(this,x,!0),yield this.navigate(t.state.path,{historyAction:"none"}),n(this,x,!1))}));a(this,tt,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,_),u=t-e(this,Z);n(this,_,s),n(this,Z,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",u>0),document.documentElement.classList.toggle("scroll-x-backward",u<0),j.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Vt.isBrowser&&!et.instance){et.instance=this,n(this,C,{base:ct.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),n(this,Q,E(this,c,wt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);n(this,f,s.path);const i=new Rt(this,e(this,f));i.setInitialDocument(document),e(this,N).set(e(this,f),i),document.documentElement.setAttribute("data-current-pathname",e(this,f)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,ut)),ct.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),n(this,$,new zt),E(this,c,Lt).call(this,document)}}get currentPath(){return e(this,f)}get previousPathname(){return e(this,it)}get links(){return e(this,g)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,x)}get scrollValue(){let t=0,s=0;return e(this,rt)?(t=window.scrollY,s=window.scrollX):(t=e(this,P).scrollTop,s=e(this,P).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,N).get(e(this,f));s&&s.saveState(t)}getState(){const t=e(this,N).get(e(this,f));return t==null?void 0:t.clearState()}normalizePath(t){return ct.splitPath(t,{base:e(this,C).base,trailingSlash:e(this,C).trailingSlash})}prefetch(t,s){return X(this,null,function*(){if(e(this,W).length)return;const i=E(this,c,ht).call(this,t);i==null||i.fetch(s)})}navigate(Y){return X(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:y,keepSearchParameters:q,submorph:w,clearState:S}={}){var ot;if(e(this,W).length)return;const d=this.normalizePath(((ot=this.pathnameModifier)==null?void 0:ot.call(this,t))||t);if(e(this,O)===d.path||e(this,f)===d.path){e(this,x)||E(this,c,Pt).call(this,d.hash||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}n(this,O,d.path),e(this,g).forEach(D=>{D.checkCurrent(d.path)});try{let D=!0;if(this.preprocessor)try{yield new Promise((o,T)=>{var p;(p=this.preprocessor)==null||p.call(this,{path:t,resolve:o,reject:T,submorph:w})})}catch(o){o?console.error(o):console.log("Route change canceled"),D=!1}if(!D||e(this,O)!==d.path){e(this,g).forEach(o=>{o.checkCurrent(e(this,f))});return}const At={path:d.path,submorph:w};j.dispatchEvent(document,"morphNavigation",{detail:At});const dt=E(this,c,ht).call(this,e(this,f)),m=E(this,c,ht).call(this,t);if(e(this,N).forEach(o=>{o.path!==d.path&&o.abort()}),yield m==null?void 0:m.fetch(y),e(this,O)!==d.path){e(this,g).forEach(o=>{o.checkCurrent(e(this,f))});return}dt.clearState(),dt.saveScrollState(),dt.saveDocumentState(),e(this,x)||(m.clearScrollState(),m.clearDocumentState()),S&&m.clearState(),m.cloneDocument(),e(this,$).textContent=m.title,document.body.appendChild(e(this,$));const mt=Et(pt({},At),{document:m.document});j.dispatchEvent(document,"morphStart",{detail:mt});const kt=Array.from(document.head.children),Ct=Array.from(m.document.head.children),Tt=E(this,c,Bt).call(this,kt,Ct),Ft=E(this,c,yt).call(this,kt,Tt),at=E(this,c,yt).call(this,Ct,Tt);at.forEach((o,T)=>{if(o.tagName==="SCRIPT"&&o.getAttribute("src")){const p=document.createElement("script"),I=o.getAttribute("src");I.includes("http")||(p.type="module"),p.src=I,at[T]=p}}),at.forEach(o=>{document.head.appendChild(o)});const ft=at.filter(o=>{if(o.hasAttribute("data-no-waiting"))return!1;if(E(this,c,bt).call(this,o))return!0});e(this,C).waitForHeadToLoad&&ft.length&&(yield new Promise(o=>X(this,null,function*(){let T=0;try{for(var p=Dt(ft),I,L,A;I=!(L=yield p.next()).done;I=!1){const lt=L.value;lt.onload=()=>{T++,T===ft.length&&o()}}}catch(L){A=[L]}finally{try{I&&(L=p.return)&&(yield L.call(p))}finally{if(A)throw A[0]}}}))),yield It.wait(10);const Mt=[];Ft.forEach(o=>{o.hasAttribute("data-permanent")||(E(this,c,bt).call(this,o)?Mt.push(o):o.remove())});const Ot=E(this,c,wt).call(this,m.document.body);e(this,C).morphInsideScrollContainer||E(this,c,Lt).call(this,m.document),document.documentElement.setAttribute("data-current-pathname",d.pathname),document.documentElement.setAttribute("data-current-leaf",d.leaf),ct.changeHistory({action:s,pathname:d.pathname,searchParameters:d.parameters||(q?location.search:""),hash:d.hash}),e(this,$).remove(),n(this,it,e(this,f)),n(this,f,d.path),e(this,Q).forEach((o,T)=>{const p=Ot[T],I=getComputedStyle(o).getPropertyValue("--morph-duration");let L=[],A=[];w?w.forEach(h=>{const v=o.querySelector(h),R=p.querySelector(h);v&&R&&(A.push(v),L.push(R))}):(L.push(...p.childNodes),A.push(...o.childNodes)),A.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),L.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),w?L.forEach((h,v)=>{var R;(R=A[v].parentElement)==null||R.insertBefore(h,A[v])}):o.prepend(...L),$t.requestIdleCallback(()=>{A.forEach(h=>{h instanceof HTMLElement&&h.classList.add("old-idle")}),L.forEach(h=>{var v;h instanceof HTMLElement&&((v=h.parentElement)==null||v.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("new-idle"))})});const lt=Et(pt({},mt),{morphElement:o});j.dispatchEvent(document,"morphNewChildrenAdded",{detail:lt});const Wt=new Promise(h=>{setTimeout(()=>{A.forEach(v=>v.remove()),L.forEach(v=>{var R;v instanceof HTMLElement&&((R=v.parentElement)==null||R.style.removeProperty("--new-content-height"),v.classList.remove("new-idle","new"))}),j.dispatchEvent(document,"morphOldChildrenRemoved",{detail:lt}),h()},(parseFloat(I)||0)*1e3+10)});e(this,W).push(Wt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-m.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),j.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:m.scrollState}),d.hash?(m.clearScrollState(),E(this,c,Pt).call(this,d.hash,{centerScroll:i,offsetScroll:u})):e(this,x)?m.restoreScrollPosition():m.renewScrollPosition(),yield Promise.all(e(this,W)),Mt.forEach(o=>o.remove()),n(this,W,[]),e(this,Q).forEach(o=>{o.querySelectorAll("script").forEach(p=>{const I=document.createElement("script");for(let L=0;L<p.attributes.length;L++){const A=p.attributes[L];I.setAttribute(A.name,A.value)}p.hasAttribute("src")||(I.innerHTML=p.innerHTML),p.replaceWith(I)})}),j.dispatchEvent(document,"morphComplete",{detail:mt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(D){console.error(D)}n(this,O,void 0)})}addLink(t){e(this,g).push(new St(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){n(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){n(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,nt));e(this,g).push(...s.map(i=>new St(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,nt));e(this,g).forEach(s=>s.destroy()),n(this,g,t.map(s=>new St(s,this)))}};C=new WeakMap,Q=new WeakMap,g=new WeakMap,O=new WeakMap,f=new WeakMap,it=new WeakMap,W=new WeakMap,x=new WeakMap,P=new WeakMap,rt=new WeakMap,N=new WeakMap,$=new WeakMap,Z=new WeakMap,_=new WeakMap,nt=new WeakMap,c=new WeakSet,ht=function(t){let s=t.split("#")[0],i=e(this,N).get(s);return i||(i=new Rt(this,s),e(this,N).set(s,i)),i},wt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Bt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},yt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},bt=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Lt=function(t){var s,i;(s=e(this,P))==null||s.removeEventListener("scroll",e(this,tt)),n(this,_,0),n(this,Z,0),n(this,P,e(this,C).scrollSelector&&t.querySelector(e(this,C).scrollSelector)||window),n(this,rt,e(this,P)===window),(i=e(this,P))==null||i.addEventListener("scroll",e(this,tt)),e(this,tt).call(this)},Pt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&It.scrollToElement(i,{scrollElement:e(this,P),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},ut=new WeakMap,tt=new WeakMap,et.instance=null;let vt=et;exports.Morph=vt;
|
|
1
|
+
"use strict";var jt=Object.defineProperty,Kt=Object.defineProperties;var $t=Object.getOwnPropertyDescriptors;var Nt=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Jt=Object.prototype.propertyIsEnumerable;var qt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),Ut=n=>{throw TypeError(n)};var Dt=(n,t,s)=>t in n?jt(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s,gt=(n,t)=>{for(var s in t||(t={}))Gt.call(t,s)&&Dt(n,s,t[s]);if(Nt)for(var s of Nt(t))Jt.call(t,s)&&Dt(n,s,t[s]);return n},vt=(n,t)=>Kt(n,$t(t));var St=(n,t,s)=>t.has(n)||Ut("Cannot "+s);var e=(n,t,s)=>(St(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?Ut("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),r=(n,t,s,i)=>(St(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),E=(n,t,s)=>(St(n,t,"access private method"),s);var W=(n,t,s)=>new Promise((i,d)=>{var y=v=>{try{w(s.next(v))}catch(O){d(O)}},P=v=>{try{w(s.throw(v))}catch(O){d(O)}},w=v=>v.done?i(v.value):Promise.resolve(v.value).then(y,P);w((s=s.apply(n,t)).next())});var zt=(n,t,s)=>(t=n[qt("asyncIterator")])?t.call(n):(n=n[qt("iterator")](),t={},s=(i,d)=>(d=n[i])&&(t[i]=y=>new Promise((P,w,v)=>(y=d.call(n,y),v=y.done,Promise.resolve(y.value).then(O=>P({value:O,done:v}),w)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ft=require("../index-DekP7OZe.cjs"),U=require("../events-KVanG9sR.cjs"),Qt=require("../polyfills-Df4r-ETT.cjs"),It=require("../scroll-CIdNtj3G.cjs");require("construct-style-sheets-polyfill");const it=require("../url-BT4fssbO.cjs"),Zt=require("../css-value-parser/index.cjs");class Bt extends HTMLElement{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,i]of Object.entries(t))this.setAttribute(s,i)}}Ft.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Bt);var H,l,z,rt,J;class wt{constructor(t,s){o(this,H);o(this,l);o(this,z);o(this,rt,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,H).previousURL)history.back();else{r(this,z,e(this,l).getAttribute("href")||"/");const d=e(this,l).getAttribute("data-history-action")||"push",y=e(this,l).hasAttribute("data-center-scroll"),P=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),w=P?Zt.cssValueParser.parse(P):void 0,v=e(this,l).hasAttribute("data-revalidate"),O=e(this,l).hasAttribute("data-keep-search-parameters"),h=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(ht=>ht.trim()),lt=e(this,l).hasAttribute("data-clear-state");e(this,H).navigate(e(this,z),{historyAction:d,centerScroll:y,offsetScroll:w,revalidate:v,keepSearchParameters:O,submorph:h,clearState:lt})}});o(this,J,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,H).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,J))});r(this,H,s),r(this,l,t),r(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,rt)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,J))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,H).normalizePath(t),i=e(this,H).normalizePath(e(this,z));e(this,l).hasAttribute("data-include")&&s.pathname.includes(i.pathname)?e(this,l).classList.add("current"):i.pathname===s.pathname?e(this,l).classList.add("current"):e(this,l).classList.remove("current")}destroy(){e(this,l).removeEventListener("click",e(this,rt)),e(this,l).removeEventListener("pointerenter",e(this,J)),e(this,l).classList.remove("current")}}H=new WeakMap,l=new WeakMap,z=new WeakMap,rt=new WeakMap,J=new WeakMap;const _t=new DOMParser;var R,Y,L,C,X,I,Q,j,V,Z;class Vt{constructor(t,s){o(this,R);o(this,Y);o(this,L,{x:0,y:0});o(this,C,null);o(this,X,null);o(this,I,null);o(this,Q,null);o(this,j,null);o(this,V,null);o(this,Z);r(this,R,t),r(this,Y,s),r(this,Z,s)}get pathname(){return e(this,Y)}get scrollState(){return e(this,L)}get document(){return e(this,I)}setInitialDocument(t){r(this,C,t.cloneNode(!0))}abort(){var t;return(t=e(this,j))==null?void 0:t.abort(`[${e(this,Y)}] page loading cancelled`)}fetch(t,s){return W(this,null,function*(){return e(this,V)||e(this,C)&&e(this,C).documentElement.hasAttribute("data-cache")&&!s&&e(this,Z)!==t||e(this,C)&&e(this,R).isPopstateNavigation?e(this,V):(r(this,V,new Promise(i=>W(this,null,function*(){try{r(this,j,new AbortController);const y=yield(yield fetch(t,{signal:e(this,j).signal})).text(),P=_t.parseFromString(y,"text/html");this.setInitialDocument(P)}catch(d){console.warn(d)}finally{r(this,Z,t),r(this,j,null),r(this,V,null),i()}}))),e(this,V))})}cloneDocument(){r(this,I,(e(this,X)||e(this,C)).cloneNode(!0))}get title(){let t="";if(e(this,I).title)t=e(this,I).title;else{const s=e(this,I).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,Y)}return t}clearScrollState(){e(this,L).x=0,e(this,L).y=0}clearDocumentState(){r(this,X,null)}saveScrollState(){e(this,C).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,L).x=0,e(this,L).y=0):(e(this,L).x=e(this,R).scrollValue.left,e(this,L).y=e(this,R).scrollValue.top)}restoreScrollPosition(){e(this,R).scrollElement.scroll({top:e(this,L).y,left:e(this,L).x,behavior:"instant"})}saveDocumentState(){e(this,C).documentElement.hasAttribute("data-no-page-restoration")?r(this,X,null):r(this,X,document.cloneNode(!0))}renewScrollPosition(){e(this,R).scrollElement.scroll({top:0,left:0,behavior:"instant"})}saveState(t){r(this,Q,t)}clearState(){const t=e(this,Q);return r(this,Q,null),t}}R=new WeakMap,Y=new WeakMap,L=new WeakMap,C=new WeakMap,X=new WeakMap,I=new WeakMap,Q=new WeakMap,j=new WeakMap,V=new WeakMap,Z=new WeakMap;var T,_,g,F,m,K,B,x,A,at,N,$,tt,et,ot,c,dt,Lt,Ot,bt,At,Pt,kt,mt,st;const nt=class nt{constructor(t){o(this,c);o(this,T,null);o(this,_,null);o(this,g,[]);o(this,F);o(this,m,null);o(this,K);o(this,B,[]);o(this,x,!1);o(this,A,null);o(this,at,!1);o(this,N,new Map);o(this,$,null);o(this,tt,0);o(this,et,0);o(this,ot,t=>{var s;return((s=t.getAttribute("href"))==null?void 0:s.startsWith("/"))&&!t.hasAttribute("download")&&!t.hasAttribute("data-morph-skip")&&!t.closest("[data-morph-skip]")&&t.getAttribute("target")!=="_blank"});o(this,mt,t=>W(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),r(this,x,!0),yield this.navigate(t.state.path,{historyAction:"none"}),r(this,x,!1))}));o(this,st,()=>{const{left:t,top:s}=this.scrollValue,i=s-e(this,et),d=t-e(this,tt);r(this,et,s),r(this,tt,t),document.documentElement.classList.toggle("scroll-y",s>0),document.documentElement.classList.toggle("scroll-x",t>0),document.documentElement.classList.toggle("scroll-y-forward",i>0),document.documentElement.classList.toggle("scroll-y-backward",i<0),document.documentElement.classList.toggle("scroll-x-forward",d>0),document.documentElement.classList.toggle("scroll-x-backward",d<0),U.dispatchEvent(document,"morphScroll",{detail:{left:t,top:s}})});if(Ft.isBrowser&&!nt.instance){nt.instance=this,r(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:t==null?void 0:t.scrollSelector,morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),r(this,_,E(this,c,Lt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash+location.search);r(this,m,s);const i=new Vt(this,e(this,m).pathname);i.setInitialDocument(document),e(this,N).set(e(this,m).path,i),document.documentElement.setAttribute("data-current-pathname",e(this,m).pathname),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),history.scrollRestoration="manual",addEventListener("popstate",e(this,mt)),it.changeHistory({action:"replace",pathname:s.pathname,searchParameters:s.parameters,hash:s.hash}),r(this,$,new Bt),E(this,c,Pt).call(this,document)}}get currentURL(){return e(this,m)}get previousURL(){return e(this,K)}get links(){return e(this,g)}get scrollElement(){return e(this,A)}get isPopstateNavigation(){return e(this,x)}get scrollValue(){let t=0,s=0;return e(this,at)?(t=window.scrollY,s=window.scrollX):(t=e(this,A).scrollTop,s=e(this,A).scrollLeft),{top:t,left:s}}saveState(t){const s=e(this,N).get(e(this,m).path);s&&s.saveState(t)}getState(){const t=e(this,N).get(e(this,m).path);return t==null?void 0:t.clearState()}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return W(this,null,function*(){if(e(this,B).length)return;const i=E(this,c,dt).call(this,t);i==null||i.fetch(t,s)})}navigate(O){return W(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:d,revalidate:y,keepSearchParameters:P,submorph:w,clearState:v}={}){var lt,ht,Ct;if(e(this,B).length)return;const h=this.normalizePath(((lt=this.pathnameModifier)==null?void 0:lt.call(this,t))||t);if(((ht=e(this,F))==null?void 0:ht.pathname)===h.pathname||e(this,m).pathname===h.pathname){e(this,x)||E(this,c,kt).call(this,h.hash||0,{centerScroll:i,offsetScroll:d,behavior:"smooth"}),((Ct=e(this,m))==null?void 0:Ct.parameters)!==h.parameters&&(r(this,K,e(this,m)),r(this,m,h),it.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters,hash:h.hash}),U.dispatchEvent(document,"morphURLParametersChange",{detail:{newURL:e(this,m),previousURL:e(this,K)}}));return}r(this,F,h),e(this,g).forEach(G=>{G.checkCurrent(h.pathname)});try{let G=!0;if(this.preprocessor)try{yield new Promise((a,M)=>{var p;(p=this.preprocessor)==null||p.call(this,{url:h,resolve:a,reject:M,submorph:w})})}catch(a){a?console.error(a):console.log("Route change canceled"),G=!1}if(!G||e(this,F).pathname!==h.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).pathname)});return}const Tt={url:h,submorph:w};U.dispatchEvent(document,"morphNavigation",{detail:Tt});const ft=E(this,c,dt).call(this,e(this,m).pathname),f=E(this,c,dt).call(this,t);if(e(this,N).forEach(a=>{a.pathname!==h.pathname&&a.abort()}),yield f==null?void 0:f.fetch(t,y),e(this,F).pathname!==h.pathname){e(this,g).forEach(a=>{a.checkCurrent(e(this,m).path)});return}ft.clearState(),ft.saveScrollState(),ft.saveDocumentState(),e(this,x)||(f.clearScrollState(),f.clearDocumentState()),v&&f.clearState(),f.cloneDocument(),e(this,$).textContent=f.title,document.body.appendChild(e(this,$));const pt=vt(gt({},Tt),{document:f.document});U.dispatchEvent(document,"morphStart",{detail:pt});const Mt=Array.from(document.head.children),Ht=Array.from(f.document.head.children),Rt=E(this,c,Ot).call(this,Mt,Ht),Wt=E(this,c,bt).call(this,Mt,Rt),ct=E(this,c,bt).call(this,Ht,Rt);ct.forEach((a,M)=>{if(a.tagName==="SCRIPT"&&a.getAttribute("src")){const p=document.createElement("script"),q=a.getAttribute("src");q.includes("http")||(p.type="module"),p.src=q,ct[M]=p}}),ct.forEach(a=>{document.head.appendChild(a)});const Et=ct.filter(a=>{if(a.hasAttribute("data-no-waiting"))return!1;if(E(this,c,At).call(this,a))return!0});e(this,T).waitForHeadToLoad&&Et.length&&(yield new Promise(a=>W(this,null,function*(){let M=0;try{for(var p=zt(Et),q,b,k;q=!(b=yield p.next()).done;q=!1){const ut=b.value;ut.onload=()=>{M++,M===Et.length&&a()}}}catch(b){k=[b]}finally{try{q&&(b=p.return)&&(yield b.call(p))}finally{if(k)throw k[0]}}}))),yield It.wait(10);const xt=[];Wt.forEach(a=>{a.hasAttribute("data-permanent")||(E(this,c,At).call(this,a)?xt.push(a):a.remove())});const Yt=E(this,c,Lt).call(this,f.document.body);e(this,T).morphInsideScrollContainer||E(this,c,Pt).call(this,f.document),document.documentElement.setAttribute("data-current-pathname",h.pathname),document.documentElement.setAttribute("data-current-leaf",h.leaf),it.changeHistory({action:s,pathname:h.pathname,searchParameters:h.parameters||(P?location.search:""),hash:h.hash}),e(this,$).remove(),r(this,K,e(this,m)),r(this,m,h),e(this,_).forEach((a,M)=>{const p=Yt[M],q=getComputedStyle(a).getPropertyValue("--morph-duration");let b=[],k=[];w?w.forEach(u=>{const S=a.querySelector(u),D=p.querySelector(u);S&&D&&(k.push(S),b.push(D))}):(b.push(...p.childNodes),k.push(...a.childNodes)),k.forEach(u=>{u instanceof HTMLElement&&(this.destroyOldLinks(u),u.classList.add("old"))}),b.forEach(u=>{u instanceof HTMLElement&&(this.findNewLinks(u),u.classList.add("new"))}),w?b.forEach((u,S)=>{var D;(D=k[S].parentElement)==null||D.insertBefore(u,k[S])}):a.prepend(...b),Qt.requestIdleCallback(()=>{k.forEach(u=>{u instanceof HTMLElement&&u.classList.add("old-idle")}),b.forEach(u=>{var S;u instanceof HTMLElement&&((S=u.parentElement)==null||S.style.setProperty("--new-content-height",u.offsetHeight+"px"),u.classList.add("new-idle"))})});const ut=vt(gt({},pt),{morphElement:a});U.dispatchEvent(document,"morphNewChildrenAdded",{detail:ut});const Xt=new Promise(u=>{setTimeout(()=>{k.forEach(S=>S.remove()),b.forEach(S=>{var D;S instanceof HTMLElement&&((D=S.parentElement)==null||D.style.removeProperty("--new-content-height"),S.classList.remove("new-idle","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:ut}),u()},(parseFloat(q)||0)*1e3+10)});e(this,B).push(Xt)}),this.isPopstateNavigation?document.documentElement.style.setProperty("--new-document-scroll-position",(this.scrollValue.top-f.scrollState.y)*1+"px"):document.documentElement.style.setProperty("--new-document-scroll-position",this.scrollValue.top+"px"),U.dispatchEvent(document,"morphBeforeNavigationScroll",{detail:f.scrollState}),h.hash?(f.clearScrollState(),E(this,c,kt).call(this,h.hash,{centerScroll:i,offsetScroll:d})):e(this,x)?f.restoreScrollPosition():f.renewScrollPosition(),yield Promise.all(e(this,B)),xt.forEach(a=>a.remove()),r(this,B,[]),e(this,_).forEach(a=>{a.querySelectorAll("script").forEach(p=>{const q=document.createElement("script");for(let b=0;b<p.attributes.length;b++){const k=p.attributes[b];q.setAttribute(k.name,k.value)}p.hasAttribute("src")||(q.innerHTML=p.innerHTML),p.replaceWith(q)})}),U.dispatchEvent(document,"morphComplete",{detail:pt}),document.documentElement.style.removeProperty("--new-document-scroll-position"),window.dispatchEvent(new Event("resize"))}catch(G){console.error(G)}r(this,F,void 0)})}addLink(t){e(this,g).push(new wt(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){r(this,g,e(this,g).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){r(this,g,e(this,g).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,ot));e(this,g).push(...s.map(i=>new wt(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,ot));e(this,g).forEach(s=>s.destroy()),r(this,g,t.map(s=>new wt(s,this)))}};T=new WeakMap,_=new WeakMap,g=new WeakMap,F=new WeakMap,m=new WeakMap,K=new WeakMap,B=new WeakMap,x=new WeakMap,A=new WeakMap,at=new WeakMap,N=new WeakMap,$=new WeakMap,tt=new WeakMap,et=new WeakMap,ot=new WeakMap,c=new WeakSet,dt=function(t){const s=this.normalizePath(t);let i=e(this,N).get(s.pathname);return i||(i=new Vt(this,s.pathname),e(this,N).set(s.pathname,i)),i},Lt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Ot=function(t,s){return t.filter(i=>s.find(d=>d.outerHTML===i.outerHTML))},bt=function(t,s){return t.filter(i=>!s.find(d=>d.outerHTML===i.outerHTML))},At=function(t){return t.tagName==="SCRIPT"||t.tagName==="STYLE"||t.tagName==="LINK"&&t.getAttribute("rel")==="stylesheet"},Pt=function(t){var s,i;(s=e(this,A))==null||s.removeEventListener("scroll",e(this,st)),r(this,et,0),r(this,tt,0),r(this,A,e(this,T).scrollSelector&&t.querySelector(e(this,T).scrollSelector)||window),r(this,at,e(this,A)===window),(i=e(this,A))==null||i.addEventListener("scroll",e(this,st)),e(this,st).call(this)},kt=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&It.scrollToElement(i,{scrollElement:e(this,A),behavior:(s==null?void 0:s.behavior)||"instant",center:s==null?void 0:s.centerScroll,offset:s==null?void 0:s.offsetScroll})},mt=new WeakMap,st=new WeakMap,nt.instance=null;let yt=nt;exports.Morph=yt;
|
package/lib/morph/index.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
1
|
+
var Xt = Object.defineProperty, jt = Object.defineProperties;
|
|
2
|
+
var Kt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var xt = Object.getOwnPropertySymbols;
|
|
4
|
+
var $t = Object.prototype.hasOwnProperty, Gt = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var Nt = (r, t) => (t = Symbol[r]) ? t : Symbol.for("Symbol." + r), Ut = (r) => {
|
|
6
6
|
throw TypeError(r);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var Dt = (r, t, s) => t in r ? Xt(r, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : r[t] = s, Et = (r, t) => {
|
|
9
9
|
for (var s in t || (t = {}))
|
|
10
|
-
|
|
11
|
-
if (
|
|
12
|
-
for (var s of
|
|
13
|
-
|
|
10
|
+
$t.call(t, s) && Dt(r, s, t[s]);
|
|
11
|
+
if (xt)
|
|
12
|
+
for (var s of xt(t))
|
|
13
|
+
Gt.call(t, s) && Dt(r, s, t[s]);
|
|
14
14
|
return r;
|
|
15
|
-
},
|
|
16
|
-
var
|
|
17
|
-
var e = (r, t, s) => (
|
|
18
|
-
var
|
|
19
|
-
var v = (
|
|
15
|
+
}, gt = (r, t) => jt(r, Kt(t));
|
|
16
|
+
var wt = (r, t, s) => t.has(r) || Ut("Cannot " + s);
|
|
17
|
+
var e = (r, t, s) => (wt(r, t, "read from private field"), s ? s.call(r) : t.get(r)), a = (r, t, s) => t.has(r) ? Ut("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, s), n = (r, t, s, i) => (wt(r, t, "write to private field"), i ? i.call(r, s) : t.set(r, s), s), E = (r, t, s) => (wt(r, t, "access private method"), s);
|
|
18
|
+
var W = (r, t, s) => new Promise((i, d) => {
|
|
19
|
+
var v = (w) => {
|
|
20
20
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
|
|
21
|
+
L(s.next(w));
|
|
22
|
+
} catch (O) {
|
|
23
|
+
d(O);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, k = (w) => {
|
|
26
26
|
try {
|
|
27
|
-
|
|
28
|
-
} catch (
|
|
29
|
-
|
|
27
|
+
L(s.throw(w));
|
|
28
|
+
} catch (O) {
|
|
29
|
+
d(O);
|
|
30
30
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
31
|
+
}, L = (w) => w.done ? i(w.value) : Promise.resolve(w.value).then(v, k);
|
|
32
|
+
L((s = s.apply(r, t)).next());
|
|
33
33
|
});
|
|
34
|
-
var
|
|
35
|
-
import { i as
|
|
36
|
-
import { d as
|
|
37
|
-
import { r as
|
|
38
|
-
import { w as
|
|
34
|
+
var zt = (r, t, s) => (t = r[Nt("asyncIterator")]) ? t.call(r) : (r = r[Nt("iterator")](), t = {}, s = (i, d) => (d = r[i]) && (t[i] = (v) => new Promise((k, L, w) => (v = d.call(r, v), w = v.done, Promise.resolve(v.value).then((O) => k({ value: O, done: w }), L)))), s("next"), s("return"), t);
|
|
35
|
+
import { i as qt } from "../index-Bv9zgfdb.js";
|
|
36
|
+
import { d as z } from "../events-CsVF98U6.js";
|
|
37
|
+
import { r as Jt } from "../polyfills-DJrTJQky.js";
|
|
38
|
+
import { w as Qt, s as Zt } from "../scroll-DPkCFTxg.js";
|
|
39
39
|
import "construct-style-sheets-polyfill";
|
|
40
|
-
import { n as
|
|
41
|
-
import { cssValueParser as
|
|
42
|
-
class
|
|
40
|
+
import { n as _t, c as St, s as te } from "../url-Cb0SFRMc.js";
|
|
41
|
+
import { cssValueParser as ee } from "../css-value-parser/index.js";
|
|
42
|
+
class Ft extends HTMLElement {
|
|
43
43
|
connectedCallback() {
|
|
44
44
|
const t = {
|
|
45
45
|
"aria-live": "assertive",
|
|
@@ -50,184 +50,185 @@ class qt extends HTMLElement {
|
|
|
50
50
|
this.setAttribute(s, i);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
class
|
|
53
|
+
qt && !customElements.get("morph-announcer") && customElements.define("morph-announcer", Ft);
|
|
54
|
+
var R, l, I, rt, J;
|
|
55
|
+
class Lt {
|
|
56
56
|
constructor(t, s) {
|
|
57
|
-
a(this,
|
|
57
|
+
a(this, R);
|
|
58
58
|
a(this, l);
|
|
59
|
-
a(this,
|
|
60
|
-
a(this,
|
|
59
|
+
a(this, I);
|
|
60
|
+
a(this, rt, (t) => {
|
|
61
61
|
var i;
|
|
62
|
-
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this,
|
|
62
|
+
if (t.preventDefault(), e(this, l).hasAttribute("data-back") && e(this, R).previousURL)
|
|
63
63
|
history.back();
|
|
64
64
|
else {
|
|
65
|
-
n(this,
|
|
66
|
-
const
|
|
65
|
+
n(this, I, e(this, l).getAttribute("href") || "/");
|
|
66
|
+
const d = e(this, l).getAttribute(
|
|
67
67
|
"data-history-action"
|
|
68
|
-
) || "push", v = e(this, l).hasAttribute("data-center-scroll"),
|
|
68
|
+
) || "push", v = e(this, l).hasAttribute("data-center-scroll"), k = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), L = k ? ee.parse(k) : void 0, w = e(this, l).hasAttribute("data-revalidate"), O = e(this, l).hasAttribute(
|
|
69
69
|
"data-keep-search-parameters"
|
|
70
|
-
),
|
|
71
|
-
e(this,
|
|
72
|
-
historyAction:
|
|
70
|
+
), h = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((lt) => lt.trim()), at = e(this, l).hasAttribute("data-clear-state");
|
|
71
|
+
e(this, R).navigate(e(this, I), {
|
|
72
|
+
historyAction: d,
|
|
73
73
|
centerScroll: v,
|
|
74
|
-
offsetScroll:
|
|
75
|
-
revalidate:
|
|
76
|
-
keepSearchParameters:
|
|
77
|
-
submorph:
|
|
78
|
-
clearState:
|
|
74
|
+
offsetScroll: L,
|
|
75
|
+
revalidate: w,
|
|
76
|
+
keepSearchParameters: O,
|
|
77
|
+
submorph: h,
|
|
78
|
+
clearState: at
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
a(this,
|
|
82
|
+
a(this, J, () => {
|
|
83
83
|
const t = e(this, l).hasAttribute("data-revalidate");
|
|
84
|
-
e(this,
|
|
84
|
+
e(this, R).prefetch(e(this, I), t), e(this, l).removeEventListener("pointerenter", e(this, J));
|
|
85
85
|
});
|
|
86
|
-
n(this,
|
|
86
|
+
n(this, R, s), n(this, l, t), n(this, I, e(this, l).getAttribute("href") || "/"), e(this, l).addEventListener("click", e(this, rt)), this.checkCurrent(location.pathname), e(this, l).hasAttribute("data-prefetch") && e(this, l).addEventListener("pointerenter", e(this, J));
|
|
87
87
|
}
|
|
88
88
|
get element() {
|
|
89
89
|
return e(this, l);
|
|
90
90
|
}
|
|
91
91
|
checkCurrent(t) {
|
|
92
|
-
const s = e(this,
|
|
92
|
+
const s = e(this, R).normalizePath(t), i = e(this, R).normalizePath(e(this, I));
|
|
93
93
|
e(this, l).hasAttribute("data-include") && s.pathname.includes(i.pathname) ? e(this, l).classList.add("current") : i.pathname === s.pathname ? e(this, l).classList.add("current") : e(this, l).classList.remove("current");
|
|
94
94
|
}
|
|
95
95
|
destroy() {
|
|
96
|
-
e(this, l).removeEventListener("click", e(this,
|
|
96
|
+
e(this, l).removeEventListener("click", e(this, rt)), e(this, l).removeEventListener("pointerenter", e(this, J)), e(this, l).classList.remove("current");
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
var
|
|
99
|
+
R = new WeakMap(), l = new WeakMap(), I = new WeakMap(), rt = new WeakMap(), J = new WeakMap();
|
|
100
|
+
const se = new DOMParser();
|
|
101
|
+
var H, Y, y, C, X, V, Q, j, q, Z;
|
|
102
102
|
class It {
|
|
103
103
|
constructor(t, s) {
|
|
104
|
-
a(this,
|
|
105
|
-
a(this,
|
|
106
|
-
a(this,
|
|
107
|
-
a(this,
|
|
104
|
+
a(this, H);
|
|
105
|
+
a(this, Y);
|
|
106
|
+
a(this, y, { x: 0, y: 0 });
|
|
107
|
+
a(this, C, null);
|
|
108
|
+
a(this, X, null);
|
|
109
|
+
a(this, V, null);
|
|
110
|
+
a(this, Q, null);
|
|
108
111
|
a(this, j, null);
|
|
109
|
-
a(this,
|
|
110
|
-
a(this,
|
|
111
|
-
|
|
112
|
-
a(this, W, null);
|
|
113
|
-
n(this, M, t), n(this, z, s);
|
|
112
|
+
a(this, q, null);
|
|
113
|
+
a(this, Z);
|
|
114
|
+
n(this, H, t), n(this, Y, s), n(this, Z, s);
|
|
114
115
|
}
|
|
115
|
-
get
|
|
116
|
-
return e(this,
|
|
116
|
+
get pathname() {
|
|
117
|
+
return e(this, Y);
|
|
117
118
|
}
|
|
118
119
|
get scrollState() {
|
|
119
|
-
return e(this,
|
|
120
|
+
return e(this, y);
|
|
120
121
|
}
|
|
121
122
|
get document() {
|
|
122
|
-
return e(this,
|
|
123
|
+
return e(this, V);
|
|
123
124
|
}
|
|
124
125
|
setInitialDocument(t) {
|
|
125
|
-
n(this,
|
|
126
|
+
n(this, C, t.cloneNode(!0));
|
|
126
127
|
}
|
|
127
128
|
abort() {
|
|
128
129
|
var t;
|
|
129
|
-
return (t = e(this,
|
|
130
|
-
`[${e(this,
|
|
130
|
+
return (t = e(this, j)) == null ? void 0 : t.abort(
|
|
131
|
+
`[${e(this, Y)}] page loading cancelled`
|
|
131
132
|
);
|
|
132
133
|
}
|
|
133
|
-
fetch(t) {
|
|
134
|
-
return
|
|
135
|
-
return e(this,
|
|
134
|
+
fetch(t, s) {
|
|
135
|
+
return W(this, null, function* () {
|
|
136
|
+
return e(this, q) || e(this, C) && e(this, C).documentElement.hasAttribute("data-cache") && !s && e(this, Z) !== t || e(this, C) && e(this, H).isPopstateNavigation ? e(this, q) : (n(this, q, new Promise((i) => W(this, null, function* () {
|
|
136
137
|
try {
|
|
137
|
-
n(this,
|
|
138
|
-
const
|
|
139
|
-
signal: e(this,
|
|
140
|
-
})).text(),
|
|
141
|
-
this.setInitialDocument(
|
|
142
|
-
} catch (
|
|
143
|
-
console.warn(
|
|
138
|
+
n(this, j, new AbortController());
|
|
139
|
+
const v = yield (yield fetch(t, {
|
|
140
|
+
signal: e(this, j).signal
|
|
141
|
+
})).text(), k = se.parseFromString(v, "text/html");
|
|
142
|
+
this.setInitialDocument(k);
|
|
143
|
+
} catch (d) {
|
|
144
|
+
console.warn(d);
|
|
144
145
|
} finally {
|
|
145
|
-
n(this,
|
|
146
|
+
n(this, Z, t), n(this, j, null), n(this, q, null), i();
|
|
146
147
|
}
|
|
147
|
-
}))), e(this,
|
|
148
|
+
}))), e(this, q));
|
|
148
149
|
});
|
|
149
150
|
}
|
|
150
151
|
cloneDocument() {
|
|
151
|
-
n(this,
|
|
152
|
+
n(this, V, (e(this, X) || e(this, C)).cloneNode(!0));
|
|
152
153
|
}
|
|
153
154
|
get title() {
|
|
154
155
|
let t = "";
|
|
155
|
-
if (e(this,
|
|
156
|
-
t = e(this,
|
|
156
|
+
if (e(this, V).title)
|
|
157
|
+
t = e(this, V).title;
|
|
157
158
|
else {
|
|
158
|
-
const s = e(this,
|
|
159
|
-
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this,
|
|
159
|
+
const s = e(this, V).querySelector("h1");
|
|
160
|
+
t = (s == null ? void 0 : s.innerText) || (s == null ? void 0 : s.textContent) || e(this, Y);
|
|
160
161
|
}
|
|
161
162
|
return t;
|
|
162
163
|
}
|
|
163
164
|
clearScrollState() {
|
|
164
|
-
e(this,
|
|
165
|
+
e(this, y).x = 0, e(this, y).y = 0;
|
|
165
166
|
}
|
|
166
167
|
clearDocumentState() {
|
|
167
|
-
n(this,
|
|
168
|
+
n(this, X, null);
|
|
168
169
|
}
|
|
169
170
|
saveScrollState() {
|
|
170
|
-
e(this,
|
|
171
|
+
e(this, C).documentElement.hasAttribute(
|
|
171
172
|
"data-no-scroll-restoration"
|
|
172
|
-
) ? (e(this,
|
|
173
|
+
) ? (e(this, y).x = 0, e(this, y).y = 0) : (e(this, y).x = e(this, H).scrollValue.left, e(this, y).y = e(this, H).scrollValue.top);
|
|
173
174
|
}
|
|
174
175
|
restoreScrollPosition() {
|
|
175
|
-
e(this,
|
|
176
|
-
top: e(this,
|
|
177
|
-
left: e(this,
|
|
176
|
+
e(this, H).scrollElement.scroll({
|
|
177
|
+
top: e(this, y).y,
|
|
178
|
+
left: e(this, y).x,
|
|
178
179
|
behavior: "instant"
|
|
179
180
|
});
|
|
180
181
|
}
|
|
181
182
|
saveDocumentState() {
|
|
182
|
-
e(this,
|
|
183
|
+
e(this, C).documentElement.hasAttribute(
|
|
183
184
|
"data-no-page-restoration"
|
|
184
|
-
) ? n(this,
|
|
185
|
+
) ? n(this, X, null) : n(this, X, document.cloneNode(!0));
|
|
185
186
|
}
|
|
186
187
|
renewScrollPosition() {
|
|
187
|
-
e(this,
|
|
188
|
+
e(this, H).scrollElement.scroll({
|
|
188
189
|
top: 0,
|
|
189
190
|
left: 0,
|
|
190
191
|
behavior: "instant"
|
|
191
192
|
});
|
|
192
193
|
}
|
|
193
194
|
saveState(t) {
|
|
194
|
-
n(this,
|
|
195
|
+
n(this, Q, t);
|
|
195
196
|
}
|
|
196
197
|
clearState() {
|
|
197
|
-
const t = e(this,
|
|
198
|
-
return n(this,
|
|
198
|
+
const t = e(this, Q);
|
|
199
|
+
return n(this, Q, null), t;
|
|
199
200
|
}
|
|
200
201
|
}
|
|
201
|
-
|
|
202
|
-
var
|
|
203
|
-
const
|
|
202
|
+
H = new WeakMap(), Y = new WeakMap(), y = new WeakMap(), C = new WeakMap(), X = new WeakMap(), V = new WeakMap(), Q = new WeakMap(), j = new WeakMap(), q = new WeakMap(), Z = new WeakMap();
|
|
203
|
+
var T, _, g, F, m, K, B, x, A, nt, N, $, tt, et, ot, c, ut, vt, Bt, yt, bt, At, kt, dt, st;
|
|
204
|
+
const it = class it {
|
|
204
205
|
constructor(t) {
|
|
205
206
|
a(this, c);
|
|
206
|
-
a(this,
|
|
207
|
-
a(this,
|
|
207
|
+
a(this, T, null);
|
|
208
|
+
a(this, _, null);
|
|
208
209
|
a(this, g, []);
|
|
209
|
-
a(this,
|
|
210
|
-
a(this,
|
|
211
|
-
a(this,
|
|
212
|
-
a(this,
|
|
210
|
+
a(this, F);
|
|
211
|
+
a(this, m, null);
|
|
212
|
+
a(this, K);
|
|
213
|
+
a(this, B, []);
|
|
213
214
|
a(this, x, !1);
|
|
214
215
|
a(this, A, null);
|
|
215
|
-
a(this,
|
|
216
|
+
a(this, nt, !1);
|
|
216
217
|
a(this, N, /* @__PURE__ */ new Map());
|
|
217
218
|
a(this, $, null);
|
|
218
|
-
a(this,
|
|
219
|
-
a(this,
|
|
220
|
-
a(this,
|
|
219
|
+
a(this, tt, 0);
|
|
220
|
+
a(this, et, 0);
|
|
221
|
+
a(this, ot, (t) => {
|
|
221
222
|
var s;
|
|
222
223
|
return ((s = t.getAttribute("href")) == null ? void 0 : s.startsWith("/")) && !t.hasAttribute("download") && !t.hasAttribute("data-morph-skip") && !t.closest("[data-morph-skip]") && t.getAttribute("target") !== "_blank";
|
|
223
224
|
});
|
|
224
|
-
a(this,
|
|
225
|
+
a(this, dt, (t) => W(this, null, function* () {
|
|
225
226
|
var s;
|
|
226
227
|
(s = t.state) != null && s.path && (t.preventDefault(), n(this, x, !0), yield this.navigate(t.state.path, { historyAction: "none" }), n(this, x, !1));
|
|
227
228
|
}));
|
|
228
|
-
a(this,
|
|
229
|
-
const { left: t, top: s } = this.scrollValue, i = s - e(this,
|
|
230
|
-
n(this,
|
|
229
|
+
a(this, st, () => {
|
|
230
|
+
const { left: t, top: s } = this.scrollValue, i = s - e(this, et), d = t - e(this, tt);
|
|
231
|
+
n(this, et, s), n(this, tt, t), document.documentElement.classList.toggle("scroll-y", s > 0), document.documentElement.classList.toggle("scroll-x", t > 0), document.documentElement.classList.toggle(
|
|
231
232
|
"scroll-y-forward",
|
|
232
233
|
i > 0
|
|
233
234
|
), document.documentElement.classList.toggle(
|
|
@@ -235,49 +236,49 @@ const et = class et {
|
|
|
235
236
|
i < 0
|
|
236
237
|
), document.documentElement.classList.toggle(
|
|
237
238
|
"scroll-x-forward",
|
|
238
|
-
|
|
239
|
+
d > 0
|
|
239
240
|
), document.documentElement.classList.toggle(
|
|
240
241
|
"scroll-x-backward",
|
|
241
|
-
|
|
242
|
-
),
|
|
242
|
+
d < 0
|
|
243
|
+
), z(document, "morphScroll", {
|
|
243
244
|
detail: {
|
|
244
245
|
left: t,
|
|
245
246
|
top: s
|
|
246
247
|
}
|
|
247
248
|
});
|
|
248
249
|
});
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
base:
|
|
250
|
+
if (qt && !it.instance) {
|
|
251
|
+
it.instance = this, n(this, T, {
|
|
252
|
+
base: _t(t == null ? void 0 : t.base),
|
|
252
253
|
waitForHeadToLoad: (t == null ? void 0 : t.waitForHeadToLoad) !== !1,
|
|
253
254
|
trailingSlash: (t == null ? void 0 : t.trailingSlash) || !1,
|
|
254
255
|
scrollSelector: t == null ? void 0 : t.scrollSelector,
|
|
255
256
|
morphInsideScrollContainer: (t == null ? void 0 : t.morphInsideScrollContainer) || !1
|
|
256
|
-
}), n(this,
|
|
257
|
+
}), n(this, _, E(this, c, vt).call(this, document.body));
|
|
257
258
|
const s = this.normalizePath(
|
|
258
259
|
location.pathname + location.hash + location.search
|
|
259
260
|
);
|
|
260
|
-
n(this,
|
|
261
|
-
const i = new It(this, e(this,
|
|
262
|
-
i.setInitialDocument(document), e(this, N).set(e(this,
|
|
261
|
+
n(this, m, s);
|
|
262
|
+
const i = new It(this, e(this, m).pathname);
|
|
263
|
+
i.setInitialDocument(document), e(this, N).set(e(this, m).path, i), document.documentElement.setAttribute(
|
|
263
264
|
"data-current-pathname",
|
|
264
|
-
e(this,
|
|
265
|
+
e(this, m).pathname
|
|
265
266
|
), document.documentElement.setAttribute(
|
|
266
267
|
"data-current-leaf",
|
|
267
268
|
s.leaf
|
|
268
|
-
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this,
|
|
269
|
+
), this.findLinks(), history.scrollRestoration = "manual", addEventListener("popstate", e(this, dt)), St({
|
|
269
270
|
action: "replace",
|
|
270
271
|
pathname: s.pathname,
|
|
271
272
|
searchParameters: s.parameters,
|
|
272
273
|
hash: s.hash
|
|
273
|
-
}), n(this, $, new
|
|
274
|
+
}), n(this, $, new Ft()), E(this, c, At).call(this, document);
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
|
-
get
|
|
277
|
-
return e(this,
|
|
277
|
+
get currentURL() {
|
|
278
|
+
return e(this, m);
|
|
278
279
|
}
|
|
279
|
-
get
|
|
280
|
-
return e(this,
|
|
280
|
+
get previousURL() {
|
|
281
|
+
return e(this, K);
|
|
281
282
|
}
|
|
282
283
|
get links() {
|
|
283
284
|
return e(this, g);
|
|
@@ -290,232 +291,242 @@ const et = class et {
|
|
|
290
291
|
}
|
|
291
292
|
get scrollValue() {
|
|
292
293
|
let t = 0, s = 0;
|
|
293
|
-
return e(this,
|
|
294
|
+
return e(this, nt) ? (t = window.scrollY, s = window.scrollX) : (t = e(this, A).scrollTop, s = e(this, A).scrollLeft), { top: t, left: s };
|
|
294
295
|
}
|
|
295
296
|
saveState(t) {
|
|
296
|
-
const s = e(this, N).get(e(this,
|
|
297
|
+
const s = e(this, N).get(e(this, m).path);
|
|
297
298
|
s && s.saveState(t);
|
|
298
299
|
}
|
|
299
300
|
getState() {
|
|
300
|
-
const t = e(this, N).get(e(this,
|
|
301
|
+
const t = e(this, N).get(e(this, m).path);
|
|
301
302
|
return t == null ? void 0 : t.clearState();
|
|
302
303
|
}
|
|
303
304
|
normalizePath(t) {
|
|
304
|
-
return
|
|
305
|
-
base: e(this,
|
|
306
|
-
trailingSlash: e(this,
|
|
305
|
+
return te(t, {
|
|
306
|
+
base: e(this, T).base,
|
|
307
|
+
trailingSlash: e(this, T).trailingSlash
|
|
307
308
|
});
|
|
308
309
|
}
|
|
309
310
|
prefetch(t, s) {
|
|
310
|
-
return
|
|
311
|
-
if (e(this,
|
|
311
|
+
return W(this, null, function* () {
|
|
312
|
+
if (e(this, B).length)
|
|
312
313
|
return;
|
|
313
|
-
const i = E(this, c,
|
|
314
|
-
i == null || i.fetch(s);
|
|
314
|
+
const i = E(this, c, ut).call(this, t);
|
|
315
|
+
i == null || i.fetch(t, s);
|
|
315
316
|
});
|
|
316
317
|
}
|
|
317
|
-
navigate(
|
|
318
|
-
return
|
|
318
|
+
navigate(O) {
|
|
319
|
+
return W(this, arguments, function* (t, {
|
|
319
320
|
historyAction: s = "push",
|
|
320
321
|
centerScroll: i,
|
|
321
|
-
offsetScroll:
|
|
322
|
+
offsetScroll: d,
|
|
322
323
|
revalidate: v,
|
|
323
|
-
keepSearchParameters:
|
|
324
|
-
submorph:
|
|
325
|
-
clearState:
|
|
324
|
+
keepSearchParameters: k,
|
|
325
|
+
submorph: L,
|
|
326
|
+
clearState: w
|
|
326
327
|
} = {}) {
|
|
327
|
-
var
|
|
328
|
-
if (e(this,
|
|
328
|
+
var at, lt, Pt;
|
|
329
|
+
if (e(this, B).length)
|
|
329
330
|
return;
|
|
330
|
-
const
|
|
331
|
-
((
|
|
331
|
+
const h = this.normalizePath(
|
|
332
|
+
((at = this.pathnameModifier) == null ? void 0 : at.call(this, t)) || t
|
|
332
333
|
);
|
|
333
|
-
if (e(this,
|
|
334
|
-
e(this, x) || E(this, c,
|
|
334
|
+
if (((lt = e(this, F)) == null ? void 0 : lt.pathname) === h.pathname || e(this, m).pathname === h.pathname) {
|
|
335
|
+
e(this, x) || E(this, c, kt).call(this, h.hash || 0, {
|
|
335
336
|
centerScroll: i,
|
|
336
|
-
offsetScroll:
|
|
337
|
+
offsetScroll: d,
|
|
337
338
|
behavior: "smooth"
|
|
338
|
-
})
|
|
339
|
+
}), ((Pt = e(this, m)) == null ? void 0 : Pt.parameters) !== h.parameters && (n(this, K, e(this, m)), n(this, m, h), St({
|
|
340
|
+
action: s,
|
|
341
|
+
pathname: h.pathname,
|
|
342
|
+
searchParameters: h.parameters,
|
|
343
|
+
hash: h.hash
|
|
344
|
+
}), z(document, "morphURLParametersChange", {
|
|
345
|
+
detail: {
|
|
346
|
+
newURL: e(this, m),
|
|
347
|
+
previousURL: e(this, K)
|
|
348
|
+
}
|
|
349
|
+
}));
|
|
339
350
|
return;
|
|
340
351
|
}
|
|
341
|
-
n(this,
|
|
342
|
-
|
|
352
|
+
n(this, F, h), e(this, g).forEach((G) => {
|
|
353
|
+
G.checkCurrent(h.pathname);
|
|
343
354
|
});
|
|
344
355
|
try {
|
|
345
|
-
let
|
|
356
|
+
let G = !0;
|
|
346
357
|
if (this.preprocessor)
|
|
347
358
|
try {
|
|
348
|
-
yield new Promise((o,
|
|
359
|
+
yield new Promise((o, M) => {
|
|
349
360
|
var p;
|
|
350
361
|
(p = this.preprocessor) == null || p.call(this, {
|
|
351
|
-
|
|
362
|
+
url: h,
|
|
352
363
|
resolve: o,
|
|
353
|
-
reject:
|
|
354
|
-
submorph:
|
|
364
|
+
reject: M,
|
|
365
|
+
submorph: L
|
|
355
366
|
});
|
|
356
367
|
});
|
|
357
368
|
} catch (o) {
|
|
358
|
-
o ? console.error(o) : console.log("Route change canceled"),
|
|
369
|
+
o ? console.error(o) : console.log("Route change canceled"), G = !1;
|
|
359
370
|
}
|
|
360
|
-
if (!
|
|
371
|
+
if (!G || e(this, F).pathname !== h.pathname) {
|
|
361
372
|
e(this, g).forEach((o) => {
|
|
362
|
-
o.checkCurrent(e(this,
|
|
373
|
+
o.checkCurrent(e(this, m).pathname);
|
|
363
374
|
});
|
|
364
375
|
return;
|
|
365
376
|
}
|
|
366
|
-
const
|
|
367
|
-
|
|
368
|
-
submorph:
|
|
377
|
+
const Ct = {
|
|
378
|
+
url: h,
|
|
379
|
+
submorph: L
|
|
369
380
|
};
|
|
370
|
-
|
|
371
|
-
detail:
|
|
381
|
+
z(document, "morphNavigation", {
|
|
382
|
+
detail: Ct
|
|
372
383
|
});
|
|
373
|
-
const
|
|
384
|
+
const mt = E(this, c, ut).call(this, e(this, m).pathname), f = E(this, c, ut).call(this, t);
|
|
374
385
|
if (e(this, N).forEach((o) => {
|
|
375
|
-
o.
|
|
376
|
-
}), yield
|
|
386
|
+
o.pathname !== h.pathname && o.abort();
|
|
387
|
+
}), yield f == null ? void 0 : f.fetch(t, v), e(this, F).pathname !== h.pathname) {
|
|
377
388
|
e(this, g).forEach((o) => {
|
|
378
|
-
o.checkCurrent(e(this,
|
|
389
|
+
o.checkCurrent(e(this, m).path);
|
|
379
390
|
});
|
|
380
391
|
return;
|
|
381
392
|
}
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
document:
|
|
393
|
+
mt.clearState(), mt.saveScrollState(), mt.saveDocumentState(), e(this, x) || (f.clearScrollState(), f.clearDocumentState()), w && f.clearState(), f.cloneDocument(), e(this, $).textContent = f.title, document.body.appendChild(e(this, $));
|
|
394
|
+
const ft = gt(Et({}, Ct), {
|
|
395
|
+
document: f.document
|
|
385
396
|
});
|
|
386
|
-
|
|
387
|
-
detail:
|
|
397
|
+
z(document, "morphStart", {
|
|
398
|
+
detail: ft
|
|
388
399
|
});
|
|
389
|
-
const
|
|
390
|
-
|
|
400
|
+
const Tt = Array.from(document.head.children), Mt = Array.from(f.document.head.children), Rt = E(this, c, Bt).call(this, Tt, Mt), Ot = E(this, c, yt).call(this, Tt, Rt), ht = E(this, c, yt).call(this, Mt, Rt);
|
|
401
|
+
ht.forEach((o, M) => {
|
|
391
402
|
if (o.tagName === "SCRIPT" && o.getAttribute("src")) {
|
|
392
|
-
const p = document.createElement("script"),
|
|
393
|
-
|
|
403
|
+
const p = document.createElement("script"), D = o.getAttribute("src");
|
|
404
|
+
D.includes("http") || (p.type = "module"), p.src = D, ht[M] = p;
|
|
394
405
|
}
|
|
395
|
-
}),
|
|
406
|
+
}), ht.forEach((o) => {
|
|
396
407
|
document.head.appendChild(o);
|
|
397
408
|
});
|
|
398
|
-
const
|
|
409
|
+
const pt = ht.filter((o) => {
|
|
399
410
|
if (o.hasAttribute("data-no-waiting"))
|
|
400
411
|
return !1;
|
|
401
|
-
if (E(this, c,
|
|
412
|
+
if (E(this, c, bt).call(this, o))
|
|
402
413
|
return !0;
|
|
403
414
|
});
|
|
404
|
-
e(this,
|
|
405
|
-
let
|
|
415
|
+
e(this, T).waitForHeadToLoad && pt.length && (yield new Promise((o) => W(this, null, function* () {
|
|
416
|
+
let M = 0;
|
|
406
417
|
try {
|
|
407
|
-
for (var p =
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
418
|
+
for (var p = zt(pt), D, b, P; D = !(b = yield p.next()).done; D = !1) {
|
|
419
|
+
const ct = b.value;
|
|
420
|
+
ct.onload = () => {
|
|
421
|
+
M++, M === pt.length && o();
|
|
411
422
|
};
|
|
412
423
|
}
|
|
413
|
-
} catch (
|
|
414
|
-
P = [
|
|
424
|
+
} catch (b) {
|
|
425
|
+
P = [b];
|
|
415
426
|
} finally {
|
|
416
427
|
try {
|
|
417
|
-
|
|
428
|
+
D && (b = p.return) && (yield b.call(p));
|
|
418
429
|
} finally {
|
|
419
430
|
if (P)
|
|
420
431
|
throw P[0];
|
|
421
432
|
}
|
|
422
433
|
}
|
|
423
|
-
}))), yield
|
|
424
|
-
const
|
|
425
|
-
|
|
426
|
-
o.hasAttribute("data-permanent") || (E(this, c,
|
|
434
|
+
}))), yield Qt(10);
|
|
435
|
+
const Ht = [];
|
|
436
|
+
Ot.forEach((o) => {
|
|
437
|
+
o.hasAttribute("data-permanent") || (E(this, c, bt).call(this, o) ? Ht.push(o) : o.remove());
|
|
427
438
|
});
|
|
428
|
-
const Wt = E(this, c,
|
|
429
|
-
e(this,
|
|
439
|
+
const Wt = E(this, c, vt).call(this, f.document.body);
|
|
440
|
+
e(this, T).morphInsideScrollContainer || E(this, c, At).call(this, f.document), document.documentElement.setAttribute(
|
|
430
441
|
"data-current-pathname",
|
|
431
|
-
|
|
442
|
+
h.pathname
|
|
432
443
|
), document.documentElement.setAttribute(
|
|
433
444
|
"data-current-leaf",
|
|
434
|
-
|
|
435
|
-
),
|
|
445
|
+
h.leaf
|
|
446
|
+
), St({
|
|
436
447
|
action: s,
|
|
437
|
-
pathname:
|
|
438
|
-
searchParameters:
|
|
439
|
-
hash:
|
|
440
|
-
}), e(this, $).remove(), n(this,
|
|
441
|
-
const p = Wt[
|
|
442
|
-
let
|
|
443
|
-
|
|
444
|
-
const
|
|
445
|
-
|
|
446
|
-
}) : (
|
|
447
|
-
|
|
448
|
-
}),
|
|
449
|
-
|
|
450
|
-
}),
|
|
451
|
-
var
|
|
452
|
-
(
|
|
453
|
-
|
|
454
|
-
P[
|
|
448
|
+
pathname: h.pathname,
|
|
449
|
+
searchParameters: h.parameters || (k ? location.search : ""),
|
|
450
|
+
hash: h.hash
|
|
451
|
+
}), e(this, $).remove(), n(this, K, e(this, m)), n(this, m, h), e(this, _).forEach((o, M) => {
|
|
452
|
+
const p = Wt[M], D = getComputedStyle(o).getPropertyValue("--morph-duration");
|
|
453
|
+
let b = [], P = [];
|
|
454
|
+
L ? L.forEach((u) => {
|
|
455
|
+
const S = o.querySelector(u), U = p.querySelector(u);
|
|
456
|
+
S && U && (P.push(S), b.push(U));
|
|
457
|
+
}) : (b.push(...p.childNodes), P.push(...o.childNodes)), P.forEach((u) => {
|
|
458
|
+
u instanceof HTMLElement && (this.destroyOldLinks(u), u.classList.add("old"));
|
|
459
|
+
}), b.forEach((u) => {
|
|
460
|
+
u instanceof HTMLElement && (this.findNewLinks(u), u.classList.add("new"));
|
|
461
|
+
}), L ? b.forEach((u, S) => {
|
|
462
|
+
var U;
|
|
463
|
+
(U = P[S].parentElement) == null || U.insertBefore(
|
|
464
|
+
u,
|
|
465
|
+
P[S]
|
|
455
466
|
);
|
|
456
|
-
}) : o.prepend(...
|
|
457
|
-
P.forEach((
|
|
458
|
-
|
|
459
|
-
}),
|
|
460
|
-
var
|
|
461
|
-
|
|
467
|
+
}) : o.prepend(...b), Jt(() => {
|
|
468
|
+
P.forEach((u) => {
|
|
469
|
+
u instanceof HTMLElement && u.classList.add("old-idle");
|
|
470
|
+
}), b.forEach((u) => {
|
|
471
|
+
var S;
|
|
472
|
+
u instanceof HTMLElement && ((S = u.parentElement) == null || S.style.setProperty(
|
|
462
473
|
"--new-content-height",
|
|
463
|
-
|
|
464
|
-
),
|
|
474
|
+
u.offsetHeight + "px"
|
|
475
|
+
), u.classList.add("new-idle"));
|
|
465
476
|
});
|
|
466
477
|
});
|
|
467
|
-
const
|
|
478
|
+
const ct = gt(Et({}, ft), {
|
|
468
479
|
morphElement: o
|
|
469
480
|
});
|
|
470
|
-
|
|
471
|
-
detail:
|
|
481
|
+
z(document, "morphNewChildrenAdded", {
|
|
482
|
+
detail: ct
|
|
472
483
|
});
|
|
473
|
-
const
|
|
484
|
+
const Yt = new Promise((u) => {
|
|
474
485
|
setTimeout(() => {
|
|
475
|
-
P.forEach((
|
|
476
|
-
var
|
|
477
|
-
|
|
486
|
+
P.forEach((S) => S.remove()), b.forEach((S) => {
|
|
487
|
+
var U;
|
|
488
|
+
S instanceof HTMLElement && ((U = S.parentElement) == null || U.style.removeProperty(
|
|
478
489
|
"--new-content-height"
|
|
479
|
-
),
|
|
480
|
-
}),
|
|
481
|
-
detail:
|
|
482
|
-
}),
|
|
483
|
-
}, (parseFloat(
|
|
490
|
+
), S.classList.remove("new-idle", "new"));
|
|
491
|
+
}), z(document, "morphOldChildrenRemoved", {
|
|
492
|
+
detail: ct
|
|
493
|
+
}), u();
|
|
494
|
+
}, (parseFloat(D) || 0) * 1e3 + 10);
|
|
484
495
|
});
|
|
485
|
-
e(this,
|
|
496
|
+
e(this, B).push(Yt);
|
|
486
497
|
}), this.isPopstateNavigation ? document.documentElement.style.setProperty(
|
|
487
498
|
"--new-document-scroll-position",
|
|
488
|
-
(this.scrollValue.top -
|
|
499
|
+
(this.scrollValue.top - f.scrollState.y) * 1 + "px"
|
|
489
500
|
) : document.documentElement.style.setProperty(
|
|
490
501
|
"--new-document-scroll-position",
|
|
491
502
|
this.scrollValue.top + "px"
|
|
492
|
-
),
|
|
493
|
-
detail:
|
|
494
|
-
}),
|
|
503
|
+
), z(document, "morphBeforeNavigationScroll", {
|
|
504
|
+
detail: f.scrollState
|
|
505
|
+
}), h.hash ? (f.clearScrollState(), E(this, c, kt).call(this, h.hash, {
|
|
495
506
|
centerScroll: i,
|
|
496
|
-
offsetScroll:
|
|
497
|
-
})) : e(this, x) ?
|
|
507
|
+
offsetScroll: d
|
|
508
|
+
})) : e(this, x) ? f.restoreScrollPosition() : f.renewScrollPosition(), yield Promise.all(e(this, B)), Ht.forEach((o) => o.remove()), n(this, B, []), e(this, _).forEach((o) => {
|
|
498
509
|
o.querySelectorAll("script").forEach((p) => {
|
|
499
|
-
const
|
|
500
|
-
for (let
|
|
501
|
-
const P = p.attributes[
|
|
502
|
-
|
|
510
|
+
const D = document.createElement("script");
|
|
511
|
+
for (let b = 0; b < p.attributes.length; b++) {
|
|
512
|
+
const P = p.attributes[b];
|
|
513
|
+
D.setAttribute(P.name, P.value);
|
|
503
514
|
}
|
|
504
|
-
p.hasAttribute("src") || (
|
|
515
|
+
p.hasAttribute("src") || (D.innerHTML = p.innerHTML), p.replaceWith(D);
|
|
505
516
|
});
|
|
506
|
-
}),
|
|
507
|
-
detail:
|
|
517
|
+
}), z(document, "morphComplete", {
|
|
518
|
+
detail: ft
|
|
508
519
|
}), document.documentElement.style.removeProperty(
|
|
509
520
|
"--new-document-scroll-position"
|
|
510
521
|
), window.dispatchEvent(new Event("resize"));
|
|
511
|
-
} catch (
|
|
512
|
-
console.error(
|
|
522
|
+
} catch (G) {
|
|
523
|
+
console.error(G);
|
|
513
524
|
}
|
|
514
|
-
n(this,
|
|
525
|
+
n(this, F, void 0);
|
|
515
526
|
});
|
|
516
527
|
}
|
|
517
528
|
addLink(t) {
|
|
518
|
-
e(this, g).push(new
|
|
529
|
+
e(this, g).push(new Lt(t, this));
|
|
519
530
|
}
|
|
520
531
|
addLinks(t) {
|
|
521
532
|
t.forEach((s) => {
|
|
@@ -530,55 +541,56 @@ const et = class et {
|
|
|
530
541
|
}
|
|
531
542
|
findNewLinks(t) {
|
|
532
543
|
const s = [...t.querySelectorAll("a")].filter(
|
|
533
|
-
e(this,
|
|
544
|
+
e(this, ot)
|
|
534
545
|
);
|
|
535
546
|
e(this, g).push(
|
|
536
|
-
...s.map((i) => new
|
|
547
|
+
...s.map((i) => new Lt(i, this))
|
|
537
548
|
);
|
|
538
549
|
}
|
|
539
550
|
findLinks() {
|
|
540
551
|
const t = [
|
|
541
552
|
...document.documentElement.querySelectorAll("a")
|
|
542
|
-
].filter(e(this,
|
|
543
|
-
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new
|
|
553
|
+
].filter(e(this, ot));
|
|
554
|
+
e(this, g).forEach((s) => s.destroy()), n(this, g, t.map((s) => new Lt(s, this)));
|
|
544
555
|
}
|
|
545
556
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
557
|
+
T = new WeakMap(), _ = new WeakMap(), g = new WeakMap(), F = new WeakMap(), m = new WeakMap(), K = new WeakMap(), B = new WeakMap(), x = new WeakMap(), A = new WeakMap(), nt = new WeakMap(), N = new WeakMap(), $ = new WeakMap(), tt = new WeakMap(), et = new WeakMap(), ot = new WeakMap(), c = new WeakSet(), ut = function(t) {
|
|
558
|
+
const s = this.normalizePath(t);
|
|
559
|
+
let i = e(this, N).get(s.pathname);
|
|
560
|
+
return i || (i = new It(this, s.pathname), e(this, N).set(s.pathname, i)), i;
|
|
561
|
+
}, vt = function(t) {
|
|
550
562
|
const s = [...t.querySelectorAll("[data-morph]")];
|
|
551
563
|
return s.length ? s : [t];
|
|
552
|
-
},
|
|
564
|
+
}, Bt = function(t, s) {
|
|
553
565
|
return t.filter(
|
|
554
566
|
(i) => s.find(
|
|
555
|
-
(
|
|
567
|
+
(d) => d.outerHTML === i.outerHTML
|
|
556
568
|
)
|
|
557
569
|
);
|
|
558
|
-
},
|
|
570
|
+
}, yt = function(t, s) {
|
|
559
571
|
return t.filter(
|
|
560
572
|
(i) => !s.find(
|
|
561
|
-
(
|
|
573
|
+
(d) => d.outerHTML === i.outerHTML
|
|
562
574
|
)
|
|
563
575
|
);
|
|
564
|
-
},
|
|
576
|
+
}, bt = function(t) {
|
|
565
577
|
return t.tagName === "SCRIPT" || t.tagName === "STYLE" || t.tagName === "LINK" && t.getAttribute("rel") === "stylesheet";
|
|
566
|
-
},
|
|
578
|
+
}, At = function(t) {
|
|
567
579
|
var s, i;
|
|
568
580
|
(s = e(this, A)) == null || s.removeEventListener(
|
|
569
581
|
"scroll",
|
|
570
|
-
e(this,
|
|
571
|
-
), n(this,
|
|
572
|
-
},
|
|
582
|
+
e(this, st)
|
|
583
|
+
), n(this, et, 0), n(this, tt, 0), n(this, A, e(this, T).scrollSelector && t.querySelector(e(this, T).scrollSelector) || window), n(this, nt, e(this, A) === window), (i = e(this, A)) == null || i.addEventListener("scroll", e(this, st)), e(this, st).call(this);
|
|
584
|
+
}, kt = function(t, s) {
|
|
573
585
|
const i = typeof t == "string" ? document.getElementById(t) : t;
|
|
574
|
-
(typeof i == "number" || i) &&
|
|
586
|
+
(typeof i == "number" || i) && Zt(i, {
|
|
575
587
|
scrollElement: e(this, A),
|
|
576
588
|
behavior: (s == null ? void 0 : s.behavior) || "instant",
|
|
577
589
|
center: s == null ? void 0 : s.centerScroll,
|
|
578
590
|
offset: s == null ? void 0 : s.offsetScroll
|
|
579
591
|
});
|
|
580
|
-
},
|
|
581
|
-
let
|
|
592
|
+
}, dt = new WeakMap(), st = new WeakMap(), it.instance = null;
|
|
593
|
+
let Vt = it;
|
|
582
594
|
export {
|
|
583
|
-
|
|
595
|
+
Vt as Morph
|
|
584
596
|
};
|