@benjavicente/angular-router-experimental 1.142.14 → 1.142.15
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/dist/fesm2022/tanstack-angular-router-experimental-experimental.mjs +57 -58
- package/dist/fesm2022/tanstack-angular-router-experimental.mjs +516 -507
- package/dist/types/tanstack-angular-router-experimental-experimental.d.ts +37 -37
- package/dist/types/tanstack-angular-router-experimental.d.ts +37 -37
- package/package.json +3 -5
- package/src/document/install-unified-document-sync.ts +7 -0
- package/src/document/provide-tanstack-body-managed-tags.ts +3 -0
- package/src/document/provide-tanstack-head-managed-tags.ts +3 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "@tanstack/store";
|
|
2
2
|
import * as e from "@angular/core";
|
|
3
|
-
import { ChangeDetectionStrategy as t,
|
|
4
|
-
import { DOCUMENT as ne } from "@angular/common";
|
|
3
|
+
import { ChangeDetectionStrategy as t, DOCUMENT as n, DestroyRef as r, ElementRef as i, EnvironmentInjector as a, InjectionToken as o, Injector as s, Renderer2 as c, ViewContainerRef as l, afterNextRender as u, assertInInjectionContext as d, computed as f, effect as p, inject as m, input as h, inputBinding as g, isDevMode as _, linkedSignal as ee, runInInjectionContext as te, signal as ne, untracked as v } from "@angular/core";
|
|
5
4
|
var re = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
|
|
6
5
|
function ie(e, t, n = () => ({}), r = 0) {
|
|
7
6
|
if (e === t) return e;
|
|
@@ -293,12 +292,12 @@ function R(t) {
|
|
|
293
292
|
return process.env.NODE_ENV !== "production" && (t?.warn ?? !0) && !n && console.warn("Warning: injectRouter must be used inside a <router-provider> component!"), n;
|
|
294
293
|
}
|
|
295
294
|
function z(e, t) {
|
|
296
|
-
return t || (
|
|
295
|
+
return t || (d(e), m(s));
|
|
297
296
|
}
|
|
298
297
|
function B(e, t = (e) => e, n) {
|
|
299
|
-
return
|
|
300
|
-
let r = typeof e == "function" ? e : () => e, i =
|
|
301
|
-
return
|
|
298
|
+
return te(z(B, n?.injector), () => {
|
|
299
|
+
let r = typeof e == "function" ? e : () => e, i = ee(() => t(r().get()), { equal: n?.compare });
|
|
300
|
+
return p((e) => {
|
|
302
301
|
let { unsubscribe: n } = r().subscribe((e) => {
|
|
303
302
|
i.set(t(e));
|
|
304
303
|
});
|
|
@@ -333,22 +332,22 @@ function pe(t) {
|
|
|
333
332
|
}, { equal: w });
|
|
334
333
|
}
|
|
335
334
|
function U(e) {
|
|
336
|
-
let t =
|
|
337
|
-
|
|
338
|
-
let
|
|
335
|
+
let t = m(l), n = m(s), i = [];
|
|
336
|
+
p(() => {
|
|
337
|
+
let r = e(), a = me(r);
|
|
339
338
|
if (W(i, a)) return;
|
|
340
339
|
i.length > 0 && t.clear(), i = a;
|
|
341
|
-
let
|
|
342
|
-
if (!
|
|
343
|
-
let c =
|
|
340
|
+
let o = r?.component;
|
|
341
|
+
if (!o) return;
|
|
342
|
+
let c = r.providers ?? [], l = s.create({
|
|
344
343
|
providers: c,
|
|
345
|
-
parent:
|
|
346
|
-
}), u = Object.entries(
|
|
347
|
-
t.createComponent(
|
|
344
|
+
parent: n
|
|
345
|
+
}), u = Object.entries(r.inputs ?? {}).map(([e, t]) => g(e, t));
|
|
346
|
+
t.createComponent(o, {
|
|
348
347
|
injector: l,
|
|
349
348
|
bindings: u
|
|
350
349
|
}).changeDetectorRef.markForCheck();
|
|
351
|
-
}),
|
|
350
|
+
}), m(r).onDestroy(() => {
|
|
352
351
|
t.clear();
|
|
353
352
|
});
|
|
354
353
|
}
|
|
@@ -409,7 +408,7 @@ var K = {
|
|
|
409
408
|
subscribe: () => ({ unsubscribe: () => {} })
|
|
410
409
|
}, ve = class t {
|
|
411
410
|
constructor() {
|
|
412
|
-
this.state =
|
|
411
|
+
this.state = m(G), this.message = f(() => {
|
|
413
412
|
let e = this.state.error;
|
|
414
413
|
return e instanceof Error ? e.stack ?? e.message : String(e);
|
|
415
414
|
});
|
|
@@ -434,26 +433,26 @@ var K = {
|
|
|
434
433
|
}
|
|
435
434
|
};
|
|
436
435
|
function ye({ parentRouteIsRoot: e }) {
|
|
437
|
-
let t = R({ warn: !1 }),
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
}),
|
|
436
|
+
let t = R({ warn: !1 }), n = m(a), i = m(r), o = V(t.stores.resolvedLocation, (e) => e?.state?.__TSR_key), s = V(t.stores.loadedAt, (e) => e), c, l = 0;
|
|
437
|
+
i.onDestroy(() => {
|
|
438
|
+
l++;
|
|
439
|
+
}), p(() => {
|
|
441
440
|
if (!e()) return;
|
|
442
441
|
o(), s();
|
|
443
|
-
let
|
|
444
|
-
|
|
445
|
-
if (
|
|
446
|
-
let
|
|
447
|
-
c !== void 0 && c ===
|
|
442
|
+
let r = ++l;
|
|
443
|
+
u({ read: () => {
|
|
444
|
+
if (r !== l || !e() || t.isServer) return;
|
|
445
|
+
let n = t.latestLocation.href;
|
|
446
|
+
c !== void 0 && c === n || (c = n, t.emit({
|
|
448
447
|
type: "onRendered",
|
|
449
448
|
...P(t.stores.location.get(), t.stores.resolvedLocation.get())
|
|
450
449
|
}));
|
|
451
|
-
} }, { injector:
|
|
450
|
+
} }, { injector: n });
|
|
452
451
|
});
|
|
453
452
|
}
|
|
454
453
|
var q = class t {
|
|
455
454
|
constructor() {
|
|
456
|
-
this.matchId =
|
|
455
|
+
this.matchId = h.required(), this.router = R(), this.match = f(() => this.matchSignal()), this.matchSignal = V(() => this.router.stores.matchStores.get(this.matchId()) ?? K, (e) => e), this.matchData = f(() => {
|
|
457
456
|
let e = this.match();
|
|
458
457
|
if (!e) return null;
|
|
459
458
|
let t = e.routeId, n = this.router.routesById[t], r = n.parentRoute?.id ?? null, i = (n.options.remountDeps ?? this.router.options.defaultRemountDeps)?.({
|
|
@@ -468,18 +467,18 @@ var q = class t {
|
|
|
468
467
|
match: e,
|
|
469
468
|
parentRouteId: r
|
|
470
469
|
};
|
|
471
|
-
}), this.isFistRouteInRouteTree =
|
|
470
|
+
}), this.isFistRouteInRouteTree = f(() => this.matchData()?.parentRouteId === N), this.resolvedNoSsr = f(() => {
|
|
472
471
|
let e = this.matchData()?.match;
|
|
473
472
|
return e ? e.ssr === !1 || e.ssr === "data-only" : !0;
|
|
474
|
-
}), this.shouldClientOnly =
|
|
473
|
+
}), this.shouldClientOnly = f(() => {
|
|
475
474
|
let e = this.matchData()?.match;
|
|
476
475
|
return e ? this.resolvedNoSsr() || !!e._displayPending : !0;
|
|
477
|
-
}), this.parentRouteIdSignal =
|
|
476
|
+
}), this.parentRouteIdSignal = f(() => this.matchData()?.parentRouteId ?? ""), this.rootRouteIdSignal = f(() => N), this.hasPendingMatch = f(() => {
|
|
478
477
|
let e = this.matchData()?.route.id;
|
|
479
478
|
return e ? !!this.pendingRouteIds()[e] : !1;
|
|
480
479
|
}), this.pendingRouteIds = V(this.router.stores.pendingRouteIds, (e) => e), this.nearestMatchContext = {
|
|
481
480
|
matchId: this.matchId,
|
|
482
|
-
routeId:
|
|
481
|
+
routeId: f(() => this.matchData()?.route.id),
|
|
483
482
|
match: this.match,
|
|
484
483
|
hasPending: this.hasPendingMatch
|
|
485
484
|
}, this.catchingErrorMatch = _e({ matchId: this.matchId }), this.render = U(() => {
|
|
@@ -527,7 +526,7 @@ var q = class t {
|
|
|
527
526
|
}]
|
|
528
527
|
};
|
|
529
528
|
}
|
|
530
|
-
}), this.onRendered = ye({ parentRouteIsRoot:
|
|
529
|
+
}), this.onRendered = ye({ parentRouteIsRoot: f(() => this.parentRouteIdSignal() === N) });
|
|
531
530
|
}
|
|
532
531
|
static {
|
|
533
532
|
this.ɵfac = function(e) {
|
|
@@ -556,10 +555,10 @@ var q = class t {
|
|
|
556
555
|
}
|
|
557
556
|
}, J = class t {
|
|
558
557
|
constructor() {
|
|
559
|
-
this.router = R(), this.nearestMatch =
|
|
558
|
+
this.router = R(), this.nearestMatch = m(F), this.currentMatch = V(() => {
|
|
560
559
|
let e = this.nearestMatch.matchId();
|
|
561
560
|
return e ? this.router.stores.matchStores.get(e) ?? K : K;
|
|
562
|
-
}, (e) => e), this.routeId =
|
|
561
|
+
}, (e) => e), this.routeId = f(() => this.currentMatch()?.routeId), this.route = f(() => this.router.routesById[this.routeId()]), this.parentGlobalNotFound = f(() => this.currentMatch()?.globalNotFound ?? !1), this.childMatchIdByRouteId = V(this.router.stores.childMatchIdByRouteId, (e) => e), this.childMatchId = f(() => {
|
|
563
562
|
let e = this.routeId();
|
|
564
563
|
return e ? this.childMatchIdByRouteId()[e] ?? null : null;
|
|
565
564
|
}), this.render = U(() => this.parentGlobalNotFound() ? { component: X(this.router, this.route()) } : this.childMatchId() ? {
|
|
@@ -592,18 +591,18 @@ function Y(e) {
|
|
|
592
591
|
return typeof e == "function" ? e() : e;
|
|
593
592
|
}
|
|
594
593
|
function X(e, t) {
|
|
595
|
-
return (Y(t.options.notFoundComponent) ?? Y(e.options.defaultNotFoundComponent)) || (
|
|
594
|
+
return (Y(t.options.notFoundComponent) ?? Y(e.options.defaultNotFoundComponent)) || (_() && !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>)`), he);
|
|
596
595
|
}
|
|
597
596
|
function be(e, t) {
|
|
598
|
-
return (Y(t.options.errorComponent) ?? Y(e.options.defaultErrorComponent)) || (
|
|
597
|
+
return (Y(t.options.errorComponent) ?? Y(e.options.defaultErrorComponent)) || (_() && !t.options.errorComponent && console.warn(`An error was encountered on the route with ID "${t.id}", but an errorComponent option was not configured, nor was a router level defaultErrorComponent configured. Consider configuring at least one of these to avoid TanStack Router's generic defaultErrorComponent.`), ve);
|
|
599
598
|
}
|
|
600
599
|
function xe(e) {
|
|
601
600
|
return null;
|
|
602
601
|
}
|
|
603
602
|
var Z = "data-tsr-scroll-restoration-inline";
|
|
604
603
|
function Se() {
|
|
605
|
-
let e = R(), t =
|
|
606
|
-
e.isServer &&
|
|
604
|
+
let e = R(), t = m(n), r = m(a);
|
|
605
|
+
e.isServer && u(() => {
|
|
607
606
|
let n = e.options.scrollRestoration;
|
|
608
607
|
if (!n || typeof n == "function" && !n({ location: e.latestLocation }) || t.querySelector(`script[${Z}]`)) return;
|
|
609
608
|
let r = xe(e);
|
|
@@ -612,7 +611,7 @@ function Se() {
|
|
|
612
611
|
i.setAttribute(Z, ""), i.className = "$tsr", i.text = `${r};document.currentScript.remove()`;
|
|
613
612
|
let a = e.options.ssr?.nonce;
|
|
614
613
|
a && i.setAttribute("nonce", a), (t.head ?? t.body).appendChild(i);
|
|
615
|
-
}, { injector:
|
|
614
|
+
}, { injector: r });
|
|
616
615
|
}
|
|
617
616
|
var Q = {
|
|
618
617
|
router: null,
|
|
@@ -724,21 +723,21 @@ var we = class t {
|
|
|
724
723
|
encapsulation: 2
|
|
725
724
|
});
|
|
726
725
|
}
|
|
727
|
-
}, Te = /* @__PURE__ */ new
|
|
726
|
+
}, Te = /* @__PURE__ */ new o("CONTEXT", {
|
|
728
727
|
providedIn: "root",
|
|
729
728
|
factory: () => ({})
|
|
730
|
-
}), Ee = /* @__PURE__ */ new
|
|
729
|
+
}), Ee = /* @__PURE__ */ new o("OPTIONS", {
|
|
731
730
|
providedIn: "root",
|
|
732
731
|
factory: () => ({})
|
|
733
732
|
});
|
|
734
733
|
(class t {
|
|
735
734
|
constructor() {
|
|
736
|
-
this.injectedContext =
|
|
735
|
+
this.injectedContext = m(Te), this.injectedOptions = m(Ee), this.injectedRouter = m(L(), { optional: !0 }), this.context = h(this.injectedContext), this.options = h(this.injectedOptions), this.routerInput = h(void 0, { alias: "router" }), this.router = f(() => {
|
|
737
736
|
let e = this.routerInput();
|
|
738
737
|
if (e) return e;
|
|
739
738
|
if (this.injectedRouter) return this.injectedRouter;
|
|
740
739
|
throw Error("No router provided to <router-provider>. Provide a router with provideTanstackRouter or the router input");
|
|
741
|
-
}), this.updateRouter =
|
|
740
|
+
}), this.updateRouter = p(() => {
|
|
742
741
|
let e = this.router(), t = this.context(), n = this.options();
|
|
743
742
|
e.update({
|
|
744
743
|
...e.options,
|
|
@@ -806,32 +805,32 @@ function Oe(t, n, r) {
|
|
|
806
805
|
}
|
|
807
806
|
(class t {
|
|
808
807
|
constructor() {
|
|
809
|
-
this.passiveEvents = Ae(() => ({ touchstart: this.handleTouchStart })), this.options =
|
|
808
|
+
this.passiveEvents = Ae(() => ({ touchstart: this.handleTouchStart })), this.options = h.required({ alias: "link" }), this.router = R(), this.isTransitioning = ne(!1), this.from = f(() => v(() => this.options().from)), this.disabled = f(() => this._options().disabled ?? !1), this.target = f(() => this._options().target), this._options = f(() => ({
|
|
810
809
|
...this.options(),
|
|
811
810
|
from: this.from()
|
|
812
|
-
})), this.nextLocation =
|
|
811
|
+
})), this.nextLocation = f(() => {
|
|
813
812
|
let e = this.location();
|
|
814
813
|
return this.router.buildLocation({
|
|
815
814
|
_fromLocation: e,
|
|
816
815
|
...this._options()
|
|
817
816
|
});
|
|
818
|
-
}), this.hrefOption =
|
|
817
|
+
}), this.hrefOption = f(() => {
|
|
819
818
|
if (this._options().disabled) return;
|
|
820
819
|
let e = this.nextLocation().maskedLocation ?? this.nextLocation(), t = e.external;
|
|
821
820
|
return {
|
|
822
821
|
href: t ? e.publicHref : this.router.history.createHref(e.publicHref) || "/",
|
|
823
822
|
external: t
|
|
824
823
|
};
|
|
825
|
-
}), this.externalLink =
|
|
824
|
+
}), this.externalLink = f(() => {
|
|
826
825
|
let e = this.hrefOption();
|
|
827
826
|
if (e?.external) return e.href;
|
|
828
827
|
try {
|
|
829
828
|
return new URL(this.options().to), this.options().to;
|
|
830
829
|
} catch {}
|
|
831
|
-
}), this.preload =
|
|
830
|
+
}), this.preload = f(() => this.options().reloadDocument ? !1 : this.options().preload ?? this.router.options.defaultPreload), this.preloadDelay = f(() => this.options().preloadDelay ?? this.router.options.defaultPreloadDelay ?? 0), this.location = De(), this.isActiveProps = f(() => {
|
|
832
831
|
let e = this.options(), t = this.isActive() ? e.activeProps : e.inactiveProps;
|
|
833
832
|
if (!(!t || typeof t != "object")) return t;
|
|
834
|
-
}), this.isActive =
|
|
833
|
+
}), this.isActive = f(() => {
|
|
835
834
|
if (this.externalLink()) return !1;
|
|
836
835
|
let e = this.options().activeOptions;
|
|
837
836
|
if (e?.exact) {
|
|
@@ -850,7 +849,7 @@ function Oe(t, n, r) {
|
|
|
850
849
|
});
|
|
851
850
|
}, this.preloadViewportIoCallback = (e) => {
|
|
852
851
|
e?.isIntersecting && this.doPreload();
|
|
853
|
-
}, this.viewportPreloader = Oe(this.preloadViewportIoCallback, { rootMargin: "100px" }, () => !!this._options().disabled || this.preload() !== "viewport"), this.hasRenderFetched = !1, this.rendererPreloader =
|
|
852
|
+
}, this.viewportPreloader = Oe(this.preloadViewportIoCallback, { rootMargin: "100px" }, () => !!this._options().disabled || this.preload() !== "viewport"), this.hasRenderFetched = !1, this.rendererPreloader = p(() => {
|
|
854
853
|
this.hasRenderFetched || !this._options().disabled && this.preload() === "render" && (this.doPreload(), this.hasRenderFetched = !0);
|
|
855
854
|
}), this.handleClick = (e) => {
|
|
856
855
|
let t = e.currentTarget.getAttribute("target"), n = this._options().target, r = n === void 0 ? t : n;
|
|
@@ -923,29 +922,29 @@ function ke(e) {
|
|
|
923
922
|
return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
|
|
924
923
|
}
|
|
925
924
|
function Ae(e) {
|
|
926
|
-
let t =
|
|
927
|
-
|
|
925
|
+
let t = m(i).nativeElement, n = m(r), a = m(c), o = [];
|
|
926
|
+
u(() => {
|
|
928
927
|
for (let [n, r] of Object.entries(e())) {
|
|
929
928
|
let e = a.listen(t, n, r, { passive: !0 });
|
|
930
929
|
o.push(e);
|
|
931
930
|
}
|
|
932
|
-
}),
|
|
931
|
+
}), n.onDestroy(() => {
|
|
933
932
|
for (; o.length;) o.pop()?.();
|
|
934
933
|
});
|
|
935
934
|
}
|
|
936
935
|
//#endregion
|
|
937
936
|
//#region experimental/injectRouteErrorHandler.ts
|
|
938
937
|
function je(e) {
|
|
939
|
-
let t = R(),
|
|
940
|
-
return
|
|
938
|
+
let t = R(), n = pe({ from: e.from }), i = !1;
|
|
939
|
+
return m(r).onDestroy(() => {
|
|
941
940
|
i = !0;
|
|
942
941
|
}), { throw: (e) => {
|
|
943
942
|
if (i) {
|
|
944
943
|
console.warn("Attempted to throw error to route after it has been destroyed");
|
|
945
944
|
return;
|
|
946
945
|
}
|
|
947
|
-
let
|
|
948
|
-
t.updateMatch(
|
|
946
|
+
let r = v(n).id;
|
|
947
|
+
t.updateMatch(r, (t) => ({
|
|
949
948
|
...t,
|
|
950
949
|
error: e,
|
|
951
950
|
status: "error",
|