aptechka 0.61.0 → 0.61.2
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 +4 -6
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.d.ts +1 -1
- package/lib/morph/index.js +44 -42
- package/package.json +1 -1
package/lib/morph/Morph.d.ts
CHANGED
|
@@ -10,8 +10,7 @@ export interface MorphOptions {
|
|
|
10
10
|
}
|
|
11
11
|
export interface MorphNavigationEntry {
|
|
12
12
|
pathname: string;
|
|
13
|
-
|
|
14
|
-
export interface MorphTransitionEntry extends MorphNavigationEntry {
|
|
13
|
+
submorph?: Array<string>;
|
|
15
14
|
}
|
|
16
15
|
export interface MorphChildrenActionEntry {
|
|
17
16
|
morphElement: HTMLElement;
|
|
@@ -22,7 +21,6 @@ export interface MorphPreprocessorEntry extends MorphNavigationEntry {
|
|
|
22
21
|
reject: () => void;
|
|
23
22
|
}
|
|
24
23
|
export type MorphPreprocessor = (entry: MorphPreprocessorEntry) => void;
|
|
25
|
-
export type MorphNavigationCallback = (entry: MorphNavigationEntry) => void;
|
|
26
24
|
export type MorphPathnameModifier = (pathname: string) => string;
|
|
27
25
|
export interface MorphNavigateOptions {
|
|
28
26
|
historyAction?: ChangeHistoryAction;
|
|
@@ -37,9 +35,9 @@ export interface MorphScrollDetail {
|
|
|
37
35
|
top: number;
|
|
38
36
|
}
|
|
39
37
|
export interface MorphEvents {
|
|
40
|
-
morphNavigation: CustomEvent<
|
|
41
|
-
morphStart: CustomEvent<
|
|
42
|
-
morphComplete: CustomEvent<
|
|
38
|
+
morphNavigation: CustomEvent<MorphNavigationEntry>;
|
|
39
|
+
morphStart: CustomEvent<MorphNavigationEntry>;
|
|
40
|
+
morphComplete: CustomEvent<MorphNavigationEntry>;
|
|
43
41
|
morphNewChildrenAdded: CustomEvent<MorphChildrenActionEntry>;
|
|
44
42
|
morphOldChildrenRemoved: CustomEvent<MorphChildrenActionEntry>;
|
|
45
43
|
morphScroll: CustomEvent<MorphScrollDetail>;
|
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var g=v=>{try{b(s.next(v))}catch(A){u(A)}},w=v=>{try{b(s.throw(v))}catch(A){u(A)}},b=v=>v.done?i(v.value):Promise.resolve(v.value).then(g,w);b((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=g=>new Promise((w,b,v)=>(g=u.call(n,g),v=g.done,Promise.resolve(g.value).then(A=>w({value:A,done:v}),b)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht 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)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",g=e(this,l).hasAttribute("data-center-scroll"),w=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),b=w?Ot.cssValueParser.parse(w):void 0,v=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:g,offsetScroll:b,revalidate:v,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).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,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,y,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,y,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,y)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,y).x=0,e(this,y).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,y).x=0,e(this,y).y=0):(e(this,y).x=e(this,x).scrollElement.scrollLeft,e(this,y).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,y).y,left:e(this,y).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,y=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,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,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(v){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:g,keepSearchParameters:w,submorph:b}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var S;(S=this.preprocessor)==null||S.call(this,{pathname:m,resolve:r,reject:k})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),L=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:g});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(L.clearScrollState(),L.clearDocumentState()),L.cloneDocument(),e(this,F).textContent=L.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(L.document.head.children),bt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,bt),et=d(this,c,mt).call(this,wt,bt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const S=document.createElement("script");S.type="module",S.src=r.getAttribute("src"),et[k]=S}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var S=kt(lt),Q,D,j;Q=!(D=yield S.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=S.return)&&(yield D.call(S))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const Lt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?Lt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,L.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,L.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(w?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const S=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];b?b.forEach(h=>{const E=r.querySelector(h),H=S.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...S.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),b?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(L.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?L.restoreScrollPosition():L.renewScrollPosition(),yield Promise.all(e(this,B)),Lt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(S=>{const Q=document.createElement("script");Q.type="module",Q.src=S.getAttribute("src"),S.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),g=e(this,nt).parseFromString(u,"text/html"),w=new Tt(this,t,g);return e(this,G).set(t,w),w})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=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,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.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})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
|
1
|
+
"use strict";var Pt=(n,t)=>(t=Symbol[n])?t:Symbol.for("Symbol."+n),At=n=>{throw TypeError(n)};var ct=(n,t,s)=>t.has(n)||At("Cannot "+s);var e=(n,t,s)=>(ct(n,t,"read from private field"),s?s.call(n):t.get(n)),o=(n,t,s)=>t.has(n)?At("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(n):t.set(n,s),a=(n,t,s,i)=>(ct(n,t,"write to private field"),i?i.call(n,s):t.set(n,s),s),d=(n,t,s)=>(ct(n,t,"access private method"),s);var R=(n,t,s)=>new Promise((i,u)=>{var v=S=>{try{g(s.next(S))}catch(A){u(A)}},L=S=>{try{g(s.throw(S))}catch(A){u(A)}},g=S=>S.done?i(S.value):Promise.resolve(S.value).then(v,L);g((s=s.apply(n,t)).next())});var kt=(n,t,s)=>(t=n[Pt("asyncIterator")])?t.call(n):(n=n[Pt("iterator")](),t={},s=(i,u)=>(u=n[i])&&(t[i]=v=>new Promise((L,g,S)=>(v=u.call(n,v),S=v.done,Promise.resolve(v.value).then(A=>L({value:A,done:S}),g)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Mt=require("../index-Cqw2NKev.cjs"),U=require("../events-KVanG9sR.cjs"),It=require("../polyfills-Df4r-ETT.cjs"),Ct=require("../scroll-DAhSpkhR.cjs"),it=require("../url-D1CgmwZ_.cjs"),Ot=require("../css-value-parser/index.cjs");class Ht 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)}}Mt.isBrowser&&!customElements.get("morph-announcer")&&customElements.define("morph-announcer",Ht);var C,l,z,Z,$;class ht{constructor(t,s){o(this,C);o(this,l);o(this,z);o(this,Z,t=>{var i;if(t.preventDefault(),e(this,l).hasAttribute("data-back")&&e(this,C).previousPathname)history.back();else{const u=e(this,l).getAttribute("data-history-action")||"push",v=e(this,l).hasAttribute("data-center-scroll"),L=getComputedStyle(e(this,l)).getPropertyValue("--offset-scroll").trim(),g=L?Ot.cssValueParser.parse(L):void 0,S=e(this,l).hasAttribute("data-revalidate"),A=e(this,l).hasAttribute("data-keep-search-parameters"),m=(i=e(this,l).getAttribute("data-submorph"))==null?void 0:i.split(",").map(V=>V.trim());e(this,C).navigate(e(this,z),{historyAction:u,centerScroll:v,offsetScroll:g,revalidate:S,keepSearchParameters:A,submorph:m})}});o(this,$,()=>{const t=e(this,l).hasAttribute("data-revalidate");e(this,C).prefetch(e(this,z),t),e(this,l).removeEventListener("pointerenter",e(this,$))});a(this,C,s),a(this,l,t),a(this,z,e(this,l).getAttribute("href")||"/"),e(this,l).addEventListener("click",e(this,Z)),this.checkCurrent(location.pathname),e(this,l).hasAttribute("data-prefetch")&&e(this,l).addEventListener("pointerenter",e(this,$))}get element(){return e(this,l)}checkCurrent(t){const s=e(this,C).normalizePath(t),i=e(this,C).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,Z)),e(this,l).removeEventListener("pointerenter",e(this,$)),e(this,l).classList.remove("current")}}C=new WeakMap,l=new WeakMap,z=new WeakMap,Z=new WeakMap,$=new WeakMap;var x,K,w,I,O,N;class Tt{constructor(t,s,i){o(this,x);o(this,K);o(this,w,{x:0,y:0});o(this,I);o(this,O,null);o(this,N,null);a(this,x,t),a(this,K,s),a(this,I,i.cloneNode(!0))}get pathname(){return e(this,K)}get scrollState(){return e(this,w)}get document(){return e(this,N)}cloneDocument(){a(this,N,(e(this,O)||e(this,I)).cloneNode(!0))}get title(){let t="";if(e(this,N).title)t=e(this,N).title;else{const s=e(this,N).querySelector("h1");t=(s==null?void 0:s.innerText)||(s==null?void 0:s.textContent)||e(this,K)}return t}clearScrollState(){e(this,w).x=0,e(this,w).y=0}clearDocumentState(){a(this,O,null)}saveScrollState(){e(this,I).documentElement.hasAttribute("data-no-scroll-restoration")?(e(this,w).x=0,e(this,w).y=0):(e(this,w).x=e(this,x).scrollElement.scrollLeft,e(this,w).y=e(this,x).scrollElement.scrollTop)}saveDocumentState(){e(this,I).documentElement.hasAttribute("data-no-page-restoration")?a(this,O,null):a(this,O,document.cloneNode(!0))}restoreScrollPosition(){e(this,x).scrollElement.scroll({top:e(this,w).y,left:e(this,w).x})}renewScrollPosition(){e(this,x).scrollElement.scroll({top:0,left:0,behavior:"instant"})}}x=new WeakMap,K=new WeakMap,w=new WeakMap,I=new WeakMap,O=new WeakMap,N=new WeakMap;var T,Y,f,nt,q,p,_,B,M,P,G,F,tt,c,rt,xt,dt,Nt,mt,ft,pt,Et,ot,J;const X=class X{constructor(t){o(this,c);o(this,T,null);o(this,Y,null);o(this,f,[]);o(this,nt,new DOMParser);o(this,q);o(this,p,null);o(this,_);o(this,B,[]);o(this,M,!1);o(this,P,null);o(this,G,new Map);o(this,F,null);o(this,tt,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,ot,t=>R(this,null,function*(){var s;(s=t.state)!=null&&s.path&&(t.preventDefault(),a(this,M,!0),yield this.navigate(t.state.path,{historyAction:"none"}),a(this,M,!1))}));o(this,J,()=>{const t=e(this,P).scrollTop,s=e(this,P).scrollLeft;document.documentElement.classList.toggle("top-scrolled",t>0),document.documentElement.classList.toggle("left-scrolled",s>0),U.dispatchEvent(document,"morphScroll",{detail:{left:s,top:t}})});if(Mt.isBrowser&&!X.instance){X.instance=this,a(this,T,{base:it.normalizeBase(t==null?void 0:t.base),waitForHeadToLoad:(t==null?void 0:t.waitForHeadToLoad)!==!1,cachePages:(t==null?void 0:t.cachePages)!==!1,trailingSlash:(t==null?void 0:t.trailingSlash)||!1,scrollSelector:(t==null?void 0:t.scrollSelector)||"body",morphInsideScrollContainer:(t==null?void 0:t.morphInsideScrollContainer)||!1}),a(this,Y,d(this,c,dt).call(this,document.body));const s=this.normalizePath(location.pathname+location.hash);a(this,p,s.pathname),e(this,G).set(e(this,p),new Tt(this,e(this,p),document)),document.documentElement.setAttribute("data-current-pathname",e(this,p)),document.documentElement.setAttribute("data-current-leaf",s.leaf),this.findLinks(),addEventListener("popstate",e(this,ot)),it.changeHistory({action:"replace",pathname:e(this,p),searchParameters:s.parameters||location.search,hash:s.hash}),a(this,F,new Ht),d(this,c,pt).call(this,document)}}get currentPathname(){return e(this,p)}get previousPathname(){return e(this,_)}get links(){return e(this,f)}get scrollElement(){return e(this,P)}get isPopstateNavigation(){return e(this,M)}normalizePath(t){return it.splitPath(t,{base:e(this,T).base,trailingSlash:e(this,T).trailingSlash})}prefetch(t,s){return R(this,null,function*(){const i=this.normalizePath(t);d(this,c,rt).call(this,i.pathname,{searchParameters:i.parameters,revalidate:s})})}navigate(S){return R(this,arguments,function*(t,{historyAction:s="push",centerScroll:i,offsetScroll:u,revalidate:v,keepSearchParameters:L,submorph:g}={}){var vt;if(e(this,B).length)return;const A=this.normalizePath(((vt=this.pathnameModifier)==null?void 0:vt.call(this,t))||t);let{pathname:m,hash:V,parameters:gt,leaf:qt}=A;if(e(this,q)===m||e(this,p)===m){e(this,M)||d(this,c,Et).call(this,V||0,{centerScroll:i,offsetScroll:u,behavior:"smooth"});return}a(this,q,m),e(this,f).forEach(W=>{W.checkCurrent(m)});try{let W=!0;if(this.preprocessor)try{yield new Promise((r,k)=>{var y;(y=this.preprocessor)==null||y.call(this,{pathname:m,resolve:r,reject:k,submorph:g})})}catch(r){r?console.error(r):console.log("Route change canceled"),W=!1}if(!W||e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}const at={pathname:m,submorph:g};U.dispatchEvent(document,"morphNavigation",{detail:at});const St=yield d(this,c,rt).call(this,e(this,p)),b=yield d(this,c,rt).call(this,m,{searchParameters:gt,revalidate:v});if(e(this,q)!==m){e(this,f).forEach(r=>{r.checkCurrent(e(this,p))});return}St.saveScrollState(),St.saveDocumentState(),e(this,M)||(b.clearScrollState(),b.clearDocumentState()),b.cloneDocument(),e(this,F).textContent=b.title,document.body.appendChild(e(this,F)),U.dispatchEvent(document,"morphStart",{detail:at});const yt=Array.from(document.head.children),wt=Array.from(b.document.head.children),Lt=d(this,c,Nt).call(this,yt,wt),Dt=d(this,c,mt).call(this,yt,Lt),et=d(this,c,mt).call(this,wt,Lt);et.forEach((r,k)=>{if(r.tagName==="SCRIPT"&&r.getAttribute("src")){const y=document.createElement("script");y.type="module",y.src=r.getAttribute("src"),et[k]=y}}),et.forEach(r=>{document.head.appendChild(r)});const lt=et.filter(r=>{if(r.hasAttribute("data-no-waiting"))return!1;if(d(this,c,ft).call(this,r))return!0});e(this,T).waitForHeadToLoad&<.length&&(yield new Promise(r=>R(this,null,function*(){let k=0;try{for(var y=kt(lt),Q,D,j;Q=!(D=yield y.next()).done;Q=!1){const st=D.value;st.onload=()=>{k++,k===lt.length&&r()}}}catch(D){j=[D]}finally{try{Q&&(D=y.return)&&(yield D.call(y))}finally{if(j)throw j[0]}}}))),yield Ct.wait(10);const bt=[];Dt.forEach(r=>{r.hasAttribute("data-permanent")||(d(this,c,ft).call(this,r)?bt.push(r):r.remove())});const Rt=d(this,c,dt).call(this,b.document.body);e(this,T).morphInsideScrollContainer||d(this,c,pt).call(this,b.document),document.documentElement.setAttribute("data-current-pathname",m),document.documentElement.setAttribute("data-current-leaf",qt),it.changeHistory({action:s,pathname:m,searchParameters:gt||(L?location.search:""),hash:V}),e(this,F).remove(),a(this,_,e(this,p)),a(this,p,m),e(this,Y).forEach((r,k)=>{const y=Rt[k],Q=getComputedStyle(r).getPropertyValue("--morph-duration");let D=[],j=[];g?g.forEach(h=>{const E=r.querySelector(h),H=y.querySelector(h);E&&H&&(j.push(E),D.push(H))}):(D.push(...y.childNodes),j.push(...r.childNodes)),j.forEach(h=>{h instanceof HTMLElement&&(this.destroyOldLinks(h),h.classList.add("old"))}),D.forEach(h=>{h instanceof HTMLElement&&(this.findNewLinks(h),h.classList.add("new"))}),g?D.forEach((h,E)=>{var H;(H=j[E].parentElement)==null||H.insertBefore(h,j[E])}):r.prepend(...D),It.requestIdleCallback(()=>{D.forEach(h=>{var E;h instanceof HTMLElement&&((E=h.parentElement)==null||E.style.setProperty("--new-content-height",h.offsetHeight+"px"),h.classList.add("in"))})});const st={morphElement:r,pathname:m};U.dispatchEvent(document,"morphNewChildrenAdded",{detail:st});const zt=new Promise(h=>{setTimeout(()=>{j.forEach(E=>E.remove()),D.forEach(E=>{var H;E instanceof HTMLElement&&((H=E.parentElement)==null||H.style.removeProperty("--new-content-height"),E.classList.remove("in","new"))}),U.dispatchEvent(document,"morphOldChildrenRemoved",{detail:st}),h()},(parseFloat(Q)||0)*1e3+10)});e(this,B).push(zt)}),V?(b.clearScrollState(),d(this,c,Et).call(this,V,{centerScroll:i,offsetScroll:u})):e(this,M)?b.restoreScrollPosition():b.renewScrollPosition(),yield Promise.all(e(this,B)),bt.forEach(r=>r.remove()),a(this,B,[]),e(this,Y).forEach(r=>{r.querySelectorAll("script").forEach(y=>{const Q=document.createElement("script");Q.type="module",Q.src=y.getAttribute("src"),y.replaceWith(Q)})}),U.dispatchEvent(document,"morphComplete",{detail:at}),window.dispatchEvent(new Event("resize"))}catch(W){console.error(W)}a(this,q,void 0)})}addLink(t){e(this,f).push(new ht(t,this))}addLinks(t){t.forEach(s=>{this.addLink(s)})}removeLink(t){a(this,f,e(this,f).filter(s=>s.element===t?(s.destroy(),!1):!0))}destroyOldLinks(t){a(this,f,e(this,f).filter(s=>t.contains(s.element)?(s.destroy(),!1):!0))}findNewLinks(t){const s=[...t.querySelectorAll("a")].filter(e(this,tt));e(this,f).push(...s.map(i=>new ht(i,this)))}findLinks(){const t=[...document.documentElement.querySelectorAll("a")].filter(e(this,tt));e(this,f).forEach(s=>s.destroy()),a(this,f,t.map(s=>new ht(s,this)))}};T=new WeakMap,Y=new WeakMap,f=new WeakMap,nt=new WeakMap,q=new WeakMap,p=new WeakMap,_=new WeakMap,B=new WeakMap,M=new WeakMap,P=new WeakMap,G=new WeakMap,F=new WeakMap,tt=new WeakMap,c=new WeakSet,rt=function(t,s){return R(this,null,function*(){let i=e(this,G).get(t);return(!i||s!=null&&s.revalidate)&&(i=yield d(this,c,xt).call(this,t,s==null?void 0:s.searchParameters)),i})},xt=function(t,s){return R(this,null,function*(){const u=yield(yield fetch(`${t}${s?"?"+s:""}`)).text(),v=e(this,nt).parseFromString(u,"text/html"),L=new Tt(this,t,v);return e(this,G).set(t,L),L})},dt=function(t){const s=[...t.querySelectorAll("[data-morph]")];return s.length?s:[t]},Nt=function(t,s){return t.filter(i=>s.find(u=>u.outerHTML===i.outerHTML))},mt=function(t,s){return t.filter(i=>!s.find(u=>u.outerHTML===i.outerHTML))},ft=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,P))==null||s.removeEventListener("scroll",e(this,J)),a(this,P,t.querySelector(e(this,T).scrollSelector)||t.documentElement),(i=e(this,P))==null||i.addEventListener("scroll",e(this,J)),e(this,J).call(this)},Et=function(t,s){const i=typeof t=="string"?document.getElementById(t):t;(typeof i=="number"||i)&&Ct.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})},ot=new WeakMap,J=new WeakMap,X.instance=null;let ut=X;exports.Morph=ut;
|
package/lib/morph/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Morph, type
|
|
1
|
+
export { Morph, type MorphPreprocessor, type MorphPreprocessorEntry, type MorphNavigationEntry, type MorphOptions, type MorphChildrenActionEntry, type MorphNavigateOptions, type MorphEvents, } from './Morph';
|
package/lib/morph/index.js
CHANGED
|
@@ -4,22 +4,22 @@ var Lt = (n, t) => (t = Symbol[n]) ? t : Symbol.for("Symbol." + n), bt = (n) =>
|
|
|
4
4
|
var lt = (n, t, s) => t.has(n) || bt("Cannot " + s);
|
|
5
5
|
var e = (n, t, s) => (lt(n, t, "read from private field"), s ? s.call(n) : t.get(n)), o = (n, t, s) => t.has(n) ? bt("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(n) : t.set(n, s), a = (n, t, s, i) => (lt(n, t, "write to private field"), i ? i.call(n, s) : t.set(n, s), s), d = (n, t, s) => (lt(n, t, "access private method"), s);
|
|
6
6
|
var q = (n, t, s) => new Promise((i, u) => {
|
|
7
|
-
var
|
|
7
|
+
var S = (v) => {
|
|
8
8
|
try {
|
|
9
|
-
|
|
9
|
+
g(s.next(v));
|
|
10
10
|
} catch (A) {
|
|
11
11
|
u(A);
|
|
12
12
|
}
|
|
13
|
-
},
|
|
13
|
+
}, L = (v) => {
|
|
14
14
|
try {
|
|
15
|
-
|
|
15
|
+
g(s.throw(v));
|
|
16
16
|
} catch (A) {
|
|
17
17
|
u(A);
|
|
18
18
|
}
|
|
19
|
-
},
|
|
20
|
-
|
|
19
|
+
}, g = (v) => v.done ? i(v.value) : Promise.resolve(v.value).then(S, L);
|
|
20
|
+
g((s = s.apply(n, t)).next());
|
|
21
21
|
});
|
|
22
|
-
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (
|
|
22
|
+
var Pt = (n, t, s) => (t = n[Lt("asyncIterator")]) ? t.call(n) : (n = n[Lt("iterator")](), t = {}, s = (i, u) => (u = n[i]) && (t[i] = (S) => new Promise((L, g, v) => (S = u.call(n, S), v = S.done, Promise.resolve(S.value).then((A) => L({ value: A, done: v }), g)))), s("next"), s("return"), t);
|
|
23
23
|
import { i as Tt } from "../index-euf5anj6.js";
|
|
24
24
|
import { d as $ } from "../events-CsVF98U6.js";
|
|
25
25
|
import { r as zt } from "../polyfills-DJrTJQky.js";
|
|
@@ -51,14 +51,14 @@ class ht {
|
|
|
51
51
|
else {
|
|
52
52
|
const u = e(this, l).getAttribute(
|
|
53
53
|
"data-history-action"
|
|
54
|
-
) || "push",
|
|
54
|
+
) || "push", S = e(this, l).hasAttribute("data-center-scroll"), L = getComputedStyle(e(this, l)).getPropertyValue("--offset-scroll").trim(), g = L ? Vt.parse(L) : void 0, v = e(this, l).hasAttribute("data-revalidate"), A = e(this, l).hasAttribute(
|
|
55
55
|
"data-keep-search-parameters"
|
|
56
56
|
), m = (i = e(this, l).getAttribute("data-submorph")) == null ? void 0 : i.split(",").map((V) => V.trim());
|
|
57
57
|
e(this, C).navigate(e(this, z), {
|
|
58
58
|
historyAction: u,
|
|
59
|
-
centerScroll:
|
|
60
|
-
offsetScroll:
|
|
61
|
-
revalidate:
|
|
59
|
+
centerScroll: S,
|
|
60
|
+
offsetScroll: g,
|
|
61
|
+
revalidate: v,
|
|
62
62
|
keepSearchParameters: A,
|
|
63
63
|
submorph: m
|
|
64
64
|
});
|
|
@@ -82,12 +82,12 @@ class ht {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
C = new WeakMap(), l = new WeakMap(), z = new WeakMap(), Z = new WeakMap(), j = new WeakMap();
|
|
85
|
-
var N, K,
|
|
85
|
+
var N, K, w, I, F, x;
|
|
86
86
|
class kt {
|
|
87
87
|
constructor(t, s, i) {
|
|
88
88
|
o(this, N);
|
|
89
89
|
o(this, K);
|
|
90
|
-
o(this,
|
|
90
|
+
o(this, w, { x: 0, y: 0 });
|
|
91
91
|
o(this, I);
|
|
92
92
|
o(this, F, null);
|
|
93
93
|
o(this, x, null);
|
|
@@ -97,7 +97,7 @@ class kt {
|
|
|
97
97
|
return e(this, K);
|
|
98
98
|
}
|
|
99
99
|
get scrollState() {
|
|
100
|
-
return e(this,
|
|
100
|
+
return e(this, w);
|
|
101
101
|
}
|
|
102
102
|
get document() {
|
|
103
103
|
return e(this, x);
|
|
@@ -116,7 +116,7 @@ class kt {
|
|
|
116
116
|
return t;
|
|
117
117
|
}
|
|
118
118
|
clearScrollState() {
|
|
119
|
-
e(this,
|
|
119
|
+
e(this, w).x = 0, e(this, w).y = 0;
|
|
120
120
|
}
|
|
121
121
|
clearDocumentState() {
|
|
122
122
|
a(this, F, null);
|
|
@@ -124,7 +124,7 @@ class kt {
|
|
|
124
124
|
saveScrollState() {
|
|
125
125
|
e(this, I).documentElement.hasAttribute(
|
|
126
126
|
"data-no-scroll-restoration"
|
|
127
|
-
) ? (e(this,
|
|
127
|
+
) ? (e(this, w).x = 0, e(this, w).y = 0) : (e(this, w).x = e(this, N).scrollElement.scrollLeft, e(this, w).y = e(this, N).scrollElement.scrollTop);
|
|
128
128
|
}
|
|
129
129
|
saveDocumentState() {
|
|
130
130
|
e(this, I).documentElement.hasAttribute(
|
|
@@ -133,8 +133,8 @@ class kt {
|
|
|
133
133
|
}
|
|
134
134
|
restoreScrollPosition() {
|
|
135
135
|
e(this, N).scrollElement.scroll({
|
|
136
|
-
top: e(this,
|
|
137
|
-
left: e(this,
|
|
136
|
+
top: e(this, w).y,
|
|
137
|
+
left: e(this, w).x
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
140
|
renewScrollPosition() {
|
|
@@ -145,7 +145,7 @@ class kt {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
|
-
N = new WeakMap(), K = new WeakMap(),
|
|
148
|
+
N = new WeakMap(), K = new WeakMap(), w = new WeakMap(), I = new WeakMap(), F = new WeakMap(), x = new WeakMap();
|
|
149
149
|
var T, Y, f, rt, D, p, _, O, M, P, G, B, tt, h, it, Ht, ct, Nt, ut, dt, mt, ft, nt, J;
|
|
150
150
|
const X = class X {
|
|
151
151
|
constructor(t) {
|
|
@@ -238,14 +238,14 @@ const X = class X {
|
|
|
238
238
|
});
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
|
-
navigate(
|
|
241
|
+
navigate(v) {
|
|
242
242
|
return q(this, arguments, function* (t, {
|
|
243
243
|
historyAction: s = "push",
|
|
244
244
|
centerScroll: i,
|
|
245
245
|
offsetScroll: u,
|
|
246
|
-
revalidate:
|
|
247
|
-
keepSearchParameters:
|
|
248
|
-
submorph:
|
|
246
|
+
revalidate: S,
|
|
247
|
+
keepSearchParameters: L,
|
|
248
|
+
submorph: g
|
|
249
249
|
} = {}) {
|
|
250
250
|
var Et;
|
|
251
251
|
if (e(this, O).length)
|
|
@@ -268,11 +268,12 @@ const X = class X {
|
|
|
268
268
|
if (this.preprocessor)
|
|
269
269
|
try {
|
|
270
270
|
yield new Promise((r, k) => {
|
|
271
|
-
var
|
|
272
|
-
(
|
|
271
|
+
var y;
|
|
272
|
+
(y = this.preprocessor) == null || y.call(this, {
|
|
273
273
|
pathname: m,
|
|
274
274
|
resolve: r,
|
|
275
|
-
reject: k
|
|
275
|
+
reject: k,
|
|
276
|
+
submorph: g
|
|
276
277
|
});
|
|
277
278
|
});
|
|
278
279
|
} catch (r) {
|
|
@@ -285,14 +286,15 @@ const X = class X {
|
|
|
285
286
|
return;
|
|
286
287
|
}
|
|
287
288
|
const ot = {
|
|
288
|
-
pathname: m
|
|
289
|
+
pathname: m,
|
|
290
|
+
submorph: g
|
|
289
291
|
};
|
|
290
292
|
$(document, "morphNavigation", {
|
|
291
293
|
detail: ot
|
|
292
294
|
});
|
|
293
295
|
const gt = yield d(this, h, it).call(this, e(this, p)), b = yield d(this, h, it).call(this, m, {
|
|
294
296
|
searchParameters: pt,
|
|
295
|
-
revalidate:
|
|
297
|
+
revalidate: S
|
|
296
298
|
});
|
|
297
299
|
if (e(this, D) !== m) {
|
|
298
300
|
e(this, f).forEach((r) => {
|
|
@@ -306,8 +308,8 @@ const X = class X {
|
|
|
306
308
|
const St = Array.from(document.head.children), vt = Array.from(b.document.head.children), yt = d(this, h, Nt).call(this, St, vt), Dt = d(this, h, ut).call(this, St, yt), et = d(this, h, ut).call(this, vt, yt);
|
|
307
309
|
et.forEach((r, k) => {
|
|
308
310
|
if (r.tagName === "SCRIPT" && r.getAttribute("src")) {
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
+
const y = document.createElement("script");
|
|
312
|
+
y.type = "module", y.src = r.getAttribute("src"), et[k] = y;
|
|
311
313
|
}
|
|
312
314
|
}), et.forEach((r) => {
|
|
313
315
|
document.head.appendChild(r);
|
|
@@ -321,7 +323,7 @@ const X = class X {
|
|
|
321
323
|
e(this, T).waitForHeadToLoad && at.length && (yield new Promise((r) => q(this, null, function* () {
|
|
322
324
|
let k = 0;
|
|
323
325
|
try {
|
|
324
|
-
for (var
|
|
326
|
+
for (var y = Pt(at), Q, R, U; Q = !(R = yield y.next()).done; Q = !1) {
|
|
325
327
|
const st = R.value;
|
|
326
328
|
st.onload = () => {
|
|
327
329
|
k++, k === at.length && r();
|
|
@@ -331,7 +333,7 @@ const X = class X {
|
|
|
331
333
|
U = [R];
|
|
332
334
|
} finally {
|
|
333
335
|
try {
|
|
334
|
-
Q && (R =
|
|
336
|
+
Q && (R = y.return) && (yield R.call(y));
|
|
335
337
|
} finally {
|
|
336
338
|
if (U)
|
|
337
339
|
throw U[0];
|
|
@@ -346,19 +348,19 @@ const X = class X {
|
|
|
346
348
|
e(this, T).morphInsideScrollContainer || d(this, h, mt).call(this, b.document), document.documentElement.setAttribute("data-current-pathname", m), document.documentElement.setAttribute("data-current-leaf", xt), At({
|
|
347
349
|
action: s,
|
|
348
350
|
pathname: m,
|
|
349
|
-
searchParameters: pt || (
|
|
351
|
+
searchParameters: pt || (L ? location.search : ""),
|
|
350
352
|
hash: V
|
|
351
353
|
}), e(this, B).remove(), a(this, _, e(this, p)), a(this, p, m), e(this, Y).forEach((r, k) => {
|
|
352
|
-
const
|
|
354
|
+
const y = Rt[k], Q = getComputedStyle(r).getPropertyValue("--morph-duration");
|
|
353
355
|
let R = [], U = [];
|
|
354
|
-
|
|
355
|
-
const E = r.querySelector(c), H =
|
|
356
|
+
g ? g.forEach((c) => {
|
|
357
|
+
const E = r.querySelector(c), H = y.querySelector(c);
|
|
356
358
|
E && H && (U.push(E), R.push(H));
|
|
357
|
-
}) : (R.push(...
|
|
359
|
+
}) : (R.push(...y.childNodes), U.push(...r.childNodes)), U.forEach((c) => {
|
|
358
360
|
c instanceof HTMLElement && (this.destroyOldLinks(c), c.classList.add("old"));
|
|
359
361
|
}), R.forEach((c) => {
|
|
360
362
|
c instanceof HTMLElement && (this.findNewLinks(c), c.classList.add("new"));
|
|
361
|
-
}),
|
|
363
|
+
}), g ? R.forEach((c, E) => {
|
|
362
364
|
var H;
|
|
363
365
|
(H = U[E].parentElement) == null || H.insertBefore(
|
|
364
366
|
c,
|
|
@@ -394,9 +396,9 @@ const X = class X {
|
|
|
394
396
|
});
|
|
395
397
|
e(this, O).push(qt);
|
|
396
398
|
}), V ? (b.clearScrollState(), d(this, h, ft).call(this, V, { centerScroll: i, offsetScroll: u })) : e(this, M) ? b.restoreScrollPosition() : b.renewScrollPosition(), yield Promise.all(e(this, O)), wt.forEach((r) => r.remove()), a(this, O, []), e(this, Y).forEach((r) => {
|
|
397
|
-
r.querySelectorAll("script").forEach((
|
|
399
|
+
r.querySelectorAll("script").forEach((y) => {
|
|
398
400
|
const Q = document.createElement("script");
|
|
399
|
-
Q.type = "module", Q.src =
|
|
401
|
+
Q.type = "module", Q.src = y.getAttribute("src"), y.replaceWith(Q);
|
|
400
402
|
});
|
|
401
403
|
}), $(document, "morphComplete", {
|
|
402
404
|
detail: ot
|
|
@@ -445,8 +447,8 @@ T = new WeakMap(), Y = new WeakMap(), f = new WeakMap(), rt = new WeakMap(), D =
|
|
|
445
447
|
return q(this, null, function* () {
|
|
446
448
|
const u = yield (yield fetch(
|
|
447
449
|
`${t}${s ? "?" + s : ""}`
|
|
448
|
-
)).text(),
|
|
449
|
-
return e(this, G).set(t,
|
|
450
|
+
)).text(), S = e(this, rt).parseFromString(u, "text/html"), L = new kt(this, t, S);
|
|
451
|
+
return e(this, G).set(t, L), L;
|
|
450
452
|
});
|
|
451
453
|
}, ct = function(t) {
|
|
452
454
|
const s = [...t.querySelectorAll("[data-morph]")];
|