aptechka 0.39.0 → 0.39.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/morph/index.cjs +1 -1
- package/lib/morph/index.js +21 -19
- package/package.json +1 -1
package/lib/morph/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var it=(s,t)=>(t=Symbol[s])?t:Symbol.for("Symbol."+s),st=s=>{throw TypeError(s)};var G=(s,t,i)=>t.has(s)||st("Cannot "+i);var e=(s,t,i)=>(G(s,t,"read from private field"),i?i.call(s):t.get(s)),o=(s,t,i)=>t.has(s)?st("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,i),u=(s,t,i,r)=>(G(s,t,"write to private field"),r?r.call(s,i):t.set(s,i),i),m=(s,t,i)=>(G(s,t,"access private method"),i);var T=(s,t,i)=>new Promise((r,n)=>{var d=l=>{try{p(i.next(l))}catch(b){n(b)}},E=l=>{try{p(i.throw(l))}catch(b){n(b)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,E);p((i=i.apply(s,t)).next())});var nt=(s,t,i)=>(t=s[it("asyncIterator")])?t.call(s):(s=s[it("iterator")](),t={},i=(r,n)=>(n=s[r])&&(t[r]=d=>new Promise((E,p,l)=>(d=n.call(s,d),l=d.done,Promise.resolve(d.value).then(b=>E({value:b,done:l}),p)))),i("next"),i("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("../notifier/index.cjs"),ut=require("../browser-CpzFX2xg.cjs"),O=require("../url-DELd-VFC.cjs"),at=require("../loading/index.cjs");var y,h,f,k,
|
|
1
|
+
"use strict";var it=(s,t)=>(t=Symbol[s])?t:Symbol.for("Symbol."+s),st=s=>{throw TypeError(s)};var G=(s,t,i)=>t.has(s)||st("Cannot "+i);var e=(s,t,i)=>(G(s,t,"read from private field"),i?i.call(s):t.get(s)),o=(s,t,i)=>t.has(s)?st("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(s):t.set(s,i),u=(s,t,i,r)=>(G(s,t,"write to private field"),r?r.call(s,i):t.set(s,i),i),m=(s,t,i)=>(G(s,t,"access private method"),i);var T=(s,t,i)=>new Promise((r,n)=>{var d=l=>{try{p(i.next(l))}catch(b){n(b)}},E=l=>{try{p(i.throw(l))}catch(b){n(b)}},p=l=>l.done?r(l.value):Promise.resolve(l.value).then(d,E);p((i=i.apply(s,t)).next())});var nt=(s,t,i)=>(t=s[it("asyncIterator")])?t.call(s):(s=s[it("iterator")](),t={},i=(r,n)=>(n=s[r])&&(t[r]=d=>new Promise((E,p,l)=>(d=n.call(s,d),l=d.done,Promise.resolve(d.value).then(b=>E({value:b,done:l}),p)))),i("next"),i("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("../notifier/index.cjs"),ut=require("../browser-CpzFX2xg.cjs"),O=require("../url-DELd-VFC.cjs"),at=require("../loading/index.cjs");var y,h,f,k,P,C,M;class dt{constructor(t,i){o(this,y);o(this,h);o(this,f);o(this,k);o(this,P);o(this,C,t=>{t.preventDefault(),e(this,y).links.forEach(i=>{var r;e(this,f)===e(i,f)||(r=e(i,P))!=null&&r.includes(e(this,f))?e(i,h).classList.add("clicked"):e(i,h).classList.remove("clicked")}),e(this,y).navigate(e(this,f),e(this,k))});o(this,M,()=>{e(this,y).prefetch(e(this,f)),e(this,h).removeEventListener("pointerenter",e(this,M))});var d,E;u(this,y,i),u(this,h,t),u(this,f,e(this,h).getAttribute("href")||"/"),u(this,k,e(this,h).getAttribute("data-history-action")||"push"),e(this,h).addEventListener("click",e(this,C));const r=i.normalizePath(e(this,f)),n=i.normalizePath(location.pathname);u(this,P,(d=e(this,h).getAttribute("data-match-paths"))==null?void 0:d.split(",").map(p=>i.normalizePath(p.trim()).pathname)),e(this,h).hasAttribute("data-include")?n.pathname.includes(r.pathname)&&e(this,h).classList.add("current"):r.pathname===n.pathname||(E=e(this,P))!=null&&E.includes(n.pathname)?(e(this,h).classList.add("current"),e(this,h).classList.add("clicked")):e(this,h).classList.remove("clicked"),e(this,h).hasAttribute("data-prefetch")&&e(this,h).addEventListener("pointerenter",e(this,M))}destroy(){e(this,h).removeEventListener("click",e(this,C)),e(this,h).removeEventListener("pointerenter",e(this,M)),e(this,h).classList.remove("current")}}y=new WeakMap,h=new WeakMap,f=new WeakMap,k=new WeakMap,P=new WeakMap,C=new WeakMap,M=new WeakMap;var S,z,q,x,H,B,A,w,g,_,D,c,J,Q,U,ot,V,W;class mt{constructor(t){o(this,c);o(this,S,null);o(this,z,null);o(this,q,null);o(this,x,null);o(this,H,[]);o(this,B,new DOMParser);o(this,A,new Map);o(this,w);o(this,g,null);o(this,_,new rt.Notifier);o(this,D,new rt.Notifier);o(this,W,t=>{t.state&&this.navigate(t.state,"none")});if(ut.isBrowser){u(this,S,O.normalizeBase(t==null?void 0:t.base)),u(this,z,(t==null?void 0:t.waitForHeadToLoad)!==!1),u(this,q,(t==null?void 0:t.cachePages)!==!1),u(this,x,m(this,c,U).call(this,document.body));const i=this.normalizePath(location.pathname);u(this,g,i.pathname),document.documentElement.setAttribute("data-current-pathname",e(this,g)),document.documentElement.setAttribute("data-current-leaf",i.leaf),m(this,c,Q).call(this),addEventListener("popstate",e(this,W)),O.changeHistory("replace",e(this,g),i.parameters,i.hash)}}get currentPathname(){return e(this,g)}get links(){return e(this,H)}normalizePath(t){return O.splitPath(t,e(this,S))}beforeNavigationEvent(t){return e(this,_).subscribe(t)}afterNavigationEvent(t){return e(this,D).subscribe(t)}prefetch(t){return T(this,null,function*(){const i=this.normalizePath(t);return m(this,c,J).call(this,i.pathname)})}navigate(t,i="push"){return T(this,null,function*(){var b;const r=this.normalizePath(t);let{pathname:n,hash:d,parameters:E,leaf:p}=r;if(e(this,w)===n||e(this,g)===n)return;u(this,w,n);const l=e(this,A).has(n);try{at.loading.add("__morph");let R=!0;if(e(this,_).notify({pathname:n,isCached:l}),this.preprocessor)try{yield new Promise((a,v)=>{var L;(L=this.preprocessor)==null||L.call(this,{pathname:n,resolve:a,reject:v,isCached:l})})}catch(a){a?console.error(a):console.log("Route change canceled"),R=!1}if(!R||e(this,w)!==n)return;const X=e(this,A).get(n)||(yield m(this,c,J).call(this,n));if(e(this,w)!==n)return;const Z=Array.from(document.head.children),$=Array.from(X.head.cloneNode(!0).children),tt=m(this,c,ot).call(this,Z,$),ht=m(this,c,V).call(this,Z,tt),F=m(this,c,V).call(this,$,tt);F.forEach((a,v)=>{if(a.tagName==="SCRIPT"&&a.getAttribute("src")){const L=document.createElement("script");L.type="module",L.src=a.getAttribute("src"),F[v]=L}}),F.forEach(a=>{document.head.appendChild(a)});const j=F.filter(a=>(a.tagName==="STYLE"||a.tagName==="SCRIPT"||a.tagName==="LINK")&&a.getAttribute("rel")!=="canonical");e(this,z)&&j.length&&(yield new Promise(a=>T(this,null,function*(){let v=0;try{for(var L=nt(j),lt,K,I;lt=!(K=yield L.next()).done;lt=!1){const N=K.value;N.onload=()=>{v++,v===j.length&&a()}}}catch(K){I=[K]}finally{try{lt&&(K=L.return)&&(yield K.call(L))}finally{if(I)throw I[0]}}}))),ht.forEach(a=>{a.hasAttribute("data-permanent")||a.remove()}),u(this,g,n),O.changeHistory(i,n,E,d);const ct=m(this,c,U).call(this,X.body.cloneNode(!0));e(this,x).forEach((a,v)=>{const L=ct[v];let lt=[...a.childNodes],K=[...L.childNodes];lt.forEach(I=>{if(I instanceof HTMLElement){const N=I.getAttribute("data-remain");let et;K=K.filter(Y=>Y instanceof HTMLElement&&N&&Y.getAttribute("data-remain")===N?(et=Y,!1):!0),N&&et||I.remove()}else I.remove()}),a.append(...K)}),m(this,c,Q).call(this),document.documentElement.setAttribute("data-current-pathname",n),document.documentElement.setAttribute("data-current-leaf",p),(b=this.postprocessor)==null||b.call(this,{pathname:n,isCached:l}),e(this,D).notify({pathname:n,isCached:l}),at.loading.complete("__morph")}catch(R){console.error(R)}u(this,w,void 0)})}}S=new WeakMap,z=new WeakMap,q=new WeakMap,x=new WeakMap,H=new WeakMap,B=new WeakMap,A=new WeakMap,w=new WeakMap,g=new WeakMap,_=new WeakMap,D=new WeakMap,c=new WeakSet,J=function(t){return T(this,null,function*(){const i=e(this,A).get(t);if(i)return i;const n=yield(yield fetch(t)).text(),d=e(this,B).parseFromString(n,"text/html");return e(this,q)&&e(this,A).set(t,d),d})},Q=function(){const t=[...document.documentElement.querySelectorAll("a")].filter(i=>{var r;return((r=i.getAttribute("href"))==null?void 0:r.startsWith("/"))&&!i.hasAttribute("download")&&!i.hasAttribute("data-morph-skip")});e(this,H).forEach(i=>i.destroy()),u(this,H,t.map(i=>new dt(i,this)))},U=function(t){return[...t.querySelectorAll("[data-morph]")]},ot=function(t,i){return t.filter(r=>i.find(n=>n.outerHTML===r.outerHTML))},V=function(t,i){return t.filter(r=>!i.find(n=>n.outerHTML===r.outerHTML))},W=new WeakMap;exports.Morph=mt;
|
package/lib/morph/index.js
CHANGED
|
@@ -54,7 +54,7 @@ class ft {
|
|
|
54
54
|
}
|
|
55
55
|
A = new WeakMap(), h = new WeakMap(), f = new WeakMap(), k = new WeakMap(), y = new WeakMap(), C = new WeakMap(), H = new WeakMap();
|
|
56
56
|
var z, S, x, D, M, B, P, w, g, R, _, c, G, J, Q, ot, U, O;
|
|
57
|
-
class
|
|
57
|
+
class vt {
|
|
58
58
|
constructor(t) {
|
|
59
59
|
o(this, c);
|
|
60
60
|
o(this, z, null);
|
|
@@ -126,9 +126,9 @@ class bt {
|
|
|
126
126
|
isCached: l
|
|
127
127
|
}), this.preprocessor)
|
|
128
128
|
try {
|
|
129
|
-
yield new Promise((a,
|
|
130
|
-
var
|
|
131
|
-
(
|
|
129
|
+
yield new Promise((a, b) => {
|
|
130
|
+
var v;
|
|
131
|
+
(v = this.preprocessor) == null || v.call(this, { pathname: n, resolve: a, reject: b, isCached: l });
|
|
132
132
|
});
|
|
133
133
|
} catch (a) {
|
|
134
134
|
a ? console.error(a) : console.log("Route change canceled"), F = !1;
|
|
@@ -141,10 +141,10 @@ class bt {
|
|
|
141
141
|
const X = Array.from(document.head.children), Z = Array.from(
|
|
142
142
|
V.head.cloneNode(!0).children
|
|
143
143
|
), $ = m(this, c, ot).call(this, X, Z), ht = m(this, c, U).call(this, X, $), I = m(this, c, U).call(this, Z, $);
|
|
144
|
-
I.forEach((a,
|
|
144
|
+
I.forEach((a, b) => {
|
|
145
145
|
if (a.tagName === "SCRIPT" && a.getAttribute("src")) {
|
|
146
|
-
const
|
|
147
|
-
|
|
146
|
+
const v = document.createElement("script");
|
|
147
|
+
v.type = "module", v.src = a.getAttribute("src"), I[b] = v;
|
|
148
148
|
}
|
|
149
149
|
}), I.forEach((a) => {
|
|
150
150
|
document.head.appendChild(a);
|
|
@@ -153,19 +153,19 @@ class bt {
|
|
|
153
153
|
(a) => (a.tagName === "STYLE" || a.tagName === "SCRIPT" || a.tagName === "LINK") && a.getAttribute("rel") !== "canonical"
|
|
154
154
|
);
|
|
155
155
|
e(this, S) && W.length && (yield new Promise((a) => T(this, null, function* () {
|
|
156
|
-
let
|
|
156
|
+
let b = 0;
|
|
157
157
|
try {
|
|
158
|
-
for (var
|
|
158
|
+
for (var v = st(W), lt, K, q; lt = !(K = yield v.next()).done; lt = !1) {
|
|
159
159
|
const N = K.value;
|
|
160
160
|
N.onload = () => {
|
|
161
|
-
|
|
161
|
+
b++, b === W.length && a();
|
|
162
162
|
};
|
|
163
163
|
}
|
|
164
164
|
} catch (K) {
|
|
165
165
|
q = [K];
|
|
166
166
|
} finally {
|
|
167
167
|
try {
|
|
168
|
-
lt && (K =
|
|
168
|
+
lt && (K = v.return) && (yield K.call(v));
|
|
169
169
|
} finally {
|
|
170
170
|
if (q)
|
|
171
171
|
throw q[0];
|
|
@@ -175,9 +175,9 @@ class bt {
|
|
|
175
175
|
a.hasAttribute("data-permanent") || a.remove();
|
|
176
176
|
}), u(this, g, n), rt(i, n, E, d);
|
|
177
177
|
const ct = m(this, c, Q).call(this, V.body.cloneNode(!0));
|
|
178
|
-
e(this, D).forEach((a,
|
|
179
|
-
const
|
|
180
|
-
let lt = [...a.childNodes], K = [...
|
|
178
|
+
e(this, D).forEach((a, b) => {
|
|
179
|
+
const v = ct[b];
|
|
180
|
+
let lt = [...a.childNodes], K = [...v.childNodes];
|
|
181
181
|
lt.forEach((q) => {
|
|
182
182
|
if (q instanceof HTMLElement) {
|
|
183
183
|
const N = q.getAttribute("data-remain");
|
|
@@ -207,10 +207,12 @@ z = new WeakMap(), S = new WeakMap(), x = new WeakMap(), D = new WeakMap(), M =
|
|
|
207
207
|
}, J = function() {
|
|
208
208
|
const t = [
|
|
209
209
|
...document.documentElement.querySelectorAll("a")
|
|
210
|
-
].filter(
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
210
|
+
].filter(
|
|
211
|
+
(i) => {
|
|
212
|
+
var r;
|
|
213
|
+
return ((r = i.getAttribute("href")) == null ? void 0 : r.startsWith("/")) && !i.hasAttribute("download") && !i.hasAttribute("data-morph-skip");
|
|
214
|
+
}
|
|
215
|
+
);
|
|
214
216
|
e(this, M).forEach((i) => i.destroy()), u(this, M, t.map((i) => new ft(i, this)));
|
|
215
217
|
}, Q = function(t) {
|
|
216
218
|
return [...t.querySelectorAll("[data-morph]")];
|
|
@@ -228,5 +230,5 @@ z = new WeakMap(), S = new WeakMap(), x = new WeakMap(), D = new WeakMap(), M =
|
|
|
228
230
|
);
|
|
229
231
|
}, O = new WeakMap();
|
|
230
232
|
export {
|
|
231
|
-
|
|
233
|
+
vt as Morph
|
|
232
234
|
};
|