@tanstack/router-core 0.0.1-beta.178 → 0.0.1-beta.180
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/build/cjs/router.js +12 -11
- package/build/cjs/router.js.map +1 -1
- package/build/esm/index.js +12 -11
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +124 -124
- package/build/types/router.d.ts +1 -0
- package/build/umd/index.development.js +12 -11
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +1 -1
- package/src/router.ts +15 -9
|
@@ -806,6 +806,7 @@
|
|
|
806
806
|
const componentTypes = ['component', 'errorComponent', 'pendingComponent'];
|
|
807
807
|
const visibilityChangeEvent = 'visibilitychange';
|
|
808
808
|
const focusEvent = 'focus';
|
|
809
|
+
const preloadWarning = 'Error preloading route! ☝️';
|
|
809
810
|
class Router {
|
|
810
811
|
#unsubHistory;
|
|
811
812
|
resetNextScroll = false;
|
|
@@ -1534,14 +1535,14 @@
|
|
|
1534
1535
|
if (preload) {
|
|
1535
1536
|
this.preloadRoute(nextOpts).catch(err => {
|
|
1536
1537
|
console.warn(err);
|
|
1537
|
-
console.warn(
|
|
1538
|
+
console.warn(preloadWarning);
|
|
1538
1539
|
});
|
|
1539
1540
|
}
|
|
1540
1541
|
};
|
|
1541
1542
|
const handleTouchStart = e => {
|
|
1542
1543
|
this.preloadRoute(nextOpts).catch(err => {
|
|
1543
1544
|
console.warn(err);
|
|
1544
|
-
console.warn(
|
|
1545
|
+
console.warn(preloadWarning);
|
|
1545
1546
|
});
|
|
1546
1547
|
};
|
|
1547
1548
|
const handleEnter = e => {
|
|
@@ -1554,7 +1555,7 @@
|
|
|
1554
1555
|
target.preloadTimeout = null;
|
|
1555
1556
|
this.preloadRoute(nextOpts).catch(err => {
|
|
1556
1557
|
console.warn(err);
|
|
1557
|
-
console.warn(
|
|
1558
|
+
console.warn(preloadWarning);
|
|
1558
1559
|
});
|
|
1559
1560
|
}, preloadDelay);
|
|
1560
1561
|
}
|
|
@@ -1581,6 +1582,7 @@
|
|
|
1581
1582
|
dehydrate = () => {
|
|
1582
1583
|
return {
|
|
1583
1584
|
state: {
|
|
1585
|
+
matchIds: this.state.matchIds,
|
|
1584
1586
|
dehydratedMatches: this.state.matches.map(d => pick(d, ['fetchedAt', 'invalid', 'preloadMaxAge', 'maxAge', 'id', 'loaderData', 'status', 'updatedAt']))
|
|
1585
1587
|
}
|
|
1586
1588
|
};
|
|
@@ -1595,11 +1597,9 @@
|
|
|
1595
1597
|
const ctx = _ctx;
|
|
1596
1598
|
this.dehydratedData = ctx.payload;
|
|
1597
1599
|
this.options.hydrate?.(ctx.payload);
|
|
1598
|
-
const
|
|
1599
|
-
dehydratedMatches
|
|
1600
|
-
} = ctx.router.state;
|
|
1600
|
+
const dehydratedState = ctx.router.state;
|
|
1601
1601
|
let matches = this.matchRoutes(this.state.location.pathname, this.state.location.search).map(match => {
|
|
1602
|
-
const dehydratedMatch = dehydratedMatches.find(d => d.id === match.id);
|
|
1602
|
+
const dehydratedMatch = dehydratedState.dehydratedMatches.find(d => d.id === match.id);
|
|
1603
1603
|
invariant(dehydratedMatch, `Could not find a client-side match for dehydrated match with id: ${match.id}!`);
|
|
1604
1604
|
if (dehydratedMatch) {
|
|
1605
1605
|
return {
|
|
@@ -1612,6 +1612,7 @@
|
|
|
1612
1612
|
this.__store.setState(s => {
|
|
1613
1613
|
return {
|
|
1614
1614
|
...s,
|
|
1615
|
+
matchIds: dehydratedState.matchIds,
|
|
1615
1616
|
matches,
|
|
1616
1617
|
matchesById: this.#mergeMatches(s.matchesById, matches)
|
|
1617
1618
|
};
|
|
@@ -1628,10 +1629,10 @@
|
|
|
1628
1629
|
const id = `__TSR_DEHYDRATED__${strKey}`;
|
|
1629
1630
|
const data = typeof getData === 'function' ? await getData() : getData;
|
|
1630
1631
|
return `<script id='${id}' suppressHydrationWarning>window["__TSR_DEHYDRATED__${escapeJSON(strKey)}"] = ${JSON.stringify(data)}
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1632
|
+
;(() => {
|
|
1633
|
+
var el = document.getElementById('${id}')
|
|
1634
|
+
el.parentElement.removeChild(el)
|
|
1635
|
+
})()
|
|
1635
1636
|
</script>`;
|
|
1636
1637
|
});
|
|
1637
1638
|
return () => this.hydrateData(key);
|