@tanstack/react-router 0.0.1-beta.267 → 0.0.1-beta.269

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
3
  "author": "Tanner Linsley",
4
- "version": "0.0.1-beta.267",
4
+ "version": "0.0.1-beta.269",
5
5
  "license": "MIT",
6
6
  "repository": "tanstack/router",
7
7
  "homepage": "https://tanstack.com/router",
@@ -44,7 +44,7 @@
44
44
  "@tanstack/store": "^0.1.3",
45
45
  "tiny-invariant": "^1.3.1",
46
46
  "tiny-warning": "^1.0.3",
47
- "@tanstack/history": "0.0.1-beta.267"
47
+ "@tanstack/history": "0.0.1-beta.269"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "rollup --config rollup.config.js"
@@ -2,13 +2,7 @@ import * as React from 'react'
2
2
  import warning from 'tiny-warning'
3
3
  import { useStore } from '@tanstack/react-store'
4
4
  import { Matches } from './Matches'
5
- import {
6
- LinkInfo,
7
- LinkOptions,
8
- NavigateOptions,
9
- ResolveRelativePath,
10
- ToOptions,
11
- } from './link'
5
+ import { NavigateOptions, ResolveRelativePath, ToOptions } from './link'
12
6
  import { ParsedLocation } from './location'
13
7
  import { AnyRoute } from './route'
14
8
  import { RouteById, RoutePaths } from './routeInfo'
@@ -19,7 +13,7 @@ import {
19
13
  RouterOptions,
20
14
  RouterState,
21
15
  } from './router'
22
- import { NoInfer, PickAsRequired, pick, useLayoutEffect } from './utils'
16
+ import { NoInfer, pick, useLayoutEffect } from './utils'
23
17
  import { MatchRouteOptions } from './Matches'
24
18
  import { RouteMatch } from './Matches'
25
19
 
@@ -36,13 +30,6 @@ export interface MatchLocation {
36
30
  from?: string
37
31
  }
38
32
 
39
- export type BuildLinkFn<TRouteTree extends AnyRoute> = <
40
- TFrom extends RoutePaths<TRouteTree> = '/',
41
- TTo extends string = '',
42
- >(
43
- dest: LinkOptions<TRouteTree, TFrom, TTo>,
44
- ) => LinkInfo
45
-
46
33
  export type NavigateFn<TRouteTree extends AnyRoute> = <
47
34
  TFrom extends RoutePaths<TRouteTree> = '/',
48
35
  TTo extends string = '',
package/src/link.tsx CHANGED
@@ -2,7 +2,7 @@ import * as React from 'react'
2
2
  import { useMatch } from './Matches'
3
3
  import { useRouter, useRouterState } from './RouterProvider'
4
4
  import { Trim } from './fileRoute'
5
- import { LocationState, ParsedLocation } from './location'
5
+ import { LocationState } from './location'
6
6
  import { AnyRoute, ReactNode } from './route'
7
7
  import {
8
8
  AllParams,
@@ -24,23 +24,6 @@ import {
24
24
  functionalUpdate,
25
25
  } from './utils'
26
26
 
27
- export type LinkInfo =
28
- | {
29
- type: 'external'
30
- href: string
31
- }
32
- | {
33
- type: 'internal'
34
- next: ParsedLocation
35
- handleFocus: (e: any) => void
36
- handleClick: (e: any) => void
37
- handleEnter: (e: any) => void
38
- handleLeave: (e: any) => void
39
- handleTouchStart: (e: any) => void
40
- isActive: boolean
41
- disabled?: boolean
42
- }
43
-
44
27
  export type CleanPath<T extends string> = T extends `${infer L}//${infer R}`
45
28
  ? CleanPath<`${CleanPath<L>}/${CleanPath<R>}`>
46
29
  : T extends `${infer L}//`
@@ -177,7 +160,6 @@ export type ToSubOptions<
177
160
  // The source route path. This is automatically set when using route-level APIs, but for type-safe relative routing on the router itself, this is required
178
161
  from?: TFrom
179
162
  // // When using relative route paths, this option forces resolution from the current path, instead of the route API's path or `from` path
180
- // fromCurrent?: boolean
181
163
  } & CheckPath<TRouteTree, NoInfer<TResolved>, {}> &
