aptechka 0.1.8 → 0.1.10
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/Composed-C2Vv1xxR.cjs +1 -0
- package/lib/Composed-DhtYBEmo.js +79 -0
- package/lib/abstract-elements/index.cjs +1 -1
- package/lib/abstract-elements/index.js +1 -1
- package/lib/canvas/index.cjs +1 -1
- package/lib/canvas/index.js +2 -2
- package/lib/component/Component.d.ts +29 -0
- package/lib/component/hooks/animation.d.ts +9 -0
- package/lib/component/hooks/context.d.ts +2 -0
- package/lib/component/hooks/intersection.d.ts +4 -0
- package/lib/component/hooks/resize.d.ts +6 -0
- package/lib/component/hooks/shadow.d.ts +1 -0
- package/lib/component/hooks/stores.d.ts +6 -0
- package/lib/component/hooks/style.d.ts +2 -0
- package/lib/component/index.cjs +1 -0
- package/lib/component/index.d.ts +7 -0
- package/lib/component/index.js +187 -0
- package/lib/connector/index.cjs +1 -1
- package/lib/connector/index.d.ts +4 -3
- package/lib/connector/index.js +24 -22
- package/lib/{createStylesheet-BsVHqHhr.cjs → createStylesheet-BoJwXvjE.cjs} +1 -1
- package/lib/{createStylesheet-ITfBHk7A.js → createStylesheet-DSgkNlUZ.js} +1 -1
- package/lib/element-constructor/ElementConstructor.d.ts +4 -3
- package/lib/element-constructor/index.cjs +1 -1
- package/lib/element-constructor/index.js +2 -2
- package/lib/element-constructor/tags.d.ts +2 -3
- package/lib/element-resizer/index.cjs +1 -1
- package/lib/element-resizer/index.d.ts +1 -1
- package/lib/element-resizer/index.js +2 -1
- package/lib/en3/core/en3.d.ts +2 -2
- package/lib/en3/objects/En3Clip.d.ts +1 -1
- package/lib/{index-COirQu7j.js → index-228VqUsZ.js} +2 -2
- package/lib/{index-Bt91QUTY.cjs → index-Cv4y7_7y.cjs} +1 -1
- package/lib/intersector/index.cjs +1 -1
- package/lib/intersector/index.d.ts +1 -1
- package/lib/intersector/index.js +2 -1
- package/lib/layout-box/index.cjs +1 -1
- package/lib/layout-box/index.d.ts +2 -2
- package/lib/layout-box/index.js +70 -72
- package/lib/modal/index.cjs +1 -1
- package/lib/modal/index.js +2 -2
- package/lib/object-C1ph624j.cjs +1 -0
- package/lib/object-DIPjdukP.js +73 -0
- package/lib/popover/index.cjs +1 -1
- package/lib/popover/index.js +79 -71
- package/lib/router/Route.d.ts +8 -2
- package/lib/router/index.cjs +1 -1
- package/lib/router/index.d.ts +1 -2
- package/lib/router/index.js +139 -140
- package/lib/scroll/index.cjs +1 -1
- package/lib/scroll/index.js +2 -2
- package/lib/select/index.cjs +1 -1
- package/lib/select/index.js +1 -1
- package/lib/store/index.cjs +1 -1
- package/lib/store/index.js +48 -111
- package/lib/studio/index.cjs +1 -1
- package/lib/studio/index.js +3 -3
- package/lib/tags-920hsh9U.cjs +1 -0
- package/lib/tags-kZqsS_nJ.js +793 -0
- package/lib/theme/index.cjs +1 -1
- package/lib/theme/index.js +1 -1
- package/lib/ticker/index.cjs +1 -1
- package/lib/ticker/index.d.ts +1 -1
- package/lib/ticker/index.js +42 -36
- package/lib/utils/dom.d.ts +2 -2
- package/lib/utils/index.cjs +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +113 -168
- package/lib/utils/object.d.ts +1 -0
- package/package.json +10 -2
- package/lib/router/RouteElement.d.ts +0 -14
- package/lib/tags-8Y7LSTwg.js +0 -779
- package/lib/tags-pcim-Cws.cjs +0 -1
package/lib/popover/index.js
CHANGED
|
@@ -1,122 +1,130 @@
|
|
|
1
|
-
import { Attribute as
|
|
2
|
-
import { CustomElement as
|
|
3
|
-
import { S as
|
|
4
|
-
import { g as
|
|
5
|
-
import { AbstractButtonElement as
|
|
6
|
-
var
|
|
7
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
8
|
-
(l = e[
|
|
9
|
-
return r && n &&
|
|
10
|
-
},
|
|
1
|
+
import { Attribute as C } from "../attribute/index.js";
|
|
2
|
+
import { CustomElement as I, define as A } from "../custom-element/index.js";
|
|
3
|
+
import { S as q } from "../Store-JOKrNVEr.js";
|
|
4
|
+
import { g as B } from "../style-j2TwriJ_.js";
|
|
5
|
+
import { AbstractButtonElement as G } from "../abstract-elements/index.js";
|
|
6
|
+
var x = Object.defineProperty, H = Object.getOwnPropertyDescriptor, R = (e, t, s) => t in e ? x(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, F = (e, t, s, r) => {
|
|
7
|
+
for (var n = r > 1 ? void 0 : r ? H(t, s) : t, p = e.length - 1, l; p >= 0; p--)
|
|
8
|
+
(l = e[p]) && (n = (r ? l(t, s, n) : l(n)) || n);
|
|
9
|
+
return r && n && x(t, s, n), n;
|
|
10
|
+
}, $ = (e, t, s) => (R(e, typeof t != "symbol" ? t + "" : t, s), s), T = (e, t, s) => {
|
|
11
11
|
if (!t.has(e))
|
|
12
|
-
throw TypeError("Cannot " +
|
|
13
|
-
},
|
|
12
|
+
throw TypeError("Cannot " + s);
|
|
13
|
+
}, i = (e, t, s) => (T(e, t, "read from private field"), s ? s.call(e) : t.get(e)), o = (e, t, s) => {
|
|
14
14
|
if (t.has(e))
|
|
15
15
|
throw TypeError("Cannot add the same private member more than once");
|
|
16
|
-
t instanceof WeakSet ? t.add(e) : t.set(e,
|
|
17
|
-
},
|
|
18
|
-
let a = class extends
|
|
16
|
+
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
17
|
+
}, W = (e, t, s, r) => (T(e, t, "write to private field"), r ? r.call(e, s) : t.set(e, s), s), P = (e, t, s) => (T(e, t, "access private method"), s), S, h, m, d, g, f, k, D, _, w, y, E, L, M, v;
|
|
18
|
+
let a = class extends I {
|
|
19
19
|
constructor() {
|
|
20
|
-
super(...arguments), o(this,
|
|
21
|
-
|
|
22
|
-
addEventListener("click",
|
|
20
|
+
super(...arguments), o(this, k), o(this, _), o(this, L), o(this, S, -1), o(this, h, new q(!1)), o(this, m, void 0), o(this, d, new C(this, "history", !1)), o(this, g, new C(this, "single", !1)), o(this, f, !1), $(this, "open", () => {
|
|
21
|
+
i(this, h).current || (i(this, h).current = !0, i(this, g).current && (a.__opened.forEach((e) => e.close()), a.__opened = []), a.__opened.push(this), W(this, S, a.__opened.length - 1), i(this, d).current && i(this, f) && history.pushState("", "", i(this, k, D)), clearTimeout(i(this, m)), this.classList.add("triggered"), this.style.display = "block", setTimeout(() => {
|
|
22
|
+
addEventListener("click", i(this, y)), addEventListener("keydown", i(this, E)), this.style.opacity = "1", this.classList.add("opened");
|
|
23
23
|
}));
|
|
24
|
-
}),
|
|
25
|
-
|
|
24
|
+
}), $(this, "close", () => {
|
|
25
|
+
i(this, h).current && (i(this, h).current = !1, a.__opened = a.__opened.filter((e) => e !== this), i(this, d).current && history.replaceState(
|
|
26
|
+
"",
|
|
27
|
+
"",
|
|
28
|
+
location.href.replace(new RegExp(`[&?]${i(this, _, w)}`, "g"), "")
|
|
29
|
+
), this.classList.remove("opened"), this.style.opacity = "0", removeEventListener("click", i(this, y)), removeEventListener("keydown", i(this, E)), setTimeout(() => {
|
|
26
30
|
this.classList.remove("triggered"), this.style.display = "none";
|
|
27
|
-
},
|
|
28
|
-
}), o(this,
|
|
29
|
-
|
|
31
|
+
}, B(this)));
|
|
32
|
+
}), o(this, y, (e) => {
|
|
33
|
+
P(this, L, M).call(this, () => {
|
|
30
34
|
const t = e.composedPath();
|
|
31
|
-
(!t.find((
|
|
32
|
-
(
|
|
35
|
+
(!t.find((s) => s === this) && !t.find(
|
|
36
|
+
(s) => s instanceof HTMLElement && s.closest("e-popover-button")
|
|
33
37
|
) || t[0] instanceof HTMLElement && t[0].hasAttribute("outside")) && this.close();
|
|
34
38
|
});
|
|
35
|
-
}), o(this,
|
|
36
|
-
|
|
39
|
+
}), o(this, E, (e) => {
|
|
40
|
+
P(this, L, M).call(this, () => {
|
|
37
41
|
e.code === "Escape" && this.close();
|
|
38
42
|
});
|
|
39
|
-
}), o(this,
|
|
40
|
-
|
|
43
|
+
}), o(this, v, () => {
|
|
44
|
+
W(this, f, !1), i(this, h).current && i(this, d).current && !location.search.includes(i(this, _, w)) ? this.close() : !i(this, h).current && i(this, d).current && location.search.includes(i(this, _, w)) && this.open(), W(this, f, !0);
|
|
41
45
|
});
|
|
42
46
|
}
|
|
43
47
|
get history() {
|
|
44
|
-
return
|
|
48
|
+
return i(this, d);
|
|
45
49
|
}
|
|
46
50
|
get single() {
|
|
47
|
-
return
|
|
51
|
+
return i(this, g);
|
|
48
52
|
}
|
|
49
53
|
get opened() {
|
|
50
|
-
return
|
|
54
|
+
return i(this, h);
|
|
51
55
|
}
|
|
52
56
|
connectedCallback() {
|
|
53
|
-
this.style.opacity = "0", this.style.display = "none", addEventListener("popstate",
|
|
54
|
-
|
|
57
|
+
this.style.opacity = "0", this.style.display = "none", addEventListener("popstate", i(this, v)), setTimeout(() => {
|
|
58
|
+
i(this, v).call(this);
|
|
55
59
|
}, 0);
|
|
56
60
|
}
|
|
57
61
|
disconnectedCallback() {
|
|
58
|
-
clearTimeout(
|
|
62
|
+
clearTimeout(i(this, m)), removeEventListener("popstate", i(this, v));
|
|
59
63
|
}
|
|
60
64
|
};
|
|
61
|
-
|
|
65
|
+
S = /* @__PURE__ */ new WeakMap();
|
|
62
66
|
h = /* @__PURE__ */ new WeakMap();
|
|
63
|
-
v = /* @__PURE__ */ new WeakMap();
|
|
64
|
-
d = /* @__PURE__ */ new WeakMap();
|
|
65
67
|
m = /* @__PURE__ */ new WeakMap();
|
|
66
|
-
|
|
67
|
-
M = /* @__PURE__ */ new WeakSet();
|
|
68
|
-
A = function() {
|
|
69
|
-
return `${location.pathname}${location.pathname.endsWith("/") ? "" : "/"}${this.id}`;
|
|
70
|
-
};
|
|
71
|
-
w = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
d = /* @__PURE__ */ new WeakMap();
|
|
72
69
|
g = /* @__PURE__ */ new WeakMap();
|
|
73
|
-
y = /* @__PURE__ */ new WeakSet();
|
|
74
|
-
S = function(e) {
|
|
75
|
-
(a.__opened[s(this, E) - 1] || a.__opened.length === 1) && e();
|
|
76
|
-
};
|
|
77
70
|
f = /* @__PURE__ */ new WeakMap();
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
k = /* @__PURE__ */ new WeakSet();
|
|
72
|
+
D = function() {
|
|
73
|
+
return `${location.pathname}${location.search ? location.search + "&" : "?"}${i(this, _, w)}`;
|
|
74
|
+
};
|
|
75
|
+
_ = /* @__PURE__ */ new WeakSet();
|
|
76
|
+
w = function() {
|
|
77
|
+
return `modal-${this.id}`;
|
|
78
|
+
};
|
|
79
|
+
y = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
E = /* @__PURE__ */ new WeakMap();
|
|
81
|
+
L = /* @__PURE__ */ new WeakSet();
|
|
82
|
+
M = function(e) {
|
|
83
|
+
(a.__opened[i(this, S) - 1] || a.__opened.length === 1) && e();
|
|
84
|
+
};
|
|
85
|
+
v = /* @__PURE__ */ new WeakMap();
|
|
86
|
+
$(a, "__opened", []);
|
|
87
|
+
a = F([
|
|
88
|
+
A("e-popover")
|
|
81
89
|
], a);
|
|
82
|
-
var
|
|
83
|
-
for (var n = r > 1 ? void 0 : r ?
|
|
84
|
-
(l = e[
|
|
85
|
-
return r && n &&
|
|
86
|
-
},
|
|
90
|
+
var z = Object.defineProperty, J = Object.getOwnPropertyDescriptor, K = (e, t, s, r) => {
|
|
91
|
+
for (var n = r > 1 ? void 0 : r ? J(t, s) : t, p = e.length - 1, l; p >= 0; p--)
|
|
92
|
+
(l = e[p]) && (n = (r ? l(t, s, n) : l(n)) || n);
|
|
93
|
+
return r && n && z(t, s, n), n;
|
|
94
|
+
}, N = (e, t, s) => {
|
|
87
95
|
if (!t.has(e))
|
|
88
|
-
throw TypeError("Cannot " +
|
|
89
|
-
}, u = (e, t,
|
|
96
|
+
throw TypeError("Cannot " + s);
|
|
97
|
+
}, u = (e, t, s) => (N(e, t, "read from private field"), s ? s.call(e) : t.get(e)), Q = (e, t, s) => {
|
|
90
98
|
if (t.has(e))
|
|
91
99
|
throw TypeError("Cannot add the same private member more than once");
|
|
92
|
-
t instanceof WeakSet ? t.add(e) : t.set(e,
|
|
93
|
-
},
|
|
94
|
-
let
|
|
100
|
+
t instanceof WeakSet ? t.add(e) : t.set(e, s);
|
|
101
|
+
}, U = (e, t, s, r) => (N(e, t, "write to private field"), r ? r.call(e, s) : t.set(e, s), s), c;
|
|
102
|
+
let O = class extends G {
|
|
95
103
|
constructor() {
|
|
96
|
-
super(...arguments),
|
|
104
|
+
super(...arguments), Q(this, c, void 0);
|
|
97
105
|
}
|
|
98
106
|
get popoverElement() {
|
|
99
|
-
return u(this,
|
|
107
|
+
return u(this, c);
|
|
100
108
|
}
|
|
101
109
|
click() {
|
|
102
|
-
if (u(this,
|
|
110
|
+
if (u(this, c)) {
|
|
103
111
|
const e = this.getAttribute("type") || "open";
|
|
104
|
-
e === "open" || e === "toggle" && !u(this,
|
|
112
|
+
e === "open" || e === "toggle" && !u(this, c).opened.current ? u(this, c).open() : (e === "close" || e === "toggle" && u(this, c).opened.current) && u(this, c).close();
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
connectedCallback() {
|
|
108
116
|
const e = this.getAttribute("target");
|
|
109
117
|
if (e) {
|
|
110
118
|
const t = document.querySelector(`#${e}`) || this.getRootNode().querySelector(`#${e}`);
|
|
111
|
-
t ?
|
|
119
|
+
t ? U(this, c, t) : console.warn(this, `target ${e} not found`);
|
|
112
120
|
}
|
|
113
121
|
}
|
|
114
122
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
],
|
|
123
|
+
c = /* @__PURE__ */ new WeakMap();
|
|
124
|
+
O = K([
|
|
125
|
+
A("e-popover-button")
|
|
126
|
+
], O);
|
|
119
127
|
export {
|
|
120
|
-
|
|
128
|
+
O as PopoverButtonElement,
|
|
121
129
|
a as PopoverElement
|
|
122
130
|
};
|
package/lib/router/Route.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { RouteElement } from './RouteElement';
|
|
2
1
|
export type RouteModule = () => Promise<any>;
|
|
2
|
+
export type RouteURLParams<T extends string = string> = Partial<{
|
|
3
|
+
[key in T]: string;
|
|
4
|
+
}>;
|
|
5
|
+
export type RouteParameters<PathnameParams extends string = string, SearchParams extends string = string> = {
|
|
6
|
+
pathnameParams: RouteURLParams<PathnameParams>;
|
|
7
|
+
searchParams: RouteURLParams<SearchParams>;
|
|
8
|
+
};
|
|
3
9
|
export declare class Route {
|
|
4
10
|
#private;
|
|
5
11
|
constructor(pattern: string, module: RouteModule);
|
|
6
12
|
get pattern(): string;
|
|
7
13
|
get urlPattern(): URLPattern;
|
|
8
14
|
get isActive(): boolean;
|
|
9
|
-
get element():
|
|
15
|
+
get element(): HTMLElement | null;
|
|
10
16
|
get outlet(): HTMLElement | ShadowRoot | null;
|
|
11
17
|
testPathname(pathname: string): boolean;
|
|
12
18
|
render(containerElement: HTMLElement | ShadowRoot, pathname: string): Promise<void>;
|
package/lib/router/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var st=Object.defineProperty;var Z=(i,t)=>(t=Symbol[i])?t:Symbol.for("Symbol."+i);var it=(i,t,s)=>t in i?st(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var I=(i,t,s)=>(it(i,typeof t!="symbol"?t+"":t,s),s),F=(i,t,s)=>{if(!t.has(i))throw TypeError("Cannot "+s)};var e=(i,t,s)=>(F(i,t,"read from private field"),s?s.call(i):t.get(i)),n=(i,t,s)=>{if(t.has(i))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(i):t.set(i,s)},o=(i,t,s,r)=>(F(i,t,"write to private field"),r?r.call(i,s):t.set(i,s),s);var G=(i,t,s)=>(F(i,t,"access private method"),s);var D=(i,t,s)=>new Promise((r,f)=>{var h=u=>{try{d(s.next(u))}catch(T){f(T)}},a=u=>{try{d(s.throw(u))}catch(T){f(T)}},d=u=>u.done?r(u.value):Promise.resolve(u.value).then(h,a);d((s=s.apply(i,t)).next())});var J=(i,t,s)=>(t=i[Z("asyncIterator")])?t.call(i):(i=i[Z("iterator")](),t={},s=(r,f)=>(f=i[r])&&(t[r]=h=>new Promise((a,d,u)=>(h=f.call(i,h),u=h.done,Promise.resolve(h.value).then(T=>a({value:T,done:u}),d)))),s("next"),s("return"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rt=require("urlpattern-polyfill"),ot=require("../notifier/index.cjs"),_=require("../browser-CpzFX2xg.cjs"),nt=require("../function-MthRj-GJ.cjs"),$=require("../object-C1ph624j.cjs");var b,H,R,m,l,w,S,v,P,y,K,tt;class ht{constructor(t,s){n(this,K);n(this,b,void 0);n(this,H,void 0);n(this,R,void 0);n(this,m,void 0);n(this,l,void 0);n(this,w,void 0);n(this,S,void 0);n(this,v,null);n(this,P,[]);n(this,y,[]);o(this,b,t),o(this,H,s),o(this,R,new URLPattern({pathname:e(this,b)})),o(this,m,null),o(this,l,null),o(this,w,!1),o(this,S,null),_.isBrowser&&o(this,v,new MutationObserver(r=>{r[0].addedNodes.forEach(h=>{e(this,m)?e(this,y).push(h):e(this,P).push(h)})}))}get pattern(){return e(this,b)}get urlPattern(){return e(this,R)}get isActive(){return e(this,w)}get element(){return e(this,l)}get outlet(){return e(this,S)}testPathname(t){return this.urlPattern.test({pathname:t})}render(t,s){return D(this,null,function*(){var r,f;if(e(this,v).observe(document.head,{childList:!0,subtree:!0}),e(this,m))e(this,P).forEach(h=>{document.head.appendChild(h)});else{const h=yield e(this,H).call(this);if(o(this,y,[...e(this,P)]),typeof h.default=="function"&&(o(this,m,h.default),$.isESClass(h.default))){const a="e-"+((r=e(this,m))==null?void 0:r.name.toLowerCase());customElements.get(a)||customElements.define(a,h.default)}}if(yield G(this,K,tt).call(this),e(this,m)){const h=e(this,R).exec({pathname:s}),a=(h==null?void 0:h.pathname.groups)||{},d=Object.fromEntries(new URLSearchParams(location.search)),u={pathnameParams:a,searchParams:d};$.isESClass(e(this,m))?o(this,l,new(e(this,m))(u)):o(this,l,e(this,m).call(this,u)),t.appendChild(e(this,l)),o(this,S,e(this,l).querySelector("[data-outlet]")||((f=e(this,l).shadowRoot)==null?void 0:f.querySelector("[data-outlet]"))||e(this,l).shadowRoot||e(this,l)),o(this,w,!0)}e(this,v).disconnect()})}close(){var t;e(this,v).disconnect(),(t=e(this,l))==null||t.remove(),o(this,w,!1),e(this,y).forEach(s=>document.head.removeChild(s)),o(this,y,[])}getAnchorElements(){var s;let t=[];return e(this,l)&&(t=[...e(this,l).querySelectorAll("a")]),(s=e(this,l))!=null&&s.shadowRoot&&(t=[...t,...e(this,l).shadowRoot.querySelectorAll("a")]),t}}b=new WeakMap,H=new WeakMap,R=new WeakMap,m=new WeakMap,l=new WeakMap,w=new WeakMap,S=new WeakMap,v=new WeakMap,P=new WeakMap,y=new WeakMap,K=new WeakSet,tt=function(){return D(this,null,function*(){const t=e(this,P).filter(a=>a instanceof HTMLElement?a.tagName==="STYLE"||a.tagName==="SCRIPT"||a.tagName==="LINK":!1);try{for(var s=J(t),r,f,h;r=!(f=yield s.next()).done;r=!1){const a=f.value;yield new Promise(d=>{a.onload=()=>{d()}})}}catch(f){h=[f]}finally{try{r&&(f=s.return)&&(yield f.call(s))}finally{if(h)throw h[0]}}})};var U,g,A,j,M;class at{constructor(t,s){n(this,U,void 0);n(this,g,void 0);n(this,A,void 0);n(this,j,void 0);n(this,M,t=>{t.preventDefault(),e(this,U).navigate(e(this,A),e(this,j))});o(this,U,t),o(this,g,s),o(this,A,e(this,g).getAttribute("href")||"/"),o(this,j,e(this,g).getAttribute("data-history-action")||"push"),e(this,g).addEventListener("click",e(this,M)),location.pathname===e(this,A)&&e(this,g).classList.add("current")}destroy(){e(this,g).removeEventListener("click",e(this,M)),e(this,g).classList.remove("current")}}U=new WeakMap,g=new WeakMap,A=new WeakMap,j=new WeakMap,M=new WeakMap;globalThis.URLPattern=rt.URLPattern;var k,q,p,C,x,E,N,B,W,Y,et,z;const O=class O{constructor(t){n(this,Y);n(this,k,null);n(this,q,void 0);n(this,p,[]);n(this,C,null);n(this,x,[]);n(this,E,void 0);n(this,N,null);n(this,B,new ot.Notifier);I(this,"preprocessor");I(this,"postprocessor");n(this,W,nt.debounce(()=>{const t=s=>s.split("/").length;o(this,p,e(this,p).sort((s,r)=>t(s.pattern)-t(r.pattern))),this.navigate(location.pathname.replace(e(this,q),""))},0));n(this,z,t=>{t.state&&this.navigate(t.state,"none")});o(this,q,(t==null?void 0:t.base)||""),O.active=this,_.isBrowser&&(o(this,k,(t==null?void 0:t.rootElement)||document.body),addEventListener("popstate",e(this,z)))}get currentPathname(){return e(this,N)}get candidatePathname(){return e(this,E)}get routes(){return e(this,p)}navigationEvent(t){return e(this,B).subscribe(t)}defineRoute(t,s){const r=new ht(t,s);e(this,p).push(r),e(this,W).call(this)}navigate(t,s="push"){return D(this,null,function*(){var u,V;if(e(this,E)===t||e(this,N)===t)return;O.active=this,o(this,E,t);const r=e(this,p).filter(c=>c.isActive),f=e(this,p).filter(c=>!r.includes(c)&&c.testPathname(t)),h=r.filter(c=>!c.testPathname(t)),a=r.filter(c=>c.testPathname(t));let d=!0;if(this.preprocessor)try{yield new Promise((c,L)=>{var X;(X=this.preprocessor)==null||X.call(this,{pathname:t,resolve:c,reject:L})})}catch(c){c?console.error(c):console.log("Route change canceled"),d=!1}if(d&&e(this,E)===t){o(this,C,a[a.length-1]),h.forEach(L=>{L.close()}),o(this,N,t);try{for(var T=J(f),ut,ft,dt;ut=!(ft=yield T.next()).done;ut=!1){const L=ft.value;yield L.render(((u=e(this,C))==null?void 0:u.outlet)||e(this,k),t),o(this,C,L)}}catch(ft){dt=[ft]}finally{try{ut&&(ft=T.return)&&(yield ft.call(T))}finally{if(dt)throw dt[0]}}const c=e(this,q)+t+location.search;s==="push"?history.pushState(c,"",c):s==="replace"&&history.replaceState(c,"",c),G(this,Y,et).call(this),(V=this.postprocessor)==null||V.call(this,{pathname:t}),e(this,B).notify({pathname:t})}})}};k=new WeakMap,q=new WeakMap,p=new WeakMap,C=new WeakMap,x=new WeakMap,E=new WeakMap,N=new WeakMap,B=new WeakMap,W=new WeakMap,Y=new WeakSet,et=function(){const t=e(this,p).filter(r=>r.isActive),s=Array.from(new Set([...e(this,k).querySelectorAll("a"),...t.map(r=>r.getAnchorElements()).flat()].filter(r=>{var f;return(f=r.getAttribute("href"))==null?void 0:f.startsWith("/")})));e(this,x).forEach(r=>{r.destroy()}),o(this,x,s.map(r=>new at(this,r)))},z=new WeakMap,I(O,"active");let Q=O;exports.Router=Q;
|
package/lib/router/index.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export { Router, type RouterPreprocessorEntry, type RouterPreprocessor, type RouterPostprocessor, type RouterAfterNavigationCallback, type RouterHistoryAction, type RouterParameters, } from './Router';
|
|
2
|
-
export {
|
|
3
|
-
export { type RouteModule } from './Route';
|
|
2
|
+
export { type RouteModule, type RouteParameters, type RouteURLParams, } from './Route';
|