aptechka 0.82.4 → 0.82.5
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/router/Route.d.ts +9 -0
- package/lib/router/index.cjs +1 -1
- package/lib/router/index.js +152 -137
- package/package.json +1 -1
package/lib/router/Route.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export type HeadNode = HTMLStyleElement | HTMLScriptElement | HTMLLinkElement;
|
|
|
6
6
|
export interface RouteParameters {
|
|
7
7
|
urlPatternResult: URLPatternResult;
|
|
8
8
|
}
|
|
9
|
+
export interface RouteEvents {
|
|
10
|
+
__hmrInstanceReplace: CustomEvent<{
|
|
11
|
+
element: HTMLElement;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
9
14
|
export declare class Route {
|
|
10
15
|
#private;
|
|
11
16
|
constructor(pattern: string, module: RouteModule);
|
|
@@ -17,3 +22,7 @@ export declare class Route {
|
|
|
17
22
|
render(container: Element | ShadowRoot, url: URL): Promise<void>;
|
|
18
23
|
close(): void;
|
|
19
24
|
}
|
|
25
|
+
declare global {
|
|
26
|
+
interface HTMLElementEventMap extends RouteEvents {
|
|
27
|
+
}
|
|
28
|
+
}
|
package/lib/router/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var ue=Object.defineProperty,ce=Object.defineProperties;var de=Object.getOwnPropertyDescriptors;var K=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,fe=Object.prototype.propertyIsEnumerable;var Y=i=>{throw TypeError(i)};var W=(i,e,s)=>e in i?ue(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,$=(i,e)=>{for(var s in e||(e={}))me.call(e,s)&&W(i,s,e[s]);if(K)for(var s of K(e))fe.call(e,s)&&W(i,s,e[s]);return i},G=(i,e)=>ce(i,de(e));var U=(i,e,s)=>e.has(i)||Y("Cannot "+s);var t=(i,e,s)=>(U(i,e,"read from private field"),s?s.call(i):e.get(i)),n=(i,e,s)=>e.has(i)?Y("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,s),h=(i,e,s,r)=>(U(i,e,"write to private field"),r?r.call(i,s):e.set(i,s),s),d=(i,e,s)=>(U(i,e,"access private method"),s);var J=(i,e,s,r)=>({set _(a){h(i,e,a,s)},get _(){return t(i,e,r)}});var R=(i,e,s)=>new Promise((r,a)=>{var o=f=>{try{g(s.next(f))}catch(N){a(N)}},C=f=>{try{g(s.throw(f))}catch(N){a(N)}},g=f=>f.done?r(f.value):Promise.resolve(f.value).then(o,C);g((s=s.apply(i,e)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const pe=require("../history/index.cjs"),ge=require("../LocalLinks-Bua7BGRF.cjs"),Re=require("../PageAnnouncerElement-C4k2kDJ5.cjs"),we=require("../PageScroll-C7QBpx0G.cjs");require("construct-style-sheets-polyfill");require("../index-CKTweR3M.cjs");const Q=require("../url-CPgw9bd5.cjs"),ve=require("urlpattern-polyfill"),Pe=require("../render-BWjKu0M_.cjs"),be=require("../object-baN9pgbU.cjs");var S,H,q,p,u,T,M,v,P,b,l,X,Z,ee,te,se,ie,re,ae,B,y;class ye{constructor(e,s){n(this,l);n(this,S);n(this,H);n(this,q);n(this,p,null);n(this,u,null);n(this,T,!1);n(this,M,null);n(this,v);n(this,P,[]);n(this,b,[]);n(this,y,e=>{t(this,u).removeEventListener("__hmrInstanceReplace",t(this,y)),h(this,u,e.detail.element),t(this,u).addEventListener("__hmrInstanceReplace",t(this,y))});h(this,S,e),h(this,H,s),h(this,q,new URLPattern({pathname:t(this,S)})),h(this,v,new MutationObserver(d(this,l,re).bind(this)))}get pattern(){return t(this,S)}get isActive(){return t(this,T)}get element(){return t(this,u)}get nest(){return t(this,M)}testPathname(e){return t(this,q).test({pathname:e})}render(e,s){return R(this,null,function*(){t(this,v).observe(document.head,{childList:!0,subtree:!0}),t(this,p)?d(this,l,Z).call(this):yield d(this,l,X).call(this),yield d(this,l,ae).call(this),t(this,p)&&(yield d(this,l,ee).call(this,e,s)),t(this,v).disconnect()})}close(){d(this,l,se).call(this)}}S=new WeakMap,H=new WeakMap,q=new WeakMap,p=new WeakMap,u=new WeakMap,T=new WeakMap,M=new WeakMap,v=new WeakMap,P=new WeakMap,b=new WeakMap,l=new WeakSet,X=function(){return R(this,null,function*(){const e=yield t(this,H).call(this);h(this,b,[...t(this,P)]),typeof e.default=="function"&&h(this,p,e.default)})},Z=function(){t(this,P).forEach(e=>{document.head.appendChild(e.cloneNode(!0))})},ee=function(e,s){return R(this,null,function*(){var o;const a={urlPatternResult:t(this,q).exec({pathname:s.pathname})};be.isESClass(t(this,p))?(h(this,u,new(t(this,p))(a)),e.appendChild(t(this,u))):h(this,u,Pe.render(e,t(this,p),a)),(o=t(this,u))==null||o.addEventListener("__hmrInstanceReplace",t(this,y)),d(this,l,te).call(this),h(this,T,!0)})},te=function(){var e;t(this,u)&&h(this,M,t(this,u).querySelector("[data-nest]")||((e=t(this,u).shadowRoot)==null?void 0:e.querySelector("[data-nest]"))||t(this,u).shadowRoot||t(this,u))},se=function(){t(this,v).disconnect(),t(this,u)&&(t(this,u).removeEventListener("__hmrInstanceReplace",t(this,y)),t(this,u).remove()),h(this,T,!1),d(this,l,ie).call(this)},ie=function(){t(this,b).forEach(e=>{e.parentNode===document.head&&document.head.removeChild(e)}),h(this,b,[])},re=function(e){e.forEach(s=>{s.addedNodes.forEach(r=>{t(this,p)?t(this,b).push(r):t(this,P).push(r)})})},ae=function(){return R(this,null,function*(){const e=t(this,P).filter(d(this,l,B));yield Promise.all(e.map(s=>new Promise(r=>{d(this,l,B).call(this,s)?s.onload=()=>r():r()})))})},B=function(e){return e instanceof HTMLElement&&(e.tagName==="STYLE"||e.tagName==="SCRIPT"||e.tagName==="LINK")},y=new WeakMap;globalThis.URLPattern=ve.URLPattern;var c,L,k,E,I,_,w,A,m,ne,he,le,z,oe;class Le{constructor(e){n(this,m);n(this,c,null);n(this,L,null);n(this,k,null);n(this,E,null);n(this,I,null);n(this,_,0);n(this,w,[]);n(this,A,null);h(this,c,G($({},e),{rootElement:(e==null?void 0:e.rootElement)||document.body,base:Q.normalizeBase(e==null?void 0:e.base)})),h(this,I,new Re.PageAnnouncerElement),h(this,L,new we.PageScroll(t(this,c).scrollSelector)),t(this,L).update(),h(this,k,new ge.LocalLinks({base:t(this,c).base,trailingSlash:t(this,c).trailingSlash,includeAnchor:e==null?void 0:e.includeAnchor,onClick:(s,r)=>{try{this.navigate(s,r)}catch(a){window.location.assign(s)}}})),t(this,k).update(),h(this,E,new pe.History({onPop:s=>{this.navigate(s)}}))}history(){return t(this,E)}get scroll(){return scroll}get routes(){return t(this,w)}run(){d(this,m,oe).call(this),this.navigate(new URL(location.href),{revalidate:!0})}defineRoute(e,s){const r=new ye(e,s);t(this,w).push(r)}navigate(e,s){return R(this,null,function*(){var O,j,x,V,D,F;const r=t(this,E).isBack,a=++J(this,_)._;let o=Q.normalizeURL(e,{base:t(this,c).base,trailingSlash:t(this,c).trailingSlash});if(t(this,c).urlModifier&&(o=t(this,c).urlModifier(o)),!(yield d(this,m,ne).call(this,o))||t(this,_)!==a||(yield(j=(O=t(this,c)).beforeNavigation)==null?void 0:j.call(O),t(this,_)!==a))return;const{activeRoutes:C,newRoutes:g,oldRoutes:f,keepRoutes:N}=d(this,m,he).call(this,o);h(this,A,(x=N[N.length-1])!=null?x:null),r||(t(this,E).push(o),((V=s==null?void 0:s.keepScrollPosition)==null||V)&&t(this,L).element.scrollTo({top:0,behavior:"instant"})),t(this,I).create(document,o.pathname),t(this,c).viewTransition&&document.startViewTransition?yield document.startViewTransition(()=>d(this,m,z).call(this,f,g,o)).finished:yield d(this,m,z).call(this,f,g,o),t(this,L).update(),t(this,k).update(),t(this,I).done(),yield(F=(D=t(this,c)).afterNavigation)==null?void 0:F.call(D)})}}c=new WeakMap,L=new WeakMap,k=new WeakMap,E=new WeakMap,I=new WeakMap,_=new WeakMap,w=new WeakMap,A=new WeakMap,m=new WeakSet,ne=function(e){return R(this,null,function*(){if(!t(this,c).preprocessor)return!0;try{return yield new Promise((s,r)=>{var a,o;(o=(a=t(this,c)).preprocessor)==null||o.call(a,{url:e,resolve:s,reject:r})}),!0}catch(s){return console.error(s!=null?s:"Route change canceled"),!1}})},he=function(e){let s=e.pathname.replace(t(this,c).base,"");s.startsWith("/")||(s=`/${s}`);const r=t(this,w).filter(a=>a.isActive);return{activeRoutes:r,newRoutes:t(this,w).filter(a=>!r.includes(a)&&a.testPathname(s)),oldRoutes:r.filter(a=>!a.testPathname(s)),keepRoutes:r.filter(a=>a.testPathname(s))}},le=function(e){e.forEach(s=>s.close())},z=function(e,s,r){return R(this,null,function*(){var a,o;d(this,m,le).call(this,e);for(const C of s){const g=(o=(a=t(this,A))==null?void 0:a.nest)!=null?o:t(this,c).rootElement;yield C.render(g,r),h(this,A,C)}})},oe=function(){t(this,w).sort((e,s)=>{const r=e.pattern.split("/").length,a=s.pattern.split("/").length;return r-a})};exports.Router=Le;
|
package/lib/router/index.js
CHANGED
|
@@ -1,253 +1,268 @@
|
|
|
1
|
-
var
|
|
1
|
+
var lt = Object.defineProperty, ct = Object.defineProperties;
|
|
2
2
|
var ut = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var K = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
4
|
+
var dt = Object.prototype.hasOwnProperty, mt = Object.prototype.propertyIsEnumerable;
|
|
5
5
|
var Y = (i) => {
|
|
6
6
|
throw TypeError(i);
|
|
7
7
|
};
|
|
8
|
-
var W = (i, t,
|
|
9
|
-
for (var
|
|
10
|
-
|
|
8
|
+
var W = (i, t, s) => t in i ? lt(i, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : i[t] = s, j = (i, t) => {
|
|
9
|
+
for (var s in t || (t = {}))
|
|
10
|
+
dt.call(t, s) && W(i, s, t[s]);
|
|
11
11
|
if (K)
|
|
12
|
-
for (var
|
|
13
|
-
|
|
12
|
+
for (var s of K(t))
|
|
13
|
+
mt.call(t, s) && W(i, s, t[s]);
|
|
14
14
|
return i;
|
|
15
|
-
}, G = (i, t) =>
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var J = (i, t,
|
|
15
|
+
}, G = (i, t) => ct(i, ut(t));
|
|
16
|
+
var B = (i, t, s) => t.has(i) || Y("Cannot " + s);
|
|
17
|
+
var e = (i, t, s) => (B(i, t, "read from private field"), s ? s.call(i) : t.get(i)), n = (i, t, s) => t.has(i) ? Y("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, s), h = (i, t, s, a) => (B(i, t, "write to private field"), a ? a.call(i, s) : t.set(i, s), s), d = (i, t, s) => (B(i, t, "access private method"), s);
|
|
18
|
+
var J = (i, t, s, a) => ({
|
|
19
19
|
set _(r) {
|
|
20
|
-
h(i, t, r,
|
|
20
|
+
h(i, t, r, s);
|
|
21
21
|
},
|
|
22
22
|
get _() {
|
|
23
|
-
return
|
|
23
|
+
return e(i, t, a);
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
|
-
var
|
|
27
|
-
var
|
|
26
|
+
var w = (i, t, s) => new Promise((a, r) => {
|
|
27
|
+
var l = (f) => {
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
} catch (
|
|
31
|
-
r(
|
|
29
|
+
R(s.next(f));
|
|
30
|
+
} catch (E) {
|
|
31
|
+
r(E);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
33
|
+
}, A = (f) => {
|
|
34
34
|
try {
|
|
35
|
-
|
|
36
|
-
} catch (
|
|
37
|
-
r(
|
|
35
|
+
R(s.throw(f));
|
|
36
|
+
} catch (E) {
|
|
37
|
+
r(E);
|
|
38
38
|
}
|
|
39
|
-
},
|
|
40
|
-
|
|
39
|
+
}, R = (f) => f.done ? a(f.value) : Promise.resolve(f.value).then(l, A);
|
|
40
|
+
R((s = s.apply(i, t)).next());
|
|
41
41
|
});
|
|
42
|
-
import { History as
|
|
43
|
-
import { L as
|
|
44
|
-
import { P as
|
|
42
|
+
import { History as ft } from "../history/index.js";
|
|
43
|
+
import { L as pt } from "../LocalLinks-TQkTpAMx.js";
|
|
44
|
+
import { P as Rt } from "../PageAnnouncerElement-sfh0_4vl.js";
|
|
45
45
|
import { P as wt } from "../PageScroll-cQ3B5-6N.js";
|
|
46
46
|
import "construct-style-sheets-polyfill";
|
|
47
47
|
import "../index-LReFyN6i.js";
|
|
48
|
-
import { a as gt, n as
|
|
48
|
+
import { a as gt, n as vt } from "../url-DAl-mgbC.js";
|
|
49
49
|
import { URLPattern as Pt } from "urlpattern-polyfill";
|
|
50
|
-
import { r as
|
|
50
|
+
import { r as Lt } from "../render-B3Hf-O7M.js";
|
|
51
51
|
import { i as bt } from "../object-CcMK4y_r.js";
|
|
52
|
-
var
|
|
52
|
+
var S, U, T, p, c, I, M, v, P, L, o, Q, X, Z, tt, et, st, it, at, z, b;
|
|
53
53
|
class Nt {
|
|
54
|
-
constructor(t,
|
|
54
|
+
constructor(t, s) {
|
|
55
55
|
n(this, o);
|
|
56
|
-
n(this, E);
|
|
57
|
-
n(this, M);
|
|
58
56
|
n(this, S);
|
|
57
|
+
n(this, U);
|
|
58
|
+
n(this, T);
|
|
59
59
|
n(this, p, null);
|
|
60
|
-
n(this,
|
|
61
|
-
n(this,
|
|
62
|
-
n(this,
|
|
63
|
-
n(this,
|
|
64
|
-
n(this,
|
|
65
|
-
n(this,
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
n(this, c, null);
|
|
61
|
+
n(this, I, !1);
|
|
62
|
+
n(this, M, null);
|
|
63
|
+
n(this, v);
|
|
64
|
+
n(this, P, []);
|
|
65
|
+
n(this, L, []);
|
|
66
|
+
n(this, b, (t) => {
|
|
67
|
+
e(this, c).removeEventListener(
|
|
68
|
+
"__hmrInstanceReplace",
|
|
69
|
+
e(this, b)
|
|
70
|
+
), h(this, c, t.detail.element), e(this, c).addEventListener(
|
|
71
|
+
"__hmrInstanceReplace",
|
|
72
|
+
e(this, b)
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
h(this, S, t), h(this, U, s), h(this, T, new URLPattern({ pathname: e(this, S) })), h(this, v, new MutationObserver(
|
|
76
|
+
d(this, o, it).bind(this)
|
|
68
77
|
));
|
|
69
78
|
}
|
|
70
79
|
get pattern() {
|
|
71
|
-
return
|
|
80
|
+
return e(this, S);
|
|
72
81
|
}
|
|
73
82
|
get isActive() {
|
|
74
|
-
return
|
|
83
|
+
return e(this, I);
|
|
75
84
|
}
|
|
76
85
|
get element() {
|
|
77
|
-
return
|
|
86
|
+
return e(this, c);
|
|
78
87
|
}
|
|
79
88
|
get nest() {
|
|
80
|
-
return
|
|
89
|
+
return e(this, M);
|
|
81
90
|
}
|
|
82
91
|
testPathname(t) {
|
|
83
|
-
return
|
|
92
|
+
return e(this, T).test({ pathname: t });
|
|
84
93
|
}
|
|
85
|
-
render(t,
|
|
86
|
-
return
|
|
87
|
-
|
|
94
|
+
render(t, s) {
|
|
95
|
+
return w(this, null, function* () {
|
|
96
|
+
e(this, v).observe(document.head, {
|
|
88
97
|
childList: !0,
|
|
89
98
|
subtree: !0
|
|
90
|
-
}),
|
|
99
|
+
}), e(this, p) ? d(this, o, X).call(this) : yield d(this, o, Q).call(this), yield d(this, o, at).call(this), e(this, p) && (yield d(this, o, Z).call(this, t, s)), e(this, v).disconnect();
|
|
91
100
|
});
|
|
92
101
|
}
|
|
93
102
|
close() {
|
|
94
|
-
|
|
103
|
+
d(this, o, et).call(this);
|
|
95
104
|
}
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
return
|
|
99
|
-
const t = yield
|
|
100
|
-
h(this,
|
|
106
|
+
S = new WeakMap(), U = new WeakMap(), T = new WeakMap(), p = new WeakMap(), c = new WeakMap(), I = new WeakMap(), M = new WeakMap(), v = new WeakMap(), P = new WeakMap(), L = new WeakMap(), o = new WeakSet(), Q = function() {
|
|
107
|
+
return w(this, null, function* () {
|
|
108
|
+
const t = yield e(this, U).call(this);
|
|
109
|
+
h(this, L, [...e(this, P)]), typeof t.default == "function" && h(this, p, t.default);
|
|
101
110
|
});
|
|
102
111
|
}, X = function() {
|
|
103
|
-
|
|
112
|
+
e(this, P).forEach((t) => {
|
|
104
113
|
document.head.appendChild(t.cloneNode(!0));
|
|
105
114
|
});
|
|
106
|
-
}, Z = function(t,
|
|
107
|
-
return
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
}, Z = function(t, s) {
|
|
116
|
+
return w(this, null, function* () {
|
|
117
|
+
var l;
|
|
118
|
+
const r = { urlPatternResult: e(this, T).exec({ pathname: s.pathname }) };
|
|
119
|
+
bt(e(this, p)) ? (h(this, c, new (e(this, p))(r)), t.appendChild(e(this, c))) : h(this, c, Lt(
|
|
110
120
|
t,
|
|
111
|
-
|
|
121
|
+
e(this, p),
|
|
112
122
|
r
|
|
113
|
-
)),
|
|
123
|
+
)), (l = e(this, c)) == null || l.addEventListener(
|
|
124
|
+
"__hmrInstanceReplace",
|
|
125
|
+
e(this, b)
|
|
126
|
+
), d(this, o, tt).call(this), h(this, I, !0);
|
|
114
127
|
});
|
|
115
|
-
}, _ = function() {
|
|
116
|
-
var t;
|
|
117
|
-
s(this, d) && h(this, B, s(this, d).querySelector("[data-nest]") || ((t = s(this, d).shadowRoot) == null ? void 0 : t.querySelector("[data-nest]")) || s(this, d).shadowRoot || s(this, d));
|
|
118
128
|
}, tt = function() {
|
|
119
129
|
var t;
|
|
120
|
-
|
|
130
|
+
e(this, c) && h(this, M, e(this, c).querySelector("[data-nest]") || ((t = e(this, c).shadowRoot) == null ? void 0 : t.querySelector("[data-nest]")) || e(this, c).shadowRoot || e(this, c));
|
|
121
131
|
}, et = function() {
|
|
122
|
-
|
|
132
|
+
e(this, v).disconnect(), e(this, c) && (e(this, c).removeEventListener(
|
|
133
|
+
"__hmrInstanceReplace",
|
|
134
|
+
e(this, b)
|
|
135
|
+
), e(this, c).remove()), h(this, I, !1), d(this, o, st).call(this);
|
|
136
|
+
}, st = function() {
|
|
137
|
+
e(this, L).forEach((t) => {
|
|
123
138
|
t.parentNode === document.head && document.head.removeChild(t);
|
|
124
|
-
}), h(this,
|
|
125
|
-
},
|
|
126
|
-
t.forEach((
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
}), h(this, L, []);
|
|
140
|
+
}, it = function(t) {
|
|
141
|
+
t.forEach((s) => {
|
|
142
|
+
s.addedNodes.forEach((a) => {
|
|
143
|
+
e(this, p) ? e(this, L).push(a) : e(this, P).push(a);
|
|
129
144
|
});
|
|
130
145
|
});
|
|
131
|
-
},
|
|
132
|
-
return
|
|
133
|
-
const t =
|
|
146
|
+
}, at = function() {
|
|
147
|
+
return w(this, null, function* () {
|
|
148
|
+
const t = e(this, P).filter(d(this, o, z));
|
|
134
149
|
yield Promise.all(
|
|
135
150
|
t.map(
|
|
136
|
-
(
|
|
137
|
-
|
|
151
|
+
(s) => new Promise((a) => {
|
|
152
|
+
d(this, o, z).call(this, s) ? s.onload = () => a() : a();
|
|
138
153
|
})
|
|
139
154
|
)
|
|
140
155
|
);
|
|
141
156
|
});
|
|
142
157
|
}, z = function(t) {
|
|
143
158
|
return t instanceof HTMLElement && (t.tagName === "STYLE" || t.tagName === "SCRIPT" || t.tagName === "LINK");
|
|
144
|
-
};
|
|
159
|
+
}, b = new WeakMap();
|
|
145
160
|
globalThis.URLPattern = Pt;
|
|
146
|
-
var
|
|
147
|
-
class
|
|
161
|
+
var u, N, k, y, C, H, g, _, m, rt, nt, ht, O, ot;
|
|
162
|
+
class Bt {
|
|
148
163
|
constructor(t) {
|
|
149
164
|
n(this, m);
|
|
150
|
-
n(this,
|
|
165
|
+
n(this, u, null);
|
|
151
166
|
n(this, N, null);
|
|
152
167
|
n(this, k, null);
|
|
153
168
|
n(this, y, null);
|
|
154
169
|
n(this, C, null);
|
|
155
170
|
n(this, H, 0);
|
|
156
|
-
n(this,
|
|
157
|
-
n(this,
|
|
158
|
-
h(this,
|
|
171
|
+
n(this, g, []);
|
|
172
|
+
n(this, _, null);
|
|
173
|
+
h(this, u, G(j({}, t), {
|
|
159
174
|
rootElement: (t == null ? void 0 : t.rootElement) || document.body,
|
|
160
175
|
base: gt(t == null ? void 0 : t.base)
|
|
161
|
-
})), h(this, C, new
|
|
162
|
-
base:
|
|
163
|
-
trailingSlash:
|
|
176
|
+
})), h(this, C, new Rt()), h(this, N, new wt(e(this, u).scrollSelector)), e(this, N).update(), h(this, k, new pt({
|
|
177
|
+
base: e(this, u).base,
|
|
178
|
+
trailingSlash: e(this, u).trailingSlash,
|
|
164
179
|
includeAnchor: t == null ? void 0 : t.includeAnchor,
|
|
165
|
-
onClick: (
|
|
180
|
+
onClick: (s, a) => {
|
|
166
181
|
try {
|
|
167
|
-
this.navigate(
|
|
182
|
+
this.navigate(s, a);
|
|
168
183
|
} catch (r) {
|
|
169
|
-
window.location.assign(
|
|
184
|
+
window.location.assign(s);
|
|
170
185
|
}
|
|
171
186
|
}
|
|
172
|
-
})),
|
|
173
|
-
onPop: (
|
|
174
|
-
this.navigate(
|
|
187
|
+
})), e(this, k).update(), h(this, y, new ft({
|
|
188
|
+
onPop: (s) => {
|
|
189
|
+
this.navigate(s);
|
|
175
190
|
}
|
|
176
191
|
}));
|
|
177
192
|
}
|
|
178
193
|
history() {
|
|
179
|
-
return
|
|
194
|
+
return e(this, y);
|
|
180
195
|
}
|
|
181
196
|
get scroll() {
|
|
182
197
|
return scroll;
|
|
183
198
|
}
|
|
184
199
|
get routes() {
|
|
185
|
-
return
|
|
200
|
+
return e(this, g);
|
|
186
201
|
}
|
|
187
202
|
run() {
|
|
188
|
-
|
|
203
|
+
d(this, m, ot).call(this), this.navigate(new URL(location.href), { revalidate: !0 });
|
|
189
204
|
}
|
|
190
|
-
defineRoute(t,
|
|
191
|
-
const a = new Nt(t,
|
|
192
|
-
|
|
205
|
+
defineRoute(t, s) {
|
|
206
|
+
const a = new Nt(t, s);
|
|
207
|
+
e(this, g).push(a);
|
|
193
208
|
}
|
|
194
|
-
navigate(t,
|
|
195
|
-
return
|
|
209
|
+
navigate(t, s) {
|
|
210
|
+
return w(this, null, function* () {
|
|
196
211
|
var q, x, V, $, D, F;
|
|
197
|
-
const a =
|
|
198
|
-
let
|
|
199
|
-
base:
|
|
200
|
-
trailingSlash:
|
|
212
|
+
const a = e(this, y).isBack, r = ++J(this, H)._;
|
|
213
|
+
let l = vt(t, {
|
|
214
|
+
base: e(this, u).base,
|
|
215
|
+
trailingSlash: e(this, u).trailingSlash
|
|
201
216
|
});
|
|
202
|
-
if (
|
|
217
|
+
if (e(this, u).urlModifier && (l = e(this, u).urlModifier(l)), !(yield d(this, m, rt).call(this, l)) || e(this, H) !== r || (yield (x = (q = e(this, u)).beforeNavigation) == null ? void 0 : x.call(q), e(this, H) !== r))
|
|
203
218
|
return;
|
|
204
|
-
const { activeRoutes:
|
|
205
|
-
h(this,
|
|
219
|
+
const { activeRoutes: A, newRoutes: R, oldRoutes: f, keepRoutes: E } = d(this, m, nt).call(this, l);
|
|
220
|
+
h(this, _, (V = E[E.length - 1]) != null ? V : null), a || (e(this, y).push(l), (($ = s == null ? void 0 : s.keepScrollPosition) == null || $) && e(this, N).element.scrollTo({ top: 0, behavior: "instant" })), e(this, C).create(document, l.pathname), e(this, u).viewTransition && document.startViewTransition ? yield document.startViewTransition(() => d(this, m, O).call(this, f, R, l)).finished : yield d(this, m, O).call(this, f, R, l), e(this, N).update(), e(this, k).update(), e(this, C).done(), yield (F = (D = e(this, u)).afterNavigation) == null ? void 0 : F.call(D);
|
|
206
221
|
});
|
|
207
222
|
}
|
|
208
223
|
}
|
|
209
|
-
|
|
210
|
-
return
|
|
211
|
-
if (!
|
|
224
|
+
u = new WeakMap(), N = new WeakMap(), k = new WeakMap(), y = new WeakMap(), C = new WeakMap(), H = new WeakMap(), g = new WeakMap(), _ = new WeakMap(), m = new WeakSet(), rt = function(t) {
|
|
225
|
+
return w(this, null, function* () {
|
|
226
|
+
if (!e(this, u).preprocessor)
|
|
212
227
|
return !0;
|
|
213
228
|
try {
|
|
214
|
-
return yield new Promise((
|
|
215
|
-
var r,
|
|
216
|
-
(
|
|
229
|
+
return yield new Promise((s, a) => {
|
|
230
|
+
var r, l;
|
|
231
|
+
(l = (r = e(this, u)).preprocessor) == null || l.call(r, { url: t, resolve: s, reject: a });
|
|
217
232
|
}), !0;
|
|
218
|
-
} catch (
|
|
219
|
-
return console.error(
|
|
233
|
+
} catch (s) {
|
|
234
|
+
return console.error(s != null ? s : "Route change canceled"), !1;
|
|
220
235
|
}
|
|
221
236
|
});
|
|
222
|
-
},
|
|
223
|
-
let
|
|
224
|
-
|
|
225
|
-
const a =
|
|
237
|
+
}, nt = function(t) {
|
|
238
|
+
let s = t.pathname.replace(e(this, u).base, "");
|
|
239
|
+
s.startsWith("/") || (s = `/${s}`);
|
|
240
|
+
const a = e(this, g).filter((r) => r.isActive);
|
|
226
241
|
return {
|
|
227
242
|
activeRoutes: a,
|
|
228
|
-
newRoutes:
|
|
229
|
-
(r) => !a.includes(r) && r.testPathname(
|
|
243
|
+
newRoutes: e(this, g).filter(
|
|
244
|
+
(r) => !a.includes(r) && r.testPathname(s)
|
|
230
245
|
),
|
|
231
|
-
oldRoutes: a.filter((r) => !r.testPathname(
|
|
232
|
-
keepRoutes: a.filter((r) => r.testPathname(
|
|
246
|
+
oldRoutes: a.filter((r) => !r.testPathname(s)),
|
|
247
|
+
keepRoutes: a.filter((r) => r.testPathname(s))
|
|
233
248
|
};
|
|
234
|
-
},
|
|
235
|
-
t.forEach((
|
|
236
|
-
}, O = function(t,
|
|
237
|
-
return
|
|
238
|
-
var r,
|
|
239
|
-
|
|
240
|
-
for (const
|
|
241
|
-
const
|
|
242
|
-
yield
|
|
249
|
+
}, ht = function(t) {
|
|
250
|
+
t.forEach((s) => s.close());
|
|
251
|
+
}, O = function(t, s, a) {
|
|
252
|
+
return w(this, null, function* () {
|
|
253
|
+
var r, l;
|
|
254
|
+
d(this, m, ht).call(this, t);
|
|
255
|
+
for (const A of s) {
|
|
256
|
+
const R = (l = (r = e(this, _)) == null ? void 0 : r.nest) != null ? l : e(this, u).rootElement;
|
|
257
|
+
yield A.render(R, a), h(this, _, A);
|
|
243
258
|
}
|
|
244
259
|
});
|
|
245
|
-
},
|
|
246
|
-
|
|
247
|
-
const a = t.pattern.split("/").length, r =
|
|
260
|
+
}, ot = function() {
|
|
261
|
+
e(this, g).sort((t, s) => {
|
|
262
|
+
const a = t.pattern.split("/").length, r = s.pattern.split("/").length;
|
|
248
263
|
return a - r;
|
|
249
264
|
});
|
|
250
265
|
};
|
|
251
266
|
export {
|
|
252
|
-
|
|
267
|
+
Bt as Router
|
|
253
268
|
};
|