@tanstack/router-core 1.98.0 → 1.98.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.
@@ -31,6 +31,7 @@ exports.decode = qss.decode;
31
31
  exports.encode = qss.encode;
32
32
  exports.rootRouteId = root.rootRouteId;
33
33
  exports.defaultSerializeError = router.defaultSerializeError;
34
+ exports.getLocationChangeInfo = router.getLocationChangeInfo;
34
35
  exports.retainSearchParams = searchMiddleware.retainSearchParams;
35
36
  exports.stripSearchParams = searchMiddleware.stripSearchParams;
36
37
  exports.defaultParseSearch = searchParams.defaultParseSearch;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -13,7 +13,7 @@ export { encode, decode } from './qss.cjs';
13
13
  export { rootRouteId } from './root.cjs';
14
14
  export type { RootRouteId } from './root.cjs';
15
15
  export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ParseSplatParams, SplatParams, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, } from './route.cjs';
16
- export { defaultSerializeError } from './router.cjs';
16
+ export { defaultSerializeError, getLocationChangeInfo } from './router.cjs';
17
17
  export type { ViewTransitionOptions, ExtractedBaseEntry, ExtractedStream, ExtractedPromise, ExtractedEntry, StreamState, TrailingSlashOption, } from './router.cjs';
18
18
  export type { MatchLocation, CommitLocationOptions } from './RouterProvider.cjs';
19
19
  export { retainSearchParams, stripSearchParams } from './searchMiddleware.cjs';
@@ -15,5 +15,14 @@ function defaultSerializeError(err) {
15
15
  data: err
16
16
  };
17
17
  }
18
+ function getLocationChangeInfo(routerState) {
19
+ const fromLocation = routerState.resolvedLocation;
20
+ const toLocation = routerState.location;
21
+ const pathChanged = (fromLocation == null ? void 0 : fromLocation.pathname) !== toLocation.pathname;
22
+ const hrefChanged = (fromLocation == null ? void 0 : fromLocation.href) !== toLocation.href;
23
+ const hashChanged = (fromLocation == null ? void 0 : fromLocation.hash) !== toLocation.hash;
24
+ return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
25
+ }
18
26
  exports.defaultSerializeError = defaultSerializeError;
27
+ exports.getLocationChangeInfo = getLocationChangeInfo;
19
28
  //# sourceMappingURL=router.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.cjs","sources":["../../src/router.ts"],"sourcesContent":["import type { DeferredPromiseState } from './defer'\nimport type { ControlledPromise } from './utils'\n\nexport interface ViewTransitionOptions {\n types: Array<string>\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\nexport interface ExtractedBaseEntry {\n dataType: '__beforeLoadContext' | 'loaderData'\n type: string\n path: Array<string>\n id: number\n matchIndex: number\n}\n\nexport interface ExtractedStream extends ExtractedBaseEntry {\n type: 'stream'\n streamState: StreamState\n}\n\nexport interface ExtractedPromise extends ExtractedBaseEntry {\n type: 'promise'\n promiseState: DeferredPromiseState<any>\n}\n\nexport type ExtractedEntry = ExtractedStream | ExtractedPromise\n\nexport type StreamState = {\n promises: Array<ControlledPromise<string | null>>\n}\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n"],"names":[],"mappings":";;AAOO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IACf;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAAA;AAGrB,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,MAAM;AAAA,EACR;AACF;;"}
