@benjavicente/angular-router-experimental 1.142.11
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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/fesm2022/tanstack-angular-router-experimental-experimental.mjs +920 -0
- package/dist/fesm2022/tanstack-angular-router-experimental.mjs +4131 -0
- package/dist/types/tanstack-angular-router-experimental-experimental.d.ts +110 -0
- package/dist/types/tanstack-angular-router-experimental.d.ts +733 -0
- package/experimental/injectRouteErrorHandler.ts +51 -0
- package/experimental/public_api.ts +8 -0
- package/package.json +98 -0
- package/src/DefaultNotFound.ts +9 -0
- package/src/Link.ts +352 -0
- package/src/Match.ts +338 -0
- package/src/Matches.ts +37 -0
- package/src/RouterProvider.ts +162 -0
- package/src/document/build-match-managed-document.ts +308 -0
- package/src/document/document-dehydration.ts +27 -0
- package/src/document/document-equality.ts +29 -0
- package/src/document/document-router-token.ts +6 -0
- package/src/document/index.ts +33 -0
- package/src/document/install-unified-document-sync.ts +108 -0
- package/src/document/managed-document-types.ts +36 -0
- package/src/document/managed-dom.ts +307 -0
- package/src/document/provide-tanstack-body-managed-tags.ts +78 -0
- package/src/document/provide-tanstack-document-title.ts +59 -0
- package/src/document/provide-tanstack-document.ts +62 -0
- package/src/document/provide-tanstack-head-managed-tags.ts +63 -0
- package/src/fileRoute.ts +232 -0
- package/src/index.ts +173 -0
- package/src/injectBlocker.ts +196 -0
- package/src/injectCanGoBack.ts +11 -0
- package/src/injectErrorState.ts +21 -0
- package/src/injectIntersectionObserver.ts +28 -0
- package/src/injectLoaderData.ts +49 -0
- package/src/injectLoaderDeps.ts +45 -0
- package/src/injectLocation.ts +38 -0
- package/src/injectMatch.ts +122 -0
- package/src/injectMatchRoute.ts +58 -0
- package/src/injectMatches.ts +79 -0
- package/src/injectNavigate.ts +24 -0
- package/src/injectParams.ts +71 -0
- package/src/injectRouteContext.ts +31 -0
- package/src/injectRouter.ts +17 -0
- package/src/injectRouterState.ts +53 -0
- package/src/injectSearch.ts +71 -0
- package/src/injectStore.ts +87 -0
- package/src/matchInjectorToken.ts +23 -0
- package/src/renderer/injectIsCatchingError.ts +40 -0
- package/src/renderer/injectRender.ts +69 -0
- package/src/route.ts +641 -0
- package/src/router.ts +141 -0
- package/src/routerInjectionToken.ts +24 -0
- package/src/routerStores.ts +107 -0
- package/src/ssr-scroll-restoration.ts +48 -0
- package/src/transitioner.ts +255 -0
|
@@ -0,0 +1,920 @@
|
|
|
1
|
+
import * as e from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy as t, DestroyRef as n, ElementRef as r, EnvironmentInjector as i, InjectionToken as a, Injector as o, Renderer2 as s, ViewContainerRef as c, afterNextRender as l, assertInInjectionContext as u, computed as d, effect as f, inject as p, input as m, inputBinding as h, isDevMode as g, linkedSignal as _, signal as ee, untracked as v } from "@angular/core";
|
|
3
|
+
import { DOCUMENT as y } from "@angular/common";
|
|
4
|
+
var b = Object.prototype.hasOwnProperty, x = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
function S(e, t, n = () => ({}), r = 0) {
|
|
6
|
+
if (e === t) return e;
|
|
7
|
+
if (r > 500) return t;
|
|
8
|
+
let i = t, a = E(e) && E(i);
|
|
9
|
+
if (!a && !(w(e) && w(i))) return i;
|
|
10
|
+
let o = a ? e : C(e);
|
|
11
|
+
if (!o) return i;
|
|
12
|
+
let s = a ? i : C(i);
|
|
13
|
+
if (!s) return i;
|
|
14
|
+
let c = o.length, l = s.length, u = a ? Array(l) : n(), d = 0;
|
|
15
|
+
for (let t = 0; t < l; t++) {
|
|
16
|
+
let o = a ? t : s[t], l = e[o], f = i[o];
|
|
17
|
+
if (l === f) {
|
|
18
|
+
u[o] = l, (a ? t < c : b.call(e, o)) && d++;
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (l === null || f === null || typeof l != "object" || typeof f != "object") {
|
|
22
|
+
u[o] = f;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
let p = S(l, f, n, r + 1);
|
|
26
|
+
u[o] = p, p === l && d++;
|
|
27
|
+
}
|
|
28
|
+
return c === l && d === c ? e : u;
|
|
29
|
+
}
|
|
30
|
+
function C(e) {
|
|
31
|
+
let t = Object.getOwnPropertyNames(e);
|
|
32
|
+
for (let n of t) if (!x.call(e, n)) return !1;
|
|
33
|
+
let n = Object.getOwnPropertySymbols(e);
|
|
34
|
+
if (n.length === 0) return t;
|
|
35
|
+
let r = t;
|
|
36
|
+
for (let t of n) {
|
|
37
|
+
if (!x.call(e, t)) return !1;
|
|
38
|
+
r.push(t);
|
|
39
|
+
}
|
|
40
|
+
return r;
|
|
41
|
+
}
|
|
42
|
+
function w(e) {
|
|
43
|
+
if (!T(e)) return !1;
|
|
44
|
+
let t = e.constructor;
|
|
45
|
+
if (t === void 0) return !0;
|
|
46
|
+
let n = t.prototype;
|
|
47
|
+
return !(!T(n) || !n.hasOwnProperty("isPrototypeOf"));
|
|
48
|
+
}
|
|
49
|
+
function T(e) {
|
|
50
|
+
return Object.prototype.toString.call(e) === "[object Object]";
|
|
51
|
+
}
|
|
52
|
+
function E(e) {
|
|
53
|
+
return Array.isArray(e) && e.length === Object.keys(e).length;
|
|
54
|
+
}
|
|
55
|
+
function D(e, t, n) {
|
|
56
|
+
if (e === t) return !0;
|
|
57
|
+
if (typeof e != typeof t) return !1;
|
|
58
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
59
|
+
if (e.length !== t.length) return !1;
|
|
60
|
+
for (let r = 0, i = e.length; r < i; r++) if (!D(e[r], t[r], n)) return !1;
|
|
61
|
+
return !0;
|
|
62
|
+
}
|
|
63
|
+
if (w(e) && w(t)) {
|
|
64
|
+
let r = n?.ignoreUndefined ?? !0;
|
|
65
|
+
if (n?.partial) {
|
|
66
|
+
for (let i in t) if ((!r || t[i] !== void 0) && !D(e[i], t[i], n)) return !1;
|
|
67
|
+
return !0;
|
|
68
|
+
}
|
|
69
|
+
let i = 0;
|
|
70
|
+
if (!r) i = Object.keys(e).length;
|
|
71
|
+
else for (let t in e) e[t] !== void 0 && i++;
|
|
72
|
+
let a = 0;
|
|
73
|
+
for (let o in t) if ((!r || t[o] !== void 0) && (a++, a > i || !D(e[o], t[o], n))) return !1;
|
|
74
|
+
return i === a;
|
|
75
|
+
}
|
|
76
|
+
return !1;
|
|
77
|
+
}
|
|
78
|
+
function te() {
|
|
79
|
+
throw Error("Invariant failed");
|
|
80
|
+
}
|
|
81
|
+
var O = 4, k = 5;
|
|
82
|
+
function A(e) {
|
|
83
|
+
let t = e.indexOf("{");
|
|
84
|
+
if (t === -1) return null;
|
|
85
|
+
let n = e.indexOf("}", t);
|
|
86
|
+
return n === -1 || t + 1 >= e.length ? null : [t, n];
|
|
87
|
+
}
|
|
88
|
+
function ne(e, t, n = new Uint16Array(6)) {
|
|
89
|
+
let r = e.indexOf("/", t), i = r === -1 ? e.length : r, a = e.substring(t, i);
|
|
90
|
+
if (!a || !a.includes("$")) return n[0] = 0, n[1] = t, n[2] = t, n[3] = i, n[4] = i, n[5] = i, n;
|
|
91
|
+
if (a === "$") {
|
|
92
|
+
let r = e.length;
|
|
93
|
+
return n[0] = 2, n[1] = t, n[2] = t, n[3] = r, n[4] = r, n[5] = r, n;
|
|
94
|
+
}
|
|
95
|
+
if (a.charCodeAt(0) === 36) return n[0] = 1, n[1] = t, n[2] = t + 1, n[3] = i, n[4] = i, n[5] = i, n;
|
|
96
|
+
let o = A(a);
|
|
97
|
+
if (o) {
|
|
98
|
+
let [r, s] = o, c = a.charCodeAt(r + 1);
|
|
99
|
+
if (c === 45) {
|
|
100
|
+
if (r + 2 < a.length && a.charCodeAt(r + 2) === 36) {
|
|
101
|
+
let e = r + 3, a = s;
|
|
102
|
+
if (e < a) return n[0] = 3, n[1] = t + r, n[2] = t + e, n[3] = t + a, n[4] = t + s + 1, n[5] = i, n;
|
|
103
|
+
}
|
|
104
|
+
} else if (c === 36) {
|
|
105
|
+
let a = r + 1, o = r + 2;
|
|
106
|
+
return o === s ? (n[0] = 2, n[1] = t + r, n[2] = t + a, n[3] = t + o, n[4] = t + s + 1, n[5] = e.length, n) : (n[0] = 1, n[1] = t + r, n[2] = t + o, n[3] = t + s, n[4] = t + s + 1, n[5] = i, n);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return n[0] = 0, n[1] = t, n[2] = t, n[3] = i, n[4] = i, n[5] = i, n;
|
|
110
|
+
}
|
|
111
|
+
function re(e, t, n, r, i, a, o) {
|
|
112
|
+
o?.(n);
|
|
113
|
+
let s = r;
|
|
114
|
+
{
|
|
115
|
+
let r = n.fullPath ?? n.from, o = r.length, c = n.options?.caseSensitive ?? e, l = !!(n.options?.params?.parse && n.options?.skipRouteOnParseError?.params);
|
|
116
|
+
for (; s < o;) {
|
|
117
|
+
let e = ne(r, s, t), o, u = s, d = e[5];
|
|
118
|
+
switch (s = d + 1, a++, e[0]) {
|
|
119
|
+
case 0: {
|
|
120
|
+
let t = r.substring(e[2], e[3]);
|
|
121
|
+
if (c) {
|
|
122
|
+
let e = i.static?.get(t);
|
|
123
|
+
if (e) o = e;
|
|
124
|
+
else {
|
|
125
|
+
i.static ??= /* @__PURE__ */ new Map();
|
|
126
|
+
let e = N(n.fullPath ?? n.from);
|
|
127
|
+
e.parent = i, e.depth = a, o = e, i.static.set(t, e);
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
let e = t.toLowerCase(), r = i.staticInsensitive?.get(e);
|
|
131
|
+
if (r) o = r;
|
|
132
|
+
else {
|
|
133
|
+
i.staticInsensitive ??= /* @__PURE__ */ new Map();
|
|
134
|
+
let t = N(n.fullPath ?? n.from);
|
|
135
|
+
t.parent = i, t.depth = a, o = t, i.staticInsensitive.set(e, t);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 1: {
|
|
141
|
+
let t = r.substring(u, e[1]), s = r.substring(e[4], d), f = c && !!(t || s), p = t ? f ? t : t.toLowerCase() : void 0, m = s ? f ? s : s.toLowerCase() : void 0, h = !l && i.dynamic?.find((e) => !e.skipOnParamError && e.caseSensitive === f && e.prefix === p && e.suffix === m);
|
|
142
|
+
if (h) o = h;
|
|
143
|
+
else {
|
|
144
|
+
let e = P(1, n.fullPath ?? n.from, f, p, m);
|
|
145
|
+
o = e, e.depth = a, e.parent = i, i.dynamic ??= [], i.dynamic.push(e);
|
|
146
|
+
}
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
case 3: {
|
|
150
|
+
let t = r.substring(u, e[1]), s = r.substring(e[4], d), f = c && !!(t || s), p = t ? f ? t : t.toLowerCase() : void 0, m = s ? f ? s : s.toLowerCase() : void 0, h = !l && i.optional?.find((e) => !e.skipOnParamError && e.caseSensitive === f && e.prefix === p && e.suffix === m);
|
|
151
|
+
if (h) o = h;
|
|
152
|
+
else {
|
|
153
|
+
let e = P(3, n.fullPath ?? n.from, f, p, m);
|
|
154
|
+
o = e, e.parent = i, e.depth = a, i.optional ??= [], i.optional.push(e);
|
|
155
|
+
}
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case 2: {
|
|
159
|
+
let t = r.substring(u, e[1]), s = r.substring(e[4], d), l = c && !!(t || s), f = t ? l ? t : t.toLowerCase() : void 0, p = s ? l ? s : s.toLowerCase() : void 0, m = P(2, n.fullPath ?? n.from, l, f, p);
|
|
160
|
+
o = m, m.parent = i, m.depth = a, i.wildcard ??= [], i.wildcard.push(m);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
i = o;
|
|
164
|
+
}
|
|
165
|
+
if (l && n.children && !n.isRoot && n.id && n.id.charCodeAt(n.id.lastIndexOf("/") + 1) === 95) {
|
|
166
|
+
let e = N(n.fullPath ?? n.from);
|
|
167
|
+
e.kind = k, e.parent = i, a++, e.depth = a, i.pathless ??= [], i.pathless.push(e), i = e;
|
|
168
|
+
}
|
|
169
|
+
let u = (n.path || !n.children) && !n.isRoot;
|
|
170
|
+
if (u && r.endsWith("/")) {
|
|
171
|
+
let e = N(n.fullPath ?? n.from);
|
|
172
|
+
e.kind = O, e.parent = i, a++, e.depth = a, i.index = e, i = e;
|
|
173
|
+
}
|
|
174
|
+
i.parse = n.options?.params?.parse ?? null, i.skipOnParamError = l, i.parsingPriority = n.options?.skipRouteOnParseError?.priority ?? 0, u && !i.route && (i.route = n, i.fullPath = n.fullPath ?? n.from);
|
|
175
|
+
}
|
|
176
|
+
if (n.children) for (let r of n.children) re(e, t, r, s, i, a, o);
|
|
177
|
+
}
|
|
178
|
+
function j(e, t) {
|
|
179
|
+
if (e.skipOnParamError && !t.skipOnParamError) return -1;
|
|
180
|
+
if (!e.skipOnParamError && t.skipOnParamError) return 1;
|
|
181
|
+
if (e.skipOnParamError && t.skipOnParamError && (e.parsingPriority || t.parsingPriority)) return t.parsingPriority - e.parsingPriority;
|
|
182
|
+
if (e.prefix && t.prefix && e.prefix !== t.prefix) {
|
|
183
|
+
if (e.prefix.startsWith(t.prefix)) return -1;
|
|
184
|
+
if (t.prefix.startsWith(e.prefix)) return 1;
|
|
185
|
+
}
|
|
186
|
+
if (e.suffix && t.suffix && e.suffix !== t.suffix) {
|
|
187
|
+
if (e.suffix.endsWith(t.suffix)) return -1;
|
|
188
|
+
if (t.suffix.endsWith(e.suffix)) return 1;
|
|
189
|
+
}
|
|
190
|
+
return e.prefix && !t.prefix ? -1 : !e.prefix && t.prefix ? 1 : e.suffix && !t.suffix ? -1 : !e.suffix && t.suffix ? 1 : e.caseSensitive && !t.caseSensitive ? -1 : !e.caseSensitive && t.caseSensitive ? 1 : 0;
|
|
191
|
+
}
|
|
192
|
+
function M(e) {
|
|
193
|
+
if (e.pathless) for (let t of e.pathless) M(t);
|
|
194
|
+
if (e.static) for (let t of e.static.values()) M(t);
|
|
195
|
+
if (e.staticInsensitive) for (let t of e.staticInsensitive.values()) M(t);
|
|
196
|
+
if (e.dynamic?.length) {
|
|
197
|
+
e.dynamic.sort(j);
|
|
198
|
+
for (let t of e.dynamic) M(t);
|
|
199
|
+
}
|
|
200
|
+
if (e.optional?.length) {
|
|
201
|
+
e.optional.sort(j);
|
|
202
|
+
for (let t of e.optional) M(t);
|
|
203
|
+
}
|
|
204
|
+
if (e.wildcard?.length) {
|
|
205
|
+
e.wildcard.sort(j);
|
|
206
|
+
for (let t of e.wildcard) M(t);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function N(e) {
|
|
210
|
+
return {
|
|
211
|
+
kind: 0,
|
|
212
|
+
depth: 0,
|
|
213
|
+
pathless: null,
|
|
214
|
+
index: null,
|
|
215
|
+
static: null,
|
|
216
|
+
staticInsensitive: null,
|
|
217
|
+
dynamic: null,
|
|
218
|
+
optional: null,
|
|
219
|
+
wildcard: null,
|
|
220
|
+
route: null,
|
|
221
|
+
fullPath: e,
|
|
222
|
+
parent: null,
|
|
223
|
+
parse: null,
|
|
224
|
+
skipOnParamError: !1,
|
|
225
|
+
parsingPriority: 0
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
function P(e, t, n, r, i) {
|
|
229
|
+
return {
|
|
230
|
+
kind: e,
|
|
231
|
+
depth: 0,
|
|
232
|
+
pathless: null,
|
|
233
|
+
index: null,
|
|
234
|
+
static: null,
|
|
235
|
+
staticInsensitive: null,
|
|
236
|
+
dynamic: null,
|
|
237
|
+
optional: null,
|
|
238
|
+
wildcard: null,
|
|
239
|
+
route: null,
|
|
240
|
+
fullPath: t,
|
|
241
|
+
parent: null,
|
|
242
|
+
parse: null,
|
|
243
|
+
skipOnParamError: !1,
|
|
244
|
+
parsingPriority: 0,
|
|
245
|
+
caseSensitive: n,
|
|
246
|
+
prefix: r,
|
|
247
|
+
suffix: i
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function F(e) {
|
|
251
|
+
let t = e.length;
|
|
252
|
+
return t > 1 && e[t - 1] === "/" ? e.replace(/\/{1,}$/, "") : e;
|
|
253
|
+
}
|
|
254
|
+
function I(e, t) {
|
|
255
|
+
return e?.endsWith("/") && e !== "/" && e !== `${t}/` ? e.slice(0, -1) : e;
|
|
256
|
+
}
|
|
257
|
+
function ie(e, t, n) {
|
|
258
|
+
return I(e, n) === I(t, n);
|
|
259
|
+
}
|
|
260
|
+
JSON.parse, JSON.stringify, JSON.parse;
|
|
261
|
+
var L = "__root__";
|
|
262
|
+
function R(e, t) {
|
|
263
|
+
let n = t, r = e;
|
|
264
|
+
return {
|
|
265
|
+
fromLocation: n,
|
|
266
|
+
toLocation: r,
|
|
267
|
+
pathChanged: n?.pathname !== r.pathname,
|
|
268
|
+
hrefChanged: n?.href !== r.href,
|
|
269
|
+
hashChanged: n?.hash !== r.hash
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
Error, Error;
|
|
273
|
+
var ae = "Error preloading route! ☝️";
|
|
274
|
+
function oe(e) {
|
|
275
|
+
if (typeof document < "u" && document.querySelector) {
|
|
276
|
+
let t = e.stores.location.state, n = t.state.__hashScrollIntoViewOptions ?? !0;
|
|
277
|
+
if (n && t.hash !== "") {
|
|
278
|
+
let e = document.getElementById(t.hash);
|
|
279
|
+
e && e.scrollIntoView(n);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
var se = {
|
|
284
|
+
matchId: () => void 0,
|
|
285
|
+
routeId: () => void 0,
|
|
286
|
+
match: () => void 0,
|
|
287
|
+
hasPending: () => !1
|
|
288
|
+
}, z = /* @__PURE__ */ new e.InjectionToken("MATCH_CONTEXT_INJECTOR", {
|
|
289
|
+
providedIn: "root",
|
|
290
|
+
factory: () => se
|
|
291
|
+
}), B = /* @__PURE__ */ new e.InjectionToken("ROUTER");
|
|
292
|
+
function V() {
|
|
293
|
+
return typeof document > "u" ? B : window.__TSR_ROUTER_INJECTION_KEY__ ? window.__TSR_ROUTER_INJECTION_KEY__ : (window.__TSR_ROUTER_INJECTION_KEY__ = B, B);
|
|
294
|
+
}
|
|
295
|
+
function H(t) {
|
|
296
|
+
let n = e.inject(V(), { optional: !0 });
|
|
297
|
+
return process.env.NODE_ENV !== "production" && (t?.warn ?? !0) && !n && console.warn("Warning: injectRouter must be used inside a <router-provider> component!"), n;
|
|
298
|
+
}
|
|
299
|
+
function U(e, t = (e) => e, n = { equal: W }) {
|
|
300
|
+
u(U);
|
|
301
|
+
let r = typeof e == "function" ? e : () => e, i = _(() => t(r().state), n);
|
|
302
|
+
return f(() => {
|
|
303
|
+
i();
|
|
304
|
+
}), i.asReadonly();
|
|
305
|
+
}
|
|
306
|
+
function W(e, t) {
|
|
307
|
+
if (Object.is(e, t)) return !0;
|
|
308
|
+
if (typeof e != "object" || !e || typeof t != "object" || !t) return !1;
|
|
309
|
+
if (e instanceof Map && t instanceof Map) {
|
|
310
|
+
if (e.size !== t.size) return !1;
|
|
311
|
+
for (let [n, r] of e) if (!t.has(n) || !Object.is(r, t.get(n))) return !1;
|
|
312
|
+
return !0;
|
|
313
|
+
}
|
|
314
|
+
if (e instanceof Set && t instanceof Set) {
|
|
315
|
+
if (e.size !== t.size) return !1;
|
|
316
|
+
for (let n of e) if (!t.has(n)) return !1;
|
|
317
|
+
return !0;
|
|
318
|
+
}
|
|
319
|
+
if (e instanceof Date && t instanceof Date) return e.getTime() === t.getTime();
|
|
320
|
+
let n = Object.keys(e);
|
|
321
|
+
if (n.length !== Object.keys(t).length) return !1;
|
|
322
|
+
for (let r of n) if (!Object.prototype.hasOwnProperty.call(t, r) || !Object.is(e[r], t[r])) return !1;
|
|
323
|
+
return !0;
|
|
324
|
+
}
|
|
325
|
+
function G(t) {
|
|
326
|
+
let n = H(), r = t.from ? void 0 : e.inject(z), i = U(n.stores.pendingRouteIds, (e) => e), a = U(n.stores.isTransitioning, (e) => e), o = () => t.from ? n.stores.getMatchStoreByRouteId(t.from).state : r?.match();
|
|
327
|
+
return e.computed(() => {
|
|
328
|
+
let e = o();
|
|
329
|
+
if (e !== void 0) return t.select ? t.select(e) : e;
|
|
330
|
+
if (!(t.from ? i()[t.from] : r?.hasPending() ?? !1) && !a() && (t.shouldThrow ?? !0)) {
|
|
331
|
+
if (process.env.NODE_ENV !== "production") throw Error(`Invariant failed: Could not find ${t.from ? `an active match from "${t.from}"` : "a nearest match!"}`);
|
|
332
|
+
te();
|
|
333
|
+
}
|
|
334
|
+
}, { equal: D });
|
|
335
|
+
}
|
|
336
|
+
function K(e) {
|
|
337
|
+
let t = p(c), r = p(o), i = [];
|
|
338
|
+
f(() => {
|
|
339
|
+
let n = e(), a = ce(n);
|
|
340
|
+
if (le(i, a)) return;
|
|
341
|
+
i.length > 0 && t.clear(), i = a;
|
|
342
|
+
let s = n?.component;
|
|
343
|
+
if (!s) return;
|
|
344
|
+
let c = n.providers ?? [], l = o.create({
|
|
345
|
+
providers: c,
|
|
346
|
+
parent: r
|
|
347
|
+
}), u = Object.entries(n.inputs ?? {}).map(([e, t]) => h(e, t));
|
|
348
|
+
t.createComponent(s, {
|
|
349
|
+
injector: l,
|
|
350
|
+
bindings: u
|
|
351
|
+
}).changeDetectorRef.markForCheck();
|
|
352
|
+
}), p(n).onDestroy(() => {
|
|
353
|
+
t.clear();
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
function ce(e) {
|
|
357
|
+
let t = e?.component;
|
|
358
|
+
return !e || !t ? [] : [t, e.key];
|
|
359
|
+
}
|
|
360
|
+
function le(e, t) {
|
|
361
|
+
if (e.length !== t.length) return !1;
|
|
362
|
+
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
|
|
363
|
+
return !0;
|
|
364
|
+
}
|
|
365
|
+
var ue = class n {
|
|
366
|
+
static {
|
|
367
|
+
this.ɵfac = function(e) {
|
|
368
|
+
return new (e || n)();
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
static {
|
|
372
|
+
this.ɵcmp = /* @__PURE__ */ e.ɵɵdefineComponent({
|
|
373
|
+
type: n,
|
|
374
|
+
selectors: [["tanstack-angular-router-default-no-found"]],
|
|
375
|
+
hostAttrs: [
|
|
376
|
+
2,
|
|
377
|
+
"display",
|
|
378
|
+
"contents"
|
|
379
|
+
],
|
|
380
|
+
decls: 2,
|
|
381
|
+
vars: 0,
|
|
382
|
+
template: function(t, n) {
|
|
383
|
+
t & 1 && (e.ɵɵelementStart(0, "p"), e.ɵɵtext(1, "Not found"), e.ɵɵelementEnd());
|
|
384
|
+
},
|
|
385
|
+
encapsulation: 2,
|
|
386
|
+
changeDetection: t.OnPush
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
}, de = /* @__PURE__ */ new e.InjectionToken("ERROR_STATE_INJECTOR_TOKEN");
|
|
390
|
+
function fe(t) {
|
|
391
|
+
let n = H({ warn: t?.router === void 0 }), r = U((t?.router ?? n).stores.__store, (e) => e);
|
|
392
|
+
return e.computed(() => t?.select ? t.select(r()) : r(), { equal: D });
|
|
393
|
+
}
|
|
394
|
+
function pe({ matchId: t }) {
|
|
395
|
+
let n = H(), r = fe({ select: (e) => e.matches }), i = e.computed(() => r().findIndex((e) => e.id === t()));
|
|
396
|
+
return e.computed(() => {
|
|
397
|
+
if (n.options.defaultErrorComponent != null) return !1;
|
|
398
|
+
let e = i();
|
|
399
|
+
if (e === -1) return !1;
|
|
400
|
+
let t = r();
|
|
401
|
+
for (let r = e + 1; r < t.length; r++) {
|
|
402
|
+
let e = t[r];
|
|
403
|
+
if (n.routesById[e?.routeId].options.errorComponent != null) return !1;
|
|
404
|
+
if (e?.status === "error") return !0;
|
|
405
|
+
}
|
|
406
|
+
return !1;
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
function me({ parentRouteIsRoot: e }) {
|
|
410
|
+
let t = H({ warn: !1 }), r = p(i), a = p(n), o = U(t.stores.resolvedLocation, (e) => e?.state.__TSR_key), s = U(t.stores.loadedAt, (e) => e), c, u = 0;
|
|
411
|
+
a.onDestroy(() => {
|
|
412
|
+
u++;
|
|
413
|
+
}), f(() => {
|
|
414
|
+
if (!e()) return;
|
|
415
|
+
o(), s();
|
|
416
|
+
let n = ++u;
|
|
417
|
+
l({ read: () => {
|
|
418
|
+
if (n !== u || !e() || t.isServer) return;
|
|
419
|
+
let r = t.latestLocation.href;
|
|
420
|
+
c !== void 0 && c === r || (c = r, t.emit({
|
|
421
|
+
type: "onRendered",
|
|
422
|
+
...R(t.stores.location.state, t.stores.resolvedLocation.state)
|
|
423
|
+
}));
|
|
424
|
+
} }, { injector: r });
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
var q = class t {
|
|
428
|
+
constructor() {
|
|
429
|
+
this.matchId = m.required(), this.router = H(), this.match = d(() => {
|
|
430
|
+
let e = this.matchId();
|
|
431
|
+
return e ? this.router.stores.activeMatchStoresById.get(e)?.state : void 0;
|
|
432
|
+
}), this.matchData = d(() => {
|
|
433
|
+
let e = this.match();
|
|
434
|
+
if (!e) return null;
|
|
435
|
+
let t = e.routeId, n = this.router.routesById[t], r = n.parentRoute?.id ?? null, i = (n.options.remountDeps ?? this.router.options.defaultRemountDeps)?.({
|
|
436
|
+
routeId: t,
|
|
437
|
+
loaderDeps: e.loaderDeps,
|
|
438
|
+
params: e._strictParams,
|
|
439
|
+
search: e._strictSearch
|
|
440
|
+
});
|
|
441
|
+
return {
|
|
442
|
+
key: i ? JSON.stringify(i) : void 0,
|
|
443
|
+
route: n,
|
|
444
|
+
match: e,
|
|
445
|
+
parentRouteId: r
|
|
446
|
+
};
|
|
447
|
+
}), this.isFistRouteInRouteTree = d(() => this.matchData()?.parentRouteId === L), this.resolvedNoSsr = d(() => {
|
|
448
|
+
let e = this.matchData()?.match;
|
|
449
|
+
return e ? e.ssr === !1 || e.ssr === "data-only" : !0;
|
|
450
|
+
}), this.shouldClientOnly = d(() => {
|
|
451
|
+
let e = this.matchData()?.match;
|
|
452
|
+
return e ? this.resolvedNoSsr() || !!e._displayPending : !0;
|
|
453
|
+
}), this.parentRouteIdSignal = d(() => this.matchData()?.parentRouteId ?? ""), this.rootRouteIdSignal = d(() => L), this.hasPendingMatch = d(() => {
|
|
454
|
+
let e = this.matchData()?.route.id;
|
|
455
|
+
return e ? !!this.pendingRouteIds()[e] : !1;
|
|
456
|
+
}), this.pendingRouteIds = U(this.router.stores.pendingRouteIds, (e) => e), this.nearestMatchContext = {
|
|
457
|
+
matchId: this.matchId,
|
|
458
|
+
routeId: d(() => this.matchData()?.route.id),
|
|
459
|
+
match: this.match,
|
|
460
|
+
hasPending: this.hasPendingMatch
|
|
461
|
+
}, this.isCatchingError = pe({ matchId: this.matchId }), this.render = K(() => {
|
|
462
|
+
let e = this.matchData();
|
|
463
|
+
if (!e || this.shouldClientOnly() && this.router.isServer) return null;
|
|
464
|
+
let { match: t, route: n } = e;
|
|
465
|
+
if (t.status === "notFound") return { component: X(this.router, n) };
|
|
466
|
+
if (t.status === "error" || this.isCatchingError()) return {
|
|
467
|
+
component: (Y(n.options.errorComponent) ?? Y(this.router.options.defaultErrorComponent)) || null,
|
|
468
|
+
providers: [{
|
|
469
|
+
provide: de,
|
|
470
|
+
useValue: {
|
|
471
|
+
error: t.error,
|
|
472
|
+
reset: () => {
|
|
473
|
+
this.router.invalidate();
|
|
474
|
+
},
|
|
475
|
+
info: { componentStack: "" }
|
|
476
|
+
}
|
|
477
|
+
}]
|
|
478
|
+
};
|
|
479
|
+
if (t.status === "redirected" || t.status === "pending") {
|
|
480
|
+
let t = n.isRoot && (Y(n.options.component) ?? Y(this.router.options.defaultComponent));
|
|
481
|
+
return t && t !== J ? {
|
|
482
|
+
key: e.key,
|
|
483
|
+
component: t,
|
|
484
|
+
providers: [{
|
|
485
|
+
provide: z,
|
|
486
|
+
useValue: this.nearestMatchContext
|
|
487
|
+
}]
|
|
488
|
+
} : { component: Y(n.options.pendingComponent) ?? Y(this.router.options.defaultPendingComponent) };
|
|
489
|
+
} else {
|
|
490
|
+
let t = Y(n.options.component) ?? Y(this.router.options.defaultComponent) ?? J;
|
|
491
|
+
return {
|
|
492
|
+
key: e.key,
|
|
493
|
+
component: t,
|
|
494
|
+
providers: [{
|
|
495
|
+
provide: z,
|
|
496
|
+
useValue: this.nearestMatchContext
|
|
497
|
+
}]
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
}), this.onRendered = me({ parentRouteIsRoot: d(() => this.parentRouteIdSignal() === L) });
|
|
501
|
+
}
|
|
502
|
+
static {
|
|
503
|
+
this.ɵfac = function(e) {
|
|
504
|
+
return new (e || t)();
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
static {
|
|
508
|
+
this.ɵcmp = /* @__PURE__ */ e.ɵɵdefineComponent({
|
|
509
|
+
type: t,
|
|
510
|
+
selectors: [["router-match"], [
|
|
511
|
+
"",
|
|
512
|
+
"router-match",
|
|
513
|
+
""
|
|
514
|
+
]],
|
|
515
|
+
hostVars: 1,
|
|
516
|
+
hostBindings: function(t, n) {
|
|
517
|
+
t & 2 && e.ɵɵattribute("data-matchId", n.matchId());
|
|
518
|
+
},
|
|
519
|
+
inputs: { matchId: [1, "matchId"] },
|
|
520
|
+
decls: 0,
|
|
521
|
+
vars: 0,
|
|
522
|
+
template: function(e, t) {},
|
|
523
|
+
encapsulation: 2
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}, J = class t {
|
|
527
|
+
constructor() {
|
|
528
|
+
this.router = H(), this.nearestMatch = p(z), this.currentMatch = d(() => {
|
|
529
|
+
let e = this.nearestMatch.matchId();
|
|
530
|
+
return e ? this.router.stores.activeMatchStoresById.get(e)?.state : void 0;
|
|
531
|
+
}), this.routeId = d(() => this.currentMatch()?.routeId), this.route = d(() => this.router.routesById[this.routeId()]), this.parentGlobalNotFound = d(() => this.currentMatch()?.globalNotFound ?? !1), this.childMatchIdByRouteId = U(this.router.stores.childMatchIdByRouteId, (e) => e), this.childMatchId = d(() => {
|
|
532
|
+
let e = this.routeId();
|
|
533
|
+
return e ? this.childMatchIdByRouteId()[e] ?? null : null;
|
|
534
|
+
}), this.render = K(() => this.parentGlobalNotFound() ? { component: X(this.router, this.route()) } : this.childMatchId() ? {
|
|
535
|
+
component: q,
|
|
536
|
+
inputs: { matchId: () => this.childMatchId() }
|
|
537
|
+
} : null);
|
|
538
|
+
}
|
|
539
|
+
static {
|
|
540
|
+
this.ɵfac = function(e) {
|
|
541
|
+
return new (e || t)();
|
|
542
|
+
};
|
|
543
|
+
}
|
|
544
|
+
static {
|
|
545
|
+
this.ɵcmp = /* @__PURE__ */ e.ɵɵdefineComponent({
|
|
546
|
+
type: t,
|
|
547
|
+
selectors: [["outlet"], [
|
|
548
|
+
"",
|
|
549
|
+
"outlet",
|
|
550
|
+
""
|
|
551
|
+
]],
|
|
552
|
+
decls: 0,
|
|
553
|
+
vars: 0,
|
|
554
|
+
template: function(e, t) {},
|
|
555
|
+
encapsulation: 2
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
function Y(e) {
|
|
560
|
+
return typeof e == "function" ? e() : e;
|
|
561
|
+
}
|
|
562
|
+
function X(e, t) {
|
|
563
|
+
return (Y(t.options.notFoundComponent) ?? Y(e.options.defaultNotFoundComponent)) || (g() && !t.options.notFoundComponent && console.warn(`A notFoundError was encountered on the route with ID "${t.id}", but a notFoundComponent option was not configured, nor was a router level defaultNotFoundComponent configured. Consider configuring at least one of these to avoid TanStack Router's overly generic defaultNotFoundComponent (<p>Page not found</p>)`), ue);
|
|
564
|
+
}
|
|
565
|
+
function he(e) {
|
|
566
|
+
return null;
|
|
567
|
+
}
|
|
568
|
+
var Z = "data-tsr-scroll-restoration-inline";
|
|
569
|
+
function ge() {
|
|
570
|
+
let e = H(), t = p(y), n = p(i);
|
|
571
|
+
e.isServer && l(() => {
|
|
572
|
+
let n = e.options.scrollRestoration;
|
|
573
|
+
if (!n || typeof n == "function" && !n({ location: e.latestLocation }) || t.querySelector(`script[${Z}]`)) return;
|
|
574
|
+
let r = he(e);
|
|
575
|
+
if (!r) return;
|
|
576
|
+
let i = t.createElement("script");
|
|
577
|
+
i.setAttribute(Z, ""), i.className = "$tsr", i.text = `${r};document.currentScript.remove()`;
|
|
578
|
+
let a = e.options.ssr?.nonce;
|
|
579
|
+
a && i.setAttribute("nonce", a), (t.head ?? t.body).appendChild(i);
|
|
580
|
+
}, { injector: n });
|
|
581
|
+
}
|
|
582
|
+
var Q = {
|
|
583
|
+
router: null,
|
|
584
|
+
mounted: !1
|
|
585
|
+
};
|
|
586
|
+
function _e() {
|
|
587
|
+
let t = H(), n = e.inject(e.EnvironmentInjector);
|
|
588
|
+
if (t.isServer) return;
|
|
589
|
+
let r = e.inject(e.DestroyRef), i = !1, a = U(t.stores.isLoading, (e) => e), o = U(t.stores.isTransitioning, (e) => e), s = U(t.stores.hasPendingMatches, (e) => e), c = U(t.stores.status, (e) => e), l = U(t.stores.location, (e) => e), u = U(t.stores.resolvedLocation, (e) => e), d = e.computed(() => a() || o() || s()), f = e.computed(() => a() || s()), p = $(() => a()), m = $(() => d()), h = $(() => f());
|
|
590
|
+
t.startTransition = (r) => {
|
|
591
|
+
t.stores.isTransitioning.setState(() => !0);
|
|
592
|
+
let a = () => {
|
|
593
|
+
i || e.afterNextRender({ read: () => {
|
|
594
|
+
try {
|
|
595
|
+
t.stores.isTransitioning.setState(() => !1);
|
|
596
|
+
} catch {}
|
|
597
|
+
} }, { injector: n });
|
|
598
|
+
}, o = r();
|
|
599
|
+
o instanceof Promise ? o.finally(() => a()) : a();
|
|
600
|
+
};
|
|
601
|
+
let g;
|
|
602
|
+
e.afterNextRender(() => {
|
|
603
|
+
g = t.history.subscribe(t.load);
|
|
604
|
+
let e = t.buildLocation({
|
|
605
|
+
to: t.latestLocation.pathname,
|
|
606
|
+
search: !0,
|
|
607
|
+
params: !0,
|
|
608
|
+
hash: !0,
|
|
609
|
+
state: !0,
|
|
610
|
+
_includeValidateSearch: !0
|
|
611
|
+
});
|
|
612
|
+
F(t.latestLocation.href) !== F(e.href) && t.commitLocation({
|
|
613
|
+
...e,
|
|
614
|
+
replace: !0
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
let _ = e.signal(!1);
|
|
618
|
+
e.afterNextRender(() => {
|
|
619
|
+
_.set(!0), d() || c() === "pending" && (t.stores.status.setState(() => "idle"), t.stores.resolvedLocation.setState(() => l()));
|
|
620
|
+
}), r.onDestroy(() => {
|
|
621
|
+
_.set(!1), i = !0, g && g();
|
|
622
|
+
}), e.afterNextRender(() => {
|
|
623
|
+
typeof window < "u" && t.ssr || Q.router === t && Q.mounted || (Q = {
|
|
624
|
+
router: t,
|
|
625
|
+
mounted: !0
|
|
626
|
+
}, (async () => {
|
|
627
|
+
try {
|
|
628
|
+
await t.load();
|
|
629
|
+
} catch (e) {
|
|
630
|
+
console.error(e);
|
|
631
|
+
}
|
|
632
|
+
})());
|
|
633
|
+
}), e.effect(() => {
|
|
634
|
+
if (_()) try {
|
|
635
|
+
p() && !a() && t.emit({
|
|
636
|
+
type: "onLoad",
|
|
637
|
+
...R(l(), u())
|
|
638
|
+
});
|
|
639
|
+
} catch {}
|
|
640
|
+
}), e.effect(() => {
|
|
641
|
+
if (_()) try {
|
|
642
|
+
h() && !f() && t.emit({
|
|
643
|
+
type: "onBeforeRouteMount",
|
|
644
|
+
...R(l(), u())
|
|
645
|
+
});
|
|
646
|
+
} catch {}
|
|
647
|
+
}), e.effect(() => {
|
|
648
|
+
if (_()) try {
|
|
649
|
+
if (m() && !d() && c() === "pending" && (t.stores.status.setState(() => "idle"), t.stores.resolvedLocation.setState(() => l())), m() && !d()) {
|
|
650
|
+
let e = R(l(), u());
|
|
651
|
+
t.emit({
|
|
652
|
+
type: "onResolved",
|
|
653
|
+
...e
|
|
654
|
+
}), e.hrefChanged && oe(t);
|
|
655
|
+
}
|
|
656
|
+
} catch {}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
function $(t) {
|
|
660
|
+
let n = e.computed(t), r = null;
|
|
661
|
+
return e.computed(() => {
|
|
662
|
+
let e = r;
|
|
663
|
+
return r = n(), e;
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
var ve = class t {
|
|
667
|
+
constructor() {
|
|
668
|
+
this.router = H(), this.matchId = U(this.router.stores.firstMatchId, (e) => e), this.ssrScrollRestoration = ge(), this.transitioner = _e(), this.render = K(() => {
|
|
669
|
+
let e = this.matchId();
|
|
670
|
+
return e ? {
|
|
671
|
+
component: q,
|
|
672
|
+
inputs: { matchId: () => e }
|
|
673
|
+
} : null;
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
static {
|
|
677
|
+
this.ɵfac = function(e) {
|
|
678
|
+
return new (e || t)();
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
static {
|
|
682
|
+
this.ɵcmp = /* @__PURE__ */ e.ɵɵdefineComponent({
|
|
683
|
+
type: t,
|
|
684
|
+
selectors: [["router-matches"]],
|
|
685
|
+
decls: 0,
|
|
686
|
+
vars: 0,
|
|
687
|
+
template: function(e, t) {},
|
|
688
|
+
encapsulation: 2
|
|
689
|
+
});
|
|
690
|
+
}
|
|
691
|
+
}, ye = /* @__PURE__ */ new a("CONTEXT", {
|
|
692
|
+
providedIn: "root",
|
|
693
|
+
factory: () => ({})
|
|
694
|
+
}), be = /* @__PURE__ */ new a("OPTIONS", {
|
|
695
|
+
providedIn: "root",
|
|
696
|
+
factory: () => ({})
|
|
697
|
+
});
|
|
698
|
+
(class t {
|
|
699
|
+
constructor() {
|
|
700
|
+
this.injectedContext = p(ye), this.injectedOptions = p(be), this.injectedRouter = p(V(), { optional: !0 }), this.context = m(this.injectedContext), this.options = m(this.injectedOptions), this.routerInput = m(void 0, { alias: "router" }), this.router = d(() => {
|
|
701
|
+
let e = this.routerInput();
|
|
702
|
+
if (e) return e;
|
|
703
|
+
if (this.injectedRouter) return this.injectedRouter;
|
|
704
|
+
throw Error("No router provided to <router-provider>. Provide a router with provideTanstackRouter or the router input");
|
|
705
|
+
}), this.updateRouter = f(() => {
|
|
706
|
+
let e = this.router(), t = this.context(), n = this.options();
|
|
707
|
+
e.update({
|
|
708
|
+
...e.options,
|
|
709
|
+
...n,
|
|
710
|
+
context: {
|
|
711
|
+
...e.options.context,
|
|
712
|
+
...t
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
}), this.render = K(() => {
|
|
716
|
+
let e = v(this.router);
|
|
717
|
+
return {
|
|
718
|
+
component: ve,
|
|
719
|
+
providers: [{
|
|
720
|
+
provide: V(),
|
|
721
|
+
useValue: e
|
|
722
|
+
}]
|
|
723
|
+
};
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
static {
|
|
727
|
+
this.ɵfac = function(e) {
|
|
728
|
+
return new (e || t)();
|
|
729
|
+
};
|
|
730
|
+
}
|
|
731
|
+
static {
|
|
732
|
+
this.ɵcmp = /* @__PURE__ */ e.ɵɵdefineComponent({
|
|
733
|
+
type: t,
|
|
734
|
+
selectors: [["router-provider"], [
|
|
735
|
+
"",
|
|
736
|
+
"router-provider",
|
|
737
|
+
""
|
|
738
|
+
]],
|
|
739
|
+
inputs: {
|
|
740
|
+
context: [1, "context"],
|
|
741
|
+
options: [1, "options"],
|
|
742
|
+
routerInput: [
|
|
743
|
+
1,
|
|
744
|
+
"router",
|
|
745
|
+
"routerInput"
|
|
746
|
+
]
|
|
747
|
+
},
|
|
748
|
+
decls: 0,
|
|
749
|
+
vars: 0,
|
|
750
|
+
template: function(e, t) {},
|
|
751
|
+
encapsulation: 2
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
function xe(e) {
|
|
756
|
+
return U(H().stores.location, (t) => e?.select ? e.select(t) : t, { equal: D });
|
|
757
|
+
}
|
|
758
|
+
function Se(t, n, r) {
|
|
759
|
+
let i = e.inject(e.ElementRef);
|
|
760
|
+
e.afterRenderEffect((e) => {
|
|
761
|
+
let a = typeof IntersectionObserver == "function", o = i.nativeElement;
|
|
762
|
+
if (!o || !a || r()) return;
|
|
763
|
+
let s = new IntersectionObserver(([e]) => t(e), n);
|
|
764
|
+
s.observe(o), e(() => {
|
|
765
|
+
s.disconnect();
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
(class t {
|
|
770
|
+
constructor() {
|
|
771
|
+
this.passiveEvents = we(() => ({ touchstart: this.handleTouchStart })), this.options = m.required({ alias: "link" }), this.router = H(), this.isTransitioning = ee(!1), this.from = d(() => v(() => this.options().from)), this.disabled = d(() => this._options().disabled ?? !1), this.target = d(() => this._options().target), this._options = d(() => ({
|
|
772
|
+
...this.options(),
|
|
773
|
+
from: this.from()
|
|
774
|
+
})), this.nextLocation = d(() => {
|
|
775
|
+
let e = this.location();
|
|
776
|
+
return this.router.buildLocation({
|
|
777
|
+
_fromLocation: e,
|
|
778
|
+
...this._options()
|
|
779
|
+
});
|
|
780
|
+
}), this.hrefOption = d(() => {
|
|
781
|
+
if (this._options().disabled) return;
|
|
782
|
+
let e = this.nextLocation().maskedLocation ?? this.nextLocation(), t = e.external;
|
|
783
|
+
return {
|
|
784
|
+
href: t ? e.publicHref : this.router.history.createHref(e.publicHref) || "/",
|
|
785
|
+
external: t
|
|
786
|
+
};
|
|
787
|
+
}), this.externalLink = d(() => {
|
|
788
|
+
let e = this.hrefOption();
|
|
789
|
+
if (e?.external) return e.href;
|
|
790
|
+
try {
|
|
791
|
+
return new URL(this.options().to), this.options().to;
|
|
792
|
+
} catch {}
|
|
793
|
+
}), this.preload = d(() => this.options().reloadDocument ? !1 : this.options().preload ?? this.router.options.defaultPreload), this.preloadDelay = d(() => this.options().preloadDelay ?? this.router.options.defaultPreloadDelay ?? 0), this.location = xe(), this.isActiveProps = d(() => {
|
|
794
|
+
let e = this.options(), t = this.isActive() ? e.activeProps : e.inactiveProps;
|
|
795
|
+
if (!(!t || typeof t != "object")) return t;
|
|
796
|
+
}), this.isActive = d(() => {
|
|
797
|
+
if (this.externalLink()) return !1;
|
|
798
|
+
let e = this.options().activeOptions;
|
|
799
|
+
if (e?.exact) {
|
|
800
|
+
if (!ie(this.location().pathname, this.nextLocation().pathname, this.router.basepath)) return !1;
|
|
801
|
+
} else {
|
|
802
|
+
let e = I(this.location().pathname, this.router.basepath), t = I(this.nextLocation().pathname, this.router.basepath);
|
|
803
|
+
if (!(e.startsWith(t) && (e.length === t.length || e[t.length] === "/"))) return !1;
|
|
804
|
+
}
|
|
805
|
+
return (e?.includeSearch ?? !0) && !D(this.location().search, this.nextLocation().search, {
|
|
806
|
+
partial: !e?.exact,
|
|
807
|
+
ignoreUndefined: !e?.explicitUndefined
|
|
808
|
+
}) ? !1 : e?.includeHash ? this.location().hash === this.nextLocation().hash : !0;
|
|
809
|
+
}), this.doPreload = () => {
|
|
810
|
+
this.router.preloadRoute(this.options()).catch((e) => {
|
|
811
|
+
console.warn(e), console.warn(ae);
|
|
812
|
+
});
|
|
813
|
+
}, this.preloadViewportIoCallback = (e) => {
|
|
814
|
+
e?.isIntersecting && this.doPreload();
|
|
815
|
+
}, this.viewportPreloader = Se(this.preloadViewportIoCallback, { rootMargin: "100px" }, () => !!this._options().disabled || this.preload() !== "viewport"), this.hasRenderFetched = !1, this.rendererPreloader = f(() => {
|
|
816
|
+
this.hasRenderFetched || !this._options().disabled && this.preload() === "render" && (this.doPreload(), this.hasRenderFetched = !0);
|
|
817
|
+
}), this.handleClick = (e) => {
|
|
818
|
+
let t = e.currentTarget.getAttribute("target"), n = this._options().target, r = n === void 0 ? t : n;
|
|
819
|
+
if (!this._options().disabled && !Ce(e) && !e.defaultPrevented && (!r || r === "_self") && e.button === 0) {
|
|
820
|
+
e.preventDefault(), this.isTransitioning.set(!0);
|
|
821
|
+
let t = this.router.subscribe("onResolved", () => {
|
|
822
|
+
t(), this.isTransitioning.set(!1);
|
|
823
|
+
});
|
|
824
|
+
this.router.navigate(this._options());
|
|
825
|
+
}
|
|
826
|
+
}, this.handleFocus = () => {
|
|
827
|
+
this._options().disabled || this.preload() && this.doPreload();
|
|
828
|
+
}, this.handleTouchStart = () => {
|
|
829
|
+
this._options().disabled || this.preload() && this.doPreload();
|
|
830
|
+
}, this.handleEnter = (e) => {
|
|
831
|
+
if (this._options().disabled) return;
|
|
832
|
+
let t = e.currentTarget || {};
|
|
833
|
+
if (this.preload()) {
|
|
834
|
+
if (t.preloadTimeout) return;
|
|
835
|
+
t.preloadTimeout = setTimeout(() => {
|
|
836
|
+
t.preloadTimeout = null, this.doPreload();
|
|
837
|
+
}, this.preloadDelay());
|
|
838
|
+
}
|
|
839
|
+
}, this.handleLeave = (e) => {
|
|
840
|
+
if (this._options().disabled) return;
|
|
841
|
+
let t = e.currentTarget || {};
|
|
842
|
+
t.preloadTimeout &&= (clearTimeout(t.preloadTimeout), null);
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
static {
|
|
846
|
+
this.ɵfac = function(e) {
|
|
847
|
+
return new (e || t)();
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
static {
|
|
851
|
+
this.ɵdir = /* @__PURE__ */ e.ɵɵdefineDirective({
|
|
852
|
+
type: t,
|
|
853
|
+
selectors: [[
|
|
854
|
+
"a",
|
|
855
|
+
"link",
|
|
856
|
+
""
|
|
857
|
+
]],
|
|
858
|
+
hostVars: 11,
|
|
859
|
+
hostBindings: function(t, n) {
|
|
860
|
+
if (t & 1 && e.ɵɵlistener("click", function(e) {
|
|
861
|
+
return n.handleClick(e);
|
|
862
|
+
})("focus", function() {
|
|
863
|
+
return n.handleFocus();
|
|
864
|
+
})("mouseenter", function(e) {
|
|
865
|
+
return n.handleEnter(e);
|
|
866
|
+
})("mouseover", function(e) {
|
|
867
|
+
return n.handleEnter(e);
|
|
868
|
+
})("mouseleave", function(e) {
|
|
869
|
+
return n.handleLeave(e);
|
|
870
|
+
}), t & 2) {
|
|
871
|
+
let t, r, i;
|
|
872
|
+
e.ɵɵdomProperty("href", (t = n.hrefOption()) == null ? null : t.href), e.ɵɵattribute("target", n.target())("role", n.disabled() ? "link" : void 0)("aria-disabled", n.disabled())("data-status", n.isActive() ? "active" : void 0)("aria-current", n.isActive() ? "page" : void 0)("data-transitioning", n.isTransitioning() ? "transitioning" : void 0), e.ɵɵstyleMap((r = n.isActiveProps()) == null ? null : r.style), e.ɵɵclassMap((i = n.isActiveProps()) == null ? null : i.class);
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
inputs: { options: [
|
|
876
|
+
1,
|
|
877
|
+
"link",
|
|
878
|
+
"options"
|
|
879
|
+
] },
|
|
880
|
+
exportAs: ["link"]
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
function Ce(e) {
|
|
885
|
+
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
886
|
+
}
|
|
887
|
+
function we(e) {
|
|
888
|
+
let t = p(r).nativeElement, i = p(n), a = p(s), o = [];
|
|
889
|
+
l(() => {
|
|
890
|
+
for (let [n, r] of Object.entries(e())) {
|
|
891
|
+
let e = a.listen(t, n, r, { passive: !0 });
|
|
892
|
+
o.push(e);
|
|
893
|
+
}
|
|
894
|
+
}), i.onDestroy(() => {
|
|
895
|
+
for (; o.length;) o.pop()?.();
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
//#endregion
|
|
899
|
+
//#region experimental/injectRouteErrorHandler.ts
|
|
900
|
+
function Te(e) {
|
|
901
|
+
let t = H(), r = G({ from: e.from }), i = !1;
|
|
902
|
+
return p(n).onDestroy(() => {
|
|
903
|
+
i = !0;
|
|
904
|
+
}), { throw: (e) => {
|
|
905
|
+
if (i) {
|
|
906
|
+
console.warn("Attempted to throw error to route after it has been destroyed");
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
let n = v(r).id;
|
|
910
|
+
t.updateMatch(n, (t) => ({
|
|
911
|
+
...t,
|
|
912
|
+
error: e,
|
|
913
|
+
status: "error",
|
|
914
|
+
isFetching: !1,
|
|
915
|
+
updatedAt: Date.now()
|
|
916
|
+
}));
|
|
917
|
+
} };
|
|
918
|
+
}
|
|
919
|
+
//#endregion
|
|
920
|
+
export { Te as injectRouteErrorHandler };
|