@tanstack/solid-router 1.153.1 → 1.154.1
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/cjs/Transitioner.cjs +8 -1
- package/dist/cjs/Transitioner.cjs.map +1 -1
- package/dist/esm/Transitioner.js +8 -1
- package/dist/esm/Transitioner.js.map +1 -1
- package/dist/source/Transitioner.jsx +8 -1
- package/dist/source/Transitioner.jsx.map +1 -1
- package/package.json +3 -3
- package/src/Transitioner.tsx +12 -1
|
@@ -51,7 +51,14 @@ function Transitioner() {
|
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
Solid__namespace.onMount(() => {
|
|
54
|
-
const unsub = router.history.subscribe(
|
|
54
|
+
const unsub = router.history.subscribe(({
|
|
55
|
+
navigateOpts
|
|
56
|
+
}) => {
|
|
57
|
+
if (navigateOpts?.skipTransitionerLoad) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
router.load();
|
|
61
|
+
});
|
|
55
62
|
const nextLocation = router.buildLocation({
|
|
56
63
|
to: router.latestLocation.pathname,
|
|
57
64
|
search: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\nexport function Transitioner() {\n const router = useRouter()\n let mountLoadForRouter = { router, mounted: false }\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n if (router.isServer) {\n return null\n }\n\n const [isSolidTransitioning, startSolidTransition] = Solid.useTransition()\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = () =>\n isLoading() || isSolidTransitioning() || hasPendingMatches()\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = () => isLoading() || hasPendingMatches()\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void | Promise<void>) => {\n Solid.startTransition(() => {\n startSolidTransition(fn)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n Solid.onMount(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n Solid.onCleanup(() => {\n unsub()\n })\n })\n\n // Try to load the initial location\n Solid.createRenderEffect(() => {\n Solid.untrack(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n })\n\n Solid.createRenderEffect(\n Solid.on(\n [previousIsLoading, isLoading],\n ([previousIsLoading, isLoading]) => {\n if (previousIsLoading.previous && !isLoading) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createComputed(\n Solid.on(\n [isPagePending, previousIsPagePending],\n ([isPagePending, previousIsPagePending]) => {\n // emit onBeforeRouteMount\n if (previousIsPagePending.previous && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createRenderEffect(\n Solid.on(\n [isAnyPending, previousIsAnyPending],\n ([isAnyPending, previousIsAnyPending]) => {\n if (previousIsAnyPending.previous && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n },\n ),\n )\n\n return null\n}\n"],"names":["Transitioner","router","useRouter","mountLoadForRouter","mounted","isLoading","useRouterState","select","isServer","isSolidTransitioning","startSolidTransition","Solid","useTransition","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","isAnyPending","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","onMount","unsub","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","publicHref","commitLocation","replace","onCleanup","createRenderEffect","untrack","window","ssr","tryLoad","err","console","error","on","previous","emit","type","getLocationChangeInfo","createComputed","changeInfo","__store","setState","resolvedLocation","location","hrefChanged","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Transitioner.cjs","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\nimport type { SubscriberArgs } from '@tanstack/history'\n\nexport function Transitioner() {\n const router = useRouter()\n let mountLoadForRouter = { router, mounted: false }\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n if (router.isServer) {\n return null\n }\n\n const [isSolidTransitioning, startSolidTransition] = Solid.useTransition()\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = () =>\n isLoading() || isSolidTransitioning() || hasPendingMatches()\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = () => isLoading() || hasPendingMatches()\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void | Promise<void>) => {\n Solid.startTransition(() => {\n startSolidTransition(fn)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n Solid.onMount(() => {\n const unsub = router.history.subscribe(\n ({ navigateOpts }: SubscriberArgs) => {\n // If commitLocation initiated this navigation, it handles load() itself\n if (navigateOpts?.skipTransitionerLoad) {\n return\n }\n\n // External navigation (pop, direct history.push, etc): call load normally\n router.load()\n },\n )\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n Solid.onCleanup(() => {\n unsub()\n })\n })\n\n // Try to load the initial location\n Solid.createRenderEffect(() => {\n Solid.untrack(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n })\n\n Solid.createRenderEffect(\n Solid.on(\n [previousIsLoading, isLoading],\n ([previousIsLoading, isLoading]) => {\n if (previousIsLoading.previous && !isLoading) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createComputed(\n Solid.on(\n [isPagePending, previousIsPagePending],\n ([isPagePending, previousIsPagePending]) => {\n // emit onBeforeRouteMount\n if (previousIsPagePending.previous && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createRenderEffect(\n Solid.on(\n [isAnyPending, previousIsAnyPending],\n ([isAnyPending, previousIsAnyPending]) => {\n if (previousIsAnyPending.previous && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n },\n ),\n )\n\n return null\n}\n"],"names":["Transitioner","router","useRouter","mountLoadForRouter","mounted","isLoading","useRouterState","select","isServer","isSolidTransitioning","startSolidTransition","Solid","useTransition","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","isAnyPending","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","onMount","unsub","history","subscribe","navigateOpts","skipTransitionerLoad","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","publicHref","commitLocation","replace","onCleanup","createRenderEffect","untrack","window","ssr","tryLoad","err","console","error","on","previous","emit","type","getLocationChangeInfo","createComputed","changeInfo","__store","setState","resolvedLocation","location","hrefChanged","handleHashScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAWO,SAASA,eAAe;AAC7B,QAAMC,SAASC,UAAAA,UAAAA;AACf,MAAIC,qBAAqB;AAAA,IAAEF;AAAAA,IAAQG,SAAS;AAAA,EAAA;AAC5C,QAAMC,YAAYC,eAAAA,eAAe;AAAA,IAC/BC,QAAQA,CAAC;AAAA,MAAEF,WAAAA;AAAAA,IAAAA,MAAgBA;AAAAA,EAAAA,CAC5B;AAED,MAAIJ,OAAOO,UAAU;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,CAACC,sBAAsBC,oBAAoB,IAAIC,iBAAMC,cAAAA;AAG3D,QAAMC,oBAAoBP,eA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O+D,QAAQC,SAAUnD,CAAAA,OAAO;AAAA,QAC9B,GAAGA;AAAAA,QACHI,QAAQ;AAAA,QACRgD,kBAAkBpD,EAAEqD;AAAAA,MAAAA,EACpB;AAEF,UAAIJ,WAAWK,aAAa;AAC1BC,mBAAAA,iBAAiBpE,MAAM;AAAA,MACzB;AAAA,IACF;AAAA,EACF,CACF,CACF;AAEA,SAAO;AACT;;"}
|
package/dist/esm/Transitioner.js
CHANGED
|
@@ -32,7 +32,14 @@ function Transitioner() {
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
Solid.onMount(() => {
|
|
35
|
-
const unsub = router.history.subscribe(
|
|
35
|
+
const unsub = router.history.subscribe(({
|
|
36
|
+
navigateOpts
|
|
37
|
+
}) => {
|
|
38
|
+
if (navigateOpts?.skipTransitionerLoad) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
router.load();
|
|
42
|
+
});
|
|
36
43
|
const nextLocation = router.buildLocation({
|
|
37
44
|
to: router.latestLocation.pathname,
|
|
38
45
|
search: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\n\nexport function Transitioner() {\n const router = useRouter()\n let mountLoadForRouter = { router, mounted: false }\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n if (router.isServer) {\n return null\n }\n\n const [isSolidTransitioning, startSolidTransition] = Solid.useTransition()\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = () =>\n isLoading() || isSolidTransitioning() || hasPendingMatches()\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = () => isLoading() || hasPendingMatches()\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void | Promise<void>) => {\n Solid.startTransition(() => {\n startSolidTransition(fn)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n Solid.onMount(() => {\n const unsub = router.history.subscribe(router.load)\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n Solid.onCleanup(() => {\n unsub()\n })\n })\n\n // Try to load the initial location\n Solid.createRenderEffect(() => {\n Solid.untrack(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n })\n\n Solid.createRenderEffect(\n Solid.on(\n [previousIsLoading, isLoading],\n ([previousIsLoading, isLoading]) => {\n if (previousIsLoading.previous && !isLoading) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createComputed(\n Solid.on(\n [isPagePending, previousIsPagePending],\n ([isPagePending, previousIsPagePending]) => {\n // emit onBeforeRouteMount\n if (previousIsPagePending.previous && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createRenderEffect(\n Solid.on(\n [isAnyPending, previousIsAnyPending],\n ([isAnyPending, previousIsAnyPending]) => {\n if (previousIsAnyPending.previous && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n },\n ),\n )\n\n return null\n}\n"],"names":["Transitioner","router","useRouter","mountLoadForRouter","mounted","isLoading","useRouterState","select","isServer","isSolidTransitioning","startSolidTransition","Solid","useTransition","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","isAnyPending","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","onMount","unsub","history","subscribe","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","publicHref","commitLocation","replace","onCleanup","createRenderEffect","untrack","window","ssr","tryLoad","err","console","error","on","previous","emit","type","getLocationChangeInfo","createComputed","changeInfo","__store","setState","resolvedLocation","location","hrefChanged","handleHashScroll"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"Transitioner.js","sources":["../../src/Transitioner.tsx"],"sourcesContent":["import * as Solid from 'solid-js'\nimport {\n getLocationChangeInfo,\n handleHashScroll,\n trimPathRight,\n} from '@tanstack/router-core'\nimport { useRouter } from './useRouter'\nimport { useRouterState } from './useRouterState'\nimport { usePrevious } from './utils'\nimport type { SubscriberArgs } from '@tanstack/history'\n\nexport function Transitioner() {\n const router = useRouter()\n let mountLoadForRouter = { router, mounted: false }\n const isLoading = useRouterState({\n select: ({ isLoading }) => isLoading,\n })\n\n if (router.isServer) {\n return null\n }\n\n const [isSolidTransitioning, startSolidTransition] = Solid.useTransition()\n\n // Track pending state changes\n const hasPendingMatches = useRouterState({\n select: (s) => s.matches.some((d) => d.status === 'pending'),\n })\n\n const previousIsLoading = usePrevious(isLoading)\n\n const isAnyPending = () =>\n isLoading() || isSolidTransitioning() || hasPendingMatches()\n const previousIsAnyPending = usePrevious(isAnyPending)\n\n const isPagePending = () => isLoading() || hasPendingMatches()\n const previousIsPagePending = usePrevious(isPagePending)\n\n router.startTransition = (fn: () => void | Promise<void>) => {\n Solid.startTransition(() => {\n startSolidTransition(fn)\n })\n }\n\n // Subscribe to location changes\n // and try to load the new location\n Solid.onMount(() => {\n const unsub = router.history.subscribe(\n ({ navigateOpts }: SubscriberArgs) => {\n // If commitLocation initiated this navigation, it handles load() itself\n if (navigateOpts?.skipTransitionerLoad) {\n return\n }\n\n // External navigation (pop, direct history.push, etc): call load normally\n router.load()\n },\n )\n\n const nextLocation = router.buildLocation({\n to: router.latestLocation.pathname,\n search: true,\n params: true,\n hash: true,\n state: true,\n _includeValidateSearch: true,\n })\n\n // Check if the current URL matches the canonical form.\n // Compare publicHref (browser-facing URL) for consistency with\n // the server-side redirect check in router.beforeLoad.\n if (\n trimPathRight(router.latestLocation.publicHref) !==\n trimPathRight(nextLocation.publicHref)\n ) {\n router.commitLocation({ ...nextLocation, replace: true })\n }\n\n Solid.onCleanup(() => {\n unsub()\n })\n })\n\n // Try to load the initial location\n Solid.createRenderEffect(() => {\n Solid.untrack(() => {\n if (\n // if we are hydrating from SSR, loading is triggered in ssr-client\n (typeof window !== 'undefined' && router.ssr) ||\n (mountLoadForRouter.router === router && mountLoadForRouter.mounted)\n ) {\n return\n }\n mountLoadForRouter = { router, mounted: true }\n const tryLoad = async () => {\n try {\n await router.load()\n } catch (err) {\n console.error(err)\n }\n }\n tryLoad()\n })\n })\n\n Solid.createRenderEffect(\n Solid.on(\n [previousIsLoading, isLoading],\n ([previousIsLoading, isLoading]) => {\n if (previousIsLoading.previous && !isLoading) {\n router.emit({\n type: 'onLoad',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createComputed(\n Solid.on(\n [isPagePending, previousIsPagePending],\n ([isPagePending, previousIsPagePending]) => {\n // emit onBeforeRouteMount\n if (previousIsPagePending.previous && !isPagePending) {\n router.emit({\n type: 'onBeforeRouteMount',\n ...getLocationChangeInfo(router.state),\n })\n }\n },\n ),\n )\n\n Solid.createRenderEffect(\n Solid.on(\n [isAnyPending, previousIsAnyPending],\n ([isAnyPending, previousIsAnyPending]) => {\n if (previousIsAnyPending.previous && !isAnyPending) {\n const changeInfo = getLocationChangeInfo(router.state)\n router.emit({\n type: 'onResolved',\n ...changeInfo,\n })\n\n router.__store.setState((s) => ({\n ...s,\n status: 'idle',\n resolvedLocation: s.location,\n }))\n\n if (changeInfo.hrefChanged) {\n handleHashScroll(router)\n }\n }\n },\n ),\n )\n\n return null\n}\n"],"names":["Transitioner","router","useRouter","mountLoadForRouter","mounted","isLoading","useRouterState","select","isServer","isSolidTransitioning","startSolidTransition","Solid","useTransition","hasPendingMatches","s","matches","some","d","status","previousIsLoading","usePrevious","isAnyPending","previousIsAnyPending","isPagePending","previousIsPagePending","startTransition","fn","onMount","unsub","history","subscribe","navigateOpts","skipTransitionerLoad","load","nextLocation","buildLocation","to","latestLocation","pathname","search","params","hash","state","_includeValidateSearch","trimPathRight","publicHref","commitLocation","replace","onCleanup","createRenderEffect","untrack","window","ssr","tryLoad","err","console","error","on","previous","emit","type","getLocationChangeInfo","createComputed","changeInfo","__store","setState","resolvedLocation","location","hrefChanged","handleHashScroll"],"mappings":";;;;;AAWO,SAASA,eAAe;AAC7B,QAAMC,SAASC,UAAAA;AACf,MAAIC,qBAAqB;AAAA,IAAEF;AAAAA,IAAQG,SAAS;AAAA,EAAA;AAC5C,QAAMC,YAAYC,eAAe;AAAA,IAC/BC,QAAQA,CAAC;AAAA,MAAEF,WAAAA;AAAAA,IAAAA,MAAgBA;AAAAA,EAAAA,CAC5B;AAED,MAAIJ,OAAOO,UAAU;AACnB,WAAO;AAAA,EACT;AAEA,QAAM,CAACC,sBAAsBC,oBAAoB,IAAIC,MAAMC,cAAAA;AAG3D,QAAMC,oBAAoBP,eAAe;AAAA,IACvCC,QAASO,OAAMA,EAAEC,QAAQC,KAAMC,CAAAA,MAAMA,EAAEC,WAAW,SAAS;AAAA,EAAA,CAC5D;AAED,QAAMC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ACzB;AAAA,IACF;AAAA,EACF,CACF,CACF;AAEA,SAAO;AACT;"}
|
|
@@ -30,7 +30,14 @@ export function Transitioner() {
|
|
|
30
30
|
// Subscribe to location changes
|
|
31
31
|
// and try to load the new location
|
|
32
32
|
Solid.onMount(() => {
|
|
33
|
-
const unsub = router.history.subscribe(
|
|
33
|
+
const unsub = router.history.subscribe(({ navigateOpts }) => {
|
|
34
|
+
// If commitLocation initiated this navigation, it handles load() itself
|
|
35
|
+
if (navigateOpts?.skipTransitionerLoad) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// External navigation (pop, direct history.push, etc): call load normally
|
|
39
|
+
router.load();
|
|
40
|
+
});
|
|
34
41
|
const nextLocation = router.buildLocation({
|
|
35
42
|
to: router.latestLocation.pathname,
|
|
36
43
|
search: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transitioner.jsx","sourceRoot":"","sources":["../../src/Transitioner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"Transitioner.jsx","sourceRoot":"","sources":["../../src/Transitioner.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,UAAU,CAAA;AACjC,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AAG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oBAAoB,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;YACnD,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;YACtD,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,YAAY;gBAClB,GAAG,UAAU;aACd,CAAC,CAAA;YAEF,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC9B,GAAG,CAAC;gBACJ,MAAM,EAAE,MAAM;gBACd,gBAAgB,EAAE,CAAC,CAAC,QAAQ;aAC7B,CAAC,CAAC,CAAA;YAEH,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;gBAC3B,gBAAgB,CAAC,MAAM,CAAC,CAAA;YAC1B,CAAC;QACH,CAAC;IACH,CAAC,CACF,CACF,CAAA;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/solid-router",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.154.1",
|
|
4
4
|
"description": "Modern and scalable routing for Solid applications",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"isbot": "^5.1.22",
|
|
92
92
|
"tiny-invariant": "^1.3.3",
|
|
93
93
|
"tiny-warning": "^1.0.3",
|
|
94
|
-
"@tanstack/
|
|
95
|
-
"@tanstack/
|
|
94
|
+
"@tanstack/history": "1.153.2",
|
|
95
|
+
"@tanstack/router-core": "1.154.1"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
98
|
"@solidjs/testing-library": "^0.8.10",
|
package/src/Transitioner.tsx
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import { useRouter } from './useRouter'
|
|
8
8
|
import { useRouterState } from './useRouterState'
|
|
9
9
|
import { usePrevious } from './utils'
|
|
10
|
+
import type { SubscriberArgs } from '@tanstack/history'
|
|
10
11
|
|
|
11
12
|
export function Transitioner() {
|
|
12
13
|
const router = useRouter()
|
|
@@ -44,7 +45,17 @@ export function Transitioner() {
|
|
|
44
45
|
// Subscribe to location changes
|
|
45
46
|
// and try to load the new location
|
|
46
47
|
Solid.onMount(() => {
|
|
47
|
-
const unsub = router.history.subscribe(
|
|
48
|
+
const unsub = router.history.subscribe(
|
|
49
|
+
({ navigateOpts }: SubscriberArgs) => {
|
|
50
|
+
// If commitLocation initiated this navigation, it handles load() itself
|
|
51
|
+
if (navigateOpts?.skipTransitionerLoad) {
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// External navigation (pop, direct history.push, etc): call load normally
|
|
56
|
+
router.load()
|
|
57
|
+
},
|
|
58
|
+
)
|
|
48
59
|
|
|
49
60
|
const nextLocation = router.buildLocation({
|
|
50
61
|
to: router.latestLocation.pathname,
|