1
+ {"version":3,"file":"router.cjs","sources":["../../src/router.ts"],"sourcesContent":["import type { ParsedLocation } from './location'\nimport type { DeferredPromiseState } from './defer'\nimport type { ControlledPromise } from './utils'\n\nexport interface ViewTransitionOptions {\n types: Array<string>\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\nexport interface ExtractedBaseEntry {\n dataType: '__beforeLoadContext' | 'loaderData'\n type: string\n path: Array<string>\n id: number\n matchIndex: number\n}\n\nexport interface ExtractedStream extends ExtractedBaseEntry {\n type: 'stream'\n streamState: StreamState\n}\n\nexport interface ExtractedPromise extends ExtractedBaseEntry {\n type: 'promise'\n promiseState: DeferredPromiseState<any>\n}\n\nexport type ExtractedEntry = ExtractedStream | ExtractedPromise\n\nexport type StreamState = {\n promises: Array<ControlledPromise<string | null>>\n}\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n\nexport function getLocationChangeInfo(routerState: {\n resolvedLocation?: ParsedLocation\n location: ParsedLocation\n}) {\n const fromLocation = routerState.resolvedLocation\n const toLocation = routerState.location\n const pathChanged = fromLocation?.pathname !== toLocation.pathname\n const hrefChanged = fromLocation?.href !== toLocation.href\n const hashChanged = fromLocation?.hash !== toLocation.hash\n return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }\n}\n"],"names":[],"mappings":";;AAQO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IACf;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAAA;AAGrB,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,MAAM;AAAA,EACR;AACF;AA2BO,SAAS,sBAAsB,aAGnC;AACD,QAAM,eAAe,YAAY;AACjC,QAAM,aAAa,YAAY;AACzB,QAAA,eAAc,6CAAc,cAAa,WAAW;AACpD,QAAA,eAAc,6CAAc,UAAS,WAAW;AAChD,QAAA,eAAc,6CAAc,UAAS,WAAW;AACtD,SAAO,EAAE,cAAc,YAAY,aAAa,aAAa,YAAY;AAC3E;;;"}
@@ -1,3 +1,4 @@
1
+ import { ParsedLocation } from './location.cjs';
1
2
  import { DeferredPromiseState } from './defer.cjs';
2
3
  import { ControlledPromise } from './utils.cjs';