182
164
  SearchParamOptions<TRouteTree, TFrom, TTo, TResolved> &
183
165
  PathParamOptions<TRouteTree, TFrom, TResolved>
package/src/router.ts CHANGED
@@ -30,6 +30,7 @@ import {
30
30
  functionalUpdate,
31
31
  last,
32
32
  pick,
33
+ Timeout,
33
34
  } from './utils'
34
35
  import {
35
36
  ErrorRouteComponent,
@@ -41,7 +42,6 @@ import { ParsedLocation } from './location'
41
42
  import { LocationState } from './location'
42
43
  import { SearchSerializer, SearchParser } from './searchParams'
43
44
  import {
44
- BuildLinkFn,
45
45
  BuildLocationFn,
46
46
  CommitLocationOptions,
47
47
  InjectedHtmlEntry,
@@ -227,7 +227,7 @@ export class Router<
227
227
  Math.random() * 10000000,
228
228
  )}`
229
229
  resetNextScroll: boolean = true
230
- navigateTimeout: NodeJS.Timeout | null = null
230
+ navigateTimeout: Timeout | null = null
231
231
  latestLoadPromise: Promise<void> = Promise.resolve()
232
232
  subscribers = new Set<RouterListener<RouterEvent>>()
233
233
  pendingMatches: AnyRouteMatch[] = []
@@ -1,26 +1,27 @@
1
1
  import * as React from 'react'
2
2
  import { ReactNode } from './route'
3
3
  import { useRouter } from './RouterProvider'
4
+ import { BlockerFn } from '@tanstack/history'
4
5
 
5
6
  export function useBlocker(
6
- message: string,
7
+ blockerFn: BlockerFn,
7
8
  condition: boolean | any = true,
8
9
  ): void {
9
10
  const { history } = useRouter()
10
11
 
11
12
  React.useEffect(() => {
12
13
  if (!condition) return
13
- return history.block(message)
14
+ return history.block(blockerFn)
14
15
  })
15
16
  }
16
17
 
17
- export function Block({ message, condition, children }: PromptProps) {
18
- useBlocker(message, condition)
18
+ export function Block({ blocker, condition, children }: PromptProps) {
19
+ useBlocker(blocker, condition)
19
20
  return (children ?? null) as ReactNode
20
21
  }
21
22
 
22
23
  export type PromptProps = {
23
- message: string
24
+ blocker: BlockerFn
24
25
  condition?: boolean | any
25
26
  children?: ReactNode
26
27
  }
File without changes
package/src/injectHtml.ts DELETED
@@ -1,28 +0,0 @@
1
- // export function useInjectHtml() {
2
- // const { } = useRouter()
3
- // return React.useCallback(
4
- // (html: string | (() => Promise<string> | string)) => {
5
- // router.injectHtml(html)
6
- // },
7
- // [],
8
- // )
9
- // }
10
- // export function useDehydrate() {
11
- // const { } = useRouter()
12
- // return React.useCallback(function dehydrate<T>(
13
- // key: any,
14
- // data: T | (() => Promise<T> | T),
15
- // ) {
16
- // return router.dehydrateData(key, data)
17
- // },
18
- // [])
19
- // }
20
- // export function useHydrate() {
21
- // const { } = useRouter()
22
- // return function hydrate<T = unknown>(key: any) {
23
- // return router.hydrateData(key) as T
24
- // }
25
- // }
26
- // This is the messiest thing ever... I'm either seriously tired (likely) or
27
- // there has to be a better way to reset error boundaries when the
28
- // router's location key changes.