3
4
  export interface ViewTransitionOptions {
@@ -29,3 +30,13 @@ export type StreamState = {
29
30
  promises: Array<ControlledPromise<string | null>>;
30
31
  };
31
32
  export type TrailingSlashOption = 'always' | 'never' | 'preserve';
33
+ export declare function getLocationChangeInfo(routerState: {
34
+ resolvedLocation?: ParsedLocation;
35
+ location: ParsedLocation;
36
+ }): {
37
+ fromLocation: ParsedLocation<{}> | undefined;
38
+ toLocation: ParsedLocation<{}>;
39
+ pathChanged: boolean;
40
+ hrefChanged: boolean;
41
+ hashChanged: boolean;
42
+ };
@@ -13,7 +13,7 @@ export { encode, decode } from './qss.js';
13
13
  export { rootRouteId } from './root.js';
14
14
  export type { RootRouteId } from './root.js';
15
15
  export type { AnyPathParams, SearchSchemaInput, AnyContext, RouteContext, PreloadableObj, RoutePathOptions, StaticDataRouteOption, RoutePathOptionsIntersection, SearchFilter, SearchMiddlewareContext, SearchMiddleware, ResolveId, InferFullSearchSchema, InferFullSearchSchemaInput, InferAllParams, InferAllContext, MetaDescriptor, RouteLinkEntry, SearchValidator, AnySearchValidator, DefaultSearchValidator, ErrorRouteProps, ErrorComponentProps, NotFoundRouteProps, ParseSplatParams, SplatParams, ResolveParams, ParseParamsFn, StringifyParamsFn, ParamsOptions, UpdatableStaticRouteOption, LooseReturnType, LooseAsyncReturnType, ContextReturnType, ContextAsyncReturnType, ResolveRouteContext, ResolveLoaderData, RoutePrefix, TrimPath, TrimPathLeft, TrimPathRight, ResolveSearchSchemaFnInput, ResolveSearchSchemaInput, ResolveSearchSchemaFn, ResolveSearchSchema, } from './route.js';
16
- export { defaultSerializeError } from './router.js';
16
+ export { defaultSerializeError, getLocationChangeInfo } from './router.js';
17
17
  export type { ViewTransitionOptions, ExtractedBaseEntry, ExtractedStream, ExtractedPromise, ExtractedEntry, StreamState, TrailingSlashOption, } from './router.js';
18
18
  export type { MatchLocation, CommitLocationOptions } from './RouterProvider.js';
19
19
  export { retainSearchParams, stripSearchParams } from './searchMiddleware.js';
package/dist/esm/index.js CHANGED
@@ -4,7 +4,7 @@ import { isMatch } from "./Matches.js";
4
4
  import { cleanPath, exactPathTest, interpolatePath, joinPaths, matchByPath, matchPathname, parsePathname, removeBasepath, removeTrailingSlash, resolvePath, trimPath, trimPathLeft, trimPathRight } from "./path.js";
5
5
  import { decode, encode } from "./qss.js";
6
6
  import { rootRouteId } from "./root.js";
7
- import { defaultSerializeError } from "./router.js";
7
+ import { defaultSerializeError, getLocationChangeInfo } from "./router.js";
8
8
  import { retainSearchParams, stripSearchParams } from "./searchMiddleware.js";
9
9
  import { defaultParseSearch, defaultStringifySearch, parseSearchWith, stringifySearchWith } from "./searchParams.js";
10
10
  import { createControlledPromise, deepEqual, escapeJSON, functionalUpdate, isPlainArray, isPlainObject, last, pick, replaceEqualDeep, shallow } from "./utils.js";
@@ -22,6 +22,7 @@ export {
22
22
  escapeJSON,
23
23
  exactPathTest,
24
24
  functionalUpdate,
25
+ getLocationChangeInfo,
25
26
  interpolatePath,
26
27
  isMatch,
27
28
  isPlainArray,
@@ -1,3 +1,4 @@
1
+ import { ParsedLocation } from './location.js';
1
2
  import { DeferredPromiseState } from './defer.js';
2
3
  import { ControlledPromise } from './utils.js';
3
4
  export interface ViewTransitionOptions {
@@ -29,3 +30,13 @@ export type StreamState = {
29
30
  promises: Array<ControlledPromise<string | null>>;
30
31
  };
31
32
  export type TrailingSlashOption = 'always' | 'never' | 'preserve';
33
+ export declare function getLocationChangeInfo(routerState: {
34
+ resolvedLocation?: ParsedLocation;
35
+ location: ParsedLocation;
36
+ }): {
37
+ fromLocation: ParsedLocation<{}> | undefined;
38
+ toLocation: ParsedLocation<{}>;
39
+ pathChanged: boolean;
40
+ hrefChanged: boolean;
41
+ hashChanged: boolean;
42
+ };
@@ -13,7 +13,16 @@ function defaultSerializeError(err) {
13
13
  data: err
14
14
  };
15
15
  }
16
+ function getLocationChangeInfo(routerState) {
17
+ const fromLocation = routerState.resolvedLocation;
18
+ const toLocation = routerState.location;
19
+ const pathChanged = (fromLocation == null ? void 0 : fromLocation.pathname) !== toLocation.pathname;
20
+ const hrefChanged = (fromLocation == null ? void 0 : fromLocation.href) !== toLocation.href;
21
+ const hashChanged = (fromLocation == null ? void 0 : fromLocation.hash) !== toLocation.hash;
22
+ return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged };
23
+ }
16
24
  export {
17
- defaultSerializeError
25
+ defaultSerializeError,
26
+ getLocationChangeInfo
18
27
  };
19
28
  //# sourceMappingURL=router.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import type { DeferredPromiseState } from './defer'\nimport type { ControlledPromise } from './utils'\n\nexport interface ViewTransitionOptions {\n types: Array<string>\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\nexport interface ExtractedBaseEntry {\n dataType: '__beforeLoadContext' | 'loaderData'\n type: string\n path: Array<string>\n id: number\n matchIndex: number\n}\n\nexport interface ExtractedStream extends ExtractedBaseEntry {\n type: 'stream'\n streamState: StreamState\n}\n\nexport interface ExtractedPromise extends ExtractedBaseEntry {\n type: 'promise'\n promiseState: DeferredPromiseState<any>\n}\n\nexport type ExtractedEntry = ExtractedStream | ExtractedPromise\n\nexport type StreamState = {\n promises: Array<ControlledPromise<string | null>>\n}\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n"],"names":[],"mappings":"AAOO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IACf;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAAA;AAGrB,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,MAAM;AAAA,EACR;AACF;"}
1
+ {"version":3,"file":"router.js","sources":["../../src/router.ts"],"sourcesContent":["import type { ParsedLocation } from './location'\nimport type { DeferredPromiseState } from './defer'\nimport type { ControlledPromise } from './utils'\n\nexport interface ViewTransitionOptions {\n types: Array<string>\n}\n\nexport function defaultSerializeError(err: unknown) {\n if (err instanceof Error) {\n const obj = {\n name: err.name,\n message: err.message,\n }\n\n if (process.env.NODE_ENV === 'development') {\n ;(obj as any).stack = err.stack\n }\n\n return obj\n }\n\n return {\n data: err,\n }\n}\nexport interface ExtractedBaseEntry {\n dataType: '__beforeLoadContext' | 'loaderData'\n type: string\n path: Array<string>\n id: number\n matchIndex: number\n}\n\nexport interface ExtractedStream extends ExtractedBaseEntry {\n type: 'stream'\n streamState: StreamState\n}\n\nexport interface ExtractedPromise extends ExtractedBaseEntry {\n type: 'promise'\n promiseState: DeferredPromiseState<any>\n}\n\nexport type ExtractedEntry = ExtractedStream | ExtractedPromise\n\nexport type StreamState = {\n promises: Array<ControlledPromise<string | null>>\n}\n\nexport type TrailingSlashOption = 'always' | 'never' | 'preserve'\n\nexport function getLocationChangeInfo(routerState: {\n resolvedLocation?: ParsedLocation\n location: ParsedLocation\n}) {\n const fromLocation = routerState.resolvedLocation\n const toLocation = routerState.location\n const pathChanged = fromLocation?.pathname !== toLocation.pathname\n const hrefChanged = fromLocation?.href !== toLocation.href\n const hashChanged = fromLocation?.hash !== toLocation.hash\n return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }\n}\n"],"names":[],"mappings":"AAQO,SAAS,sBAAsB,KAAc;AAClD,MAAI,eAAe,OAAO;AACxB,UAAM,MAAM;AAAA,MACV,MAAM,IAAI;AAAA,MACV,SAAS,IAAI;AAAA,IACf;AAEI,QAAA,QAAQ,IAAI,aAAa,eAAe;AACxC,UAAY,QAAQ,IAAI;AAAA,IAAA;AAGrB,WAAA;AAAA,EAAA;AAGF,SAAA;AAAA,IACL,MAAM;AAAA,EACR;AACF;AA2BO,SAAS,sBAAsB,aAGnC;AACD,QAAM,eAAe,YAAY;AACjC,QAAM,aAAa,YAAY;AACzB,QAAA,eAAc,6CAAc,cAAa,WAAW;AACpD,QAAA,eAAc,6CAAc,UAAS,WAAW;AAChD,QAAA,eAAc,6CAAc,UAAS,WAAW;AACtD,SAAO,EAAE,cAAc,YAAY,aAAa,aAAa,YAAY;AAC3E;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/router-core",
3
- "version": "1.98.0",
3
+ "version": "1.98.1",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@tanstack/store": "^0.7.0",
48
- "@tanstack/history": "1.98.0"
48
+ "@tanstack/history": "1.98.1"
49
49
  },
50
50
  "scripts": {}
51
51
  }
package/src/index.ts CHANGED
@@ -108,7 +108,7 @@ export type {
108
108
  ResolveSearchSchema,
109
109
  } from './route'
110
110
 
111
- export { defaultSerializeError } from './router'
111
+ export { defaultSerializeError, getLocationChangeInfo } from './router'
112
112
  export type {
113
113
  ViewTransitionOptions,
114
114
  ExtractedBaseEntry,
package/src/router.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ParsedLocation } from './location'
1
2
  import type { DeferredPromiseState } from './defer'
2
3
  import type { ControlledPromise } from './utils'
3
4
 
@@ -48,3 +49,15 @@ export type StreamState = {
48
49
  }
49
50
 
50
51
  export type TrailingSlashOption = 'always' | 'never' | 'preserve'
52
+
53
+ export function getLocationChangeInfo(routerState: {
54
+ resolvedLocation?: ParsedLocation
55
+ location: ParsedLocation
56
+ }) {
57
+ const fromLocation = routerState.resolvedLocation
58
+ const toLocation = routerState.location
59
+ const pathChanged = fromLocation?.pathname !== toLocation.pathname
60
+ const hrefChanged = fromLocation?.href !== toLocation.href
61
+ const hashChanged = fromLocation?.hash !== toLocation.hash
62
+ return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }
63
+ }