typed-next-router 0.0.2 → 0.0.3
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/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -10
- package/dist/index.d.ts +9 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.tsx","../src/Link.tsx","../src/utils.ts","../src/useTypedRouter.ts","../src/useTypedSearchParams.ts"],"sourcesContent":["export { Link } from './Link';\
|
|
1
|
+
{"version":3,"sources":["../src/index.tsx","../src/Link.tsx","../src/utils.ts","../src/useTypedRouter.ts","../src/useTypedSearchParams.ts"],"sourcesContent":["export { Link } from './Link';\nexport type { RouteMapShape, RouteRegistry } from './route-registry';\nexport type {\n\tExtractParams,\n\tPathParams,\n\tPathType,\n\tQueryParamName,\n\tQueryParams,\n\tQueryParamValue,\n\tTypedHref,\n} from './types';\nexport { useTypedRouter } from './useTypedRouter';\nexport { useTypedSearchParams } from './useTypedSearchParams';\nexport { buildHref } from './utils';\n","import type { LinkProps as NextLinkProps } from 'next/link';\nimport NextLink from 'next/link';\nimport type { ComponentProps } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype LinkProps<P extends PathType> = Omit<NextLinkProps, 'href'> &\n\tOmit<ComponentProps<'a'>, 'href'> & {\n\t\thref: TypedHref<P>;\n\t};\n\nfunction Link<P extends PathType>(props: LinkProps<P>) {\n\tconst { href, children, ...rest } = props;\n\n\tconst builtHref = buildHref(href);\n\n\treturn (\n\t\t<NextLink href={builtHref} {...rest}>\n\t\t\t{children}\n\t\t</NextLink>\n\t);\n}\n\nexport { Link };\n","interface Href {\n path: string;\n pathParams?: Record<string, string>;\n queryParams?: Record<string, string>;\n}\n\nexport function buildHref(href: Href): string {\n let url: string = href.path;\n\n if (href.pathParams) {\n Object.entries(href.pathParams).forEach(([key, value]) => {\n url = url.replace(`[${key}]`, value);\n });\n }\n\n if (href.queryParams && Object.keys(href.queryParams).length > 0) {\n const params = new URLSearchParams(href.queryParams);\n url = `${url}?${params.toString()}`;\n }\n\n return url;\n}\n","import type {\n\tAppRouterInstance,\n\tNavigateOptions,\n\tPrefetchOptions,\n} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { useRouter } from 'next/navigation';\nimport { useCallback } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype InternalHref = {\n\tpath: string;\n\tpathParams?: Record<string, string>;\n\tqueryParams?: Record<string, string>;\n};\n\ninterface TypedAppRouterInstance\n\textends Omit<AppRouterInstance, 'push' | 'replace' | 'prefetch'> {\n\tpush: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\treplace: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\tprefetch: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: PrefetchOptions,\n\t) => void;\n}\n\nexport const useTypedRouter = (): TypedAppRouterInstance => {\n\tconst router = useRouter();\n\n\tconst push: TypedAppRouterInstance['push'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.push(builtHref, options);\n\t\t},\n\t\t[router.push],\n\t);\n\n\tconst replace: TypedAppRouterInstance['replace'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.replace(builtHref, options);\n\t\t},\n\t\t[router.replace],\n\t);\n\n\tconst prefetch: TypedAppRouterInstance['prefetch'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.prefetch(builtHref, options);\n\t\t},\n\t\t[router.prefetch],\n\t);\n\n\treturn {\n\t\t...router,\n\t\tpush,\n\t\treplace,\n\t\tprefetch,\n\t};\n};\n","import { useSearchParams } from 'next/navigation';\nimport type { PathType, QueryParamName, QueryParamValue } from './types';\n\ninterface TypedReadonlyURLSearchParams<P extends PathType>\n\textends URLSearchParams {\n\tappend<K extends QueryParamName<P>>(\n\t\tname: QueryParamName<P>,\n\t\tvalue: QueryParamValue<P, K>,\n\t): void;\n\tdelete<K extends QueryParamName<P>>(\n\t\tname: K,\n\t\tvalue?: QueryParamValue<P, K>,\n\t): void;\n\tget<K extends QueryParamName<P>>(\n\t\tname: QueryParamName<P>,\n\t): QueryParamValue<P, K> | null;\n\thas<K extends QueryParamName<P>>(\n\t\tname: K,\n\t\tvalue?: QueryParamValue<P, K>,\n\t): boolean;\n\tset<K extends QueryParamName<P>>(name: K, value: QueryParamValue<P, K>): void;\n}\n\nexport const useTypedSearchParams = <P extends PathType>(\n\tpath: P,\n): TypedReadonlyURLSearchParams<P> => {\n\tconst searchParams = useSearchParams();\n\n\treturn searchParams as TypedReadonlyURLSearchParams<P>;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,kBAAqB;;;ACKd,SAAS,UAAU,MAAoB;AAC1C,MAAI,MAAc,KAAK;AAEvB,MAAI,KAAK,YAAY;AACjB,WAAO,QAAQ,KAAK,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACtD,YAAM,IAAI,QAAQ,IAAI,GAAG,KAAK,KAAK;AAAA,IACvC,CAAC;AAAA,EACL;AAEA,MAAI,KAAK,eAAe,OAAO,KAAK,KAAK,WAAW,EAAE,SAAS,GAAG;AAC9D,UAAM,SAAS,IAAI,gBAAgB,KAAK,WAAW;AACnD,UAAM,GAAG,GAAG,IAAI,OAAO,SAAS,CAAC;AAAA,EACrC;AAEA,SAAO;AACX;;;ADJE;AANF,SAAS,KAAyB,OAAqB;AACtD,QAAM,EAAE,MAAM,UAAU,GAAG,KAAK,IAAI;AAEpC,QAAM,YAAY,UAAU,IAAI;AAEhC,SACC,4CAAC,YAAAA,SAAA,EAAS,MAAM,WAAY,GAAG,MAC7B,UACF;AAEF;;;AEhBA,wBAA0B;AAC1B,mBAA4B;AA0BrB,IAAM,iBAAiB,MAA8B;AAC3D,QAAM,aAAS,6BAAU;AAEzB,QAAM,WAAuC;AAAA,IAC5C,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,KAAK,WAAW,OAAO;AAAA,IAC/B;AAAA,IACA,CAAC,OAAO,IAAI;AAAA,EACb;AAEA,QAAM,cAA6C;AAAA,IAClD,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,QAAQ,WAAW,OAAO;AAAA,IAClC;AAAA,IACA,CAAC,OAAO,OAAO;AAAA,EAChB;AAEA,QAAM,eAA+C;AAAA,IACpD,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,SAAS,WAAW,OAAO;AAAA,IACnC;AAAA,IACA,CAAC,OAAO,QAAQ;AAAA,EACjB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACpEA,IAAAC,qBAAgC;AAuBzB,IAAM,uBAAuB,CACnC,SACqC;AACrC,QAAM,mBAAe,oCAAgB;AAErC,SAAO;AACR;","names":["NextLink","import_navigation"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -10,18 +10,17 @@ interface RouteDefinition {
|
|
|
10
10
|
type RouteMapShape<Path extends string = string> = Record<Path, RouteDefinition>;
|
|
11
11
|
interface RouteRegistry {
|
|
12
12
|
}
|
|
13
|
-
type
|
|
13
|
+
type RegisteredPathType = RouteRegistry extends {
|
|
14
14
|
path: infer P;
|
|
15
15
|
} ? P : never;
|
|
16
|
-
type RegisteredPathType = RegisteredPath extends string ? RegisteredPath : never;
|
|
17
16
|
type AppRouteMap = RouteRegistry extends {
|
|
18
17
|
map: infer M;
|
|
19
|
-
} ? M
|
|
18
|
+
} ? M : never;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Extracts path types from registered map keys and explicit path registration.
|
|
23
22
|
*/
|
|
24
|
-
type PathType =
|
|
23
|
+
type PathType = RegisteredPathType;
|
|
25
24
|
/**
|
|
26
25
|
* Extracts route-specific parameter types from the registered route map.
|
|
27
26
|
*/
|
|
@@ -46,9 +45,6 @@ type QueryParams<P extends PathType> = ExtractParams<P> extends {
|
|
|
46
45
|
[K in keyof QP]: QP[K] extends readonly (infer U)[] ? [U] extends [never] ? string : U : never;
|
|
47
46
|
}>;
|
|
48
47
|
} : object : object;
|
|
49
|
-
type TypedHref<P extends PathType> = {
|
|
50
|
-
path: P;
|
|
51
|
-
} & PathParams<P> & QueryParams<P>;
|
|
52
48
|
type QueryParamName<P extends PathType> = ExtractParams<P> extends {
|
|
53
49
|
queryParams: infer QP;
|
|
54
50
|
} ? keyof QP & string : string;
|
|
@@ -57,6 +53,9 @@ type QueryParamValue<P extends PathType, K extends QueryParamName<P>> = [
|
|
|
57
53
|
] extends [never] ? string : ExtractParams<P> extends {
|
|
58
54
|
queryParams: infer QP;
|
|
59
55
|
} ? K extends keyof QP ? QP[K] extends readonly (infer U)[] ? U | (string & object) : string : string : string;
|
|
56
|
+
type TypedHref<P extends PathType> = {
|
|
57
|
+
path: P;
|
|
58
|
+
} & PathParams<P> & QueryParams<P>;
|
|
60
59
|
|
|
61
60
|
type LinkProps<P extends PathType> = Omit<LinkProps$1, 'href'> & Omit<ComponentProps<'a'>, 'href'> & {
|
|
62
61
|
href: TypedHref<P>;
|
|
@@ -70,14 +69,14 @@ interface TypedAppRouterInstance extends Omit<AppRouterInstance, 'push' | 'repla
|
|
|
70
69
|
}
|
|
71
70
|
declare const useTypedRouter: () => TypedAppRouterInstance;
|
|
72
71
|
|
|
73
|
-
interface
|
|
72
|
+
interface TypedReadonlyURLSearchParams<P extends PathType> extends URLSearchParams {
|
|
74
73
|
append<K extends QueryParamName<P>>(name: QueryParamName<P>, value: QueryParamValue<P, K>): void;
|
|
75
74
|
delete<K extends QueryParamName<P>>(name: K, value?: QueryParamValue<P, K>): void;
|
|
76
|
-
get(name: QueryParamName<P>):
|
|
75
|
+
get<K extends QueryParamName<P>>(name: QueryParamName<P>): QueryParamValue<P, K> | null;
|
|
77
76
|
has<K extends QueryParamName<P>>(name: K, value?: QueryParamValue<P, K>): boolean;
|
|
78
77
|
set<K extends QueryParamName<P>>(name: K, value: QueryParamValue<P, K>): void;
|
|
79
78
|
}
|
|
80
|
-
declare const useTypedSearchParams: <P extends PathType>(path: P) =>
|
|
79
|
+
declare const useTypedSearchParams: <P extends PathType>(path: P) => TypedReadonlyURLSearchParams<P>;
|
|
81
80
|
|
|
82
81
|
interface Href {
|
|
83
82
|
path: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -10,18 +10,17 @@ interface RouteDefinition {
|
|
|
10
10
|
type RouteMapShape<Path extends string = string> = Record<Path, RouteDefinition>;
|
|
11
11
|
interface RouteRegistry {
|
|
12
12
|
}
|
|
13
|
-
type
|
|
13
|
+
type RegisteredPathType = RouteRegistry extends {
|
|
14
14
|
path: infer P;
|
|
15
15
|
} ? P : never;
|
|
16
|
-
type RegisteredPathType = RegisteredPath extends string ? RegisteredPath : never;
|
|
17
16
|
type AppRouteMap = RouteRegistry extends {
|
|
18
17
|
map: infer M;
|
|
19
|
-
} ? M
|
|
18
|
+
} ? M : never;
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Extracts path types from registered map keys and explicit path registration.
|
|
23
22
|
*/
|
|
24
|
-
type PathType =
|
|
23
|
+
type PathType = RegisteredPathType;
|
|
25
24
|
/**
|
|
26
25
|
* Extracts route-specific parameter types from the registered route map.
|
|
27
26
|
*/
|
|
@@ -46,9 +45,6 @@ type QueryParams<P extends PathType> = ExtractParams<P> extends {
|
|
|
46
45
|
[K in keyof QP]: QP[K] extends readonly (infer U)[] ? [U] extends [never] ? string : U : never;
|
|
47
46
|
}>;
|
|
48
47
|
} : object : object;
|
|
49
|
-
type TypedHref<P extends PathType> = {
|
|
50
|
-
path: P;
|
|
51
|
-
} & PathParams<P> & QueryParams<P>;
|
|
52
48
|
type QueryParamName<P extends PathType> = ExtractParams<P> extends {
|
|
53
49
|
queryParams: infer QP;
|
|
54
50
|
} ? keyof QP & string : string;
|
|
@@ -57,6 +53,9 @@ type QueryParamValue<P extends PathType, K extends QueryParamName<P>> = [
|
|
|
57
53
|
] extends [never] ? string : ExtractParams<P> extends {
|
|
58
54
|
queryParams: infer QP;
|
|
59
55
|
} ? K extends keyof QP ? QP[K] extends readonly (infer U)[] ? U | (string & object) : string : string : string;
|
|
56
|
+
type TypedHref<P extends PathType> = {
|
|
57
|
+
path: P;
|
|
58
|
+
} & PathParams<P> & QueryParams<P>;
|
|
60
59
|
|
|
61
60
|
type LinkProps<P extends PathType> = Omit<LinkProps$1, 'href'> & Omit<ComponentProps<'a'>, 'href'> & {
|
|
62
61
|
href: TypedHref<P>;
|
|
@@ -70,14 +69,14 @@ interface TypedAppRouterInstance extends Omit<AppRouterInstance, 'push' | 'repla
|
|
|
70
69
|
}
|
|
71
70
|
declare const useTypedRouter: () => TypedAppRouterInstance;
|
|
72
71
|
|
|
73
|
-
interface
|
|
72
|
+
interface TypedReadonlyURLSearchParams<P extends PathType> extends URLSearchParams {
|
|
74
73
|
append<K extends QueryParamName<P>>(name: QueryParamName<P>, value: QueryParamValue<P, K>): void;
|
|
75
74
|
delete<K extends QueryParamName<P>>(name: K, value?: QueryParamValue<P, K>): void;
|
|
76
|
-
get(name: QueryParamName<P>):
|
|
75
|
+
get<K extends QueryParamName<P>>(name: QueryParamName<P>): QueryParamValue<P, K> | null;
|
|
77
76
|
has<K extends QueryParamName<P>>(name: K, value?: QueryParamValue<P, K>): boolean;
|
|
78
77
|
set<K extends QueryParamName<P>>(name: K, value: QueryParamValue<P, K>): void;
|
|
79
78
|
}
|
|
80
|
-
declare const useTypedSearchParams: <P extends PathType>(path: P) =>
|
|
79
|
+
declare const useTypedSearchParams: <P extends PathType>(path: P) => TypedReadonlyURLSearchParams<P>;
|
|
81
80
|
|
|
82
81
|
interface Href {
|
|
83
82
|
path: string;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Link.tsx","../src/utils.ts","../src/useTypedRouter.ts","../src/useTypedSearchParams.ts"],"sourcesContent":["import type { LinkProps as NextLinkProps } from 'next/link';\nimport NextLink from 'next/link';\nimport type { ComponentProps } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype LinkProps<P extends PathType> = Omit<NextLinkProps, 'href'> &\n\tOmit<ComponentProps<'a'>, 'href'> & {\n\t\thref: TypedHref<P>;\n\t};\n\nfunction Link<P extends PathType>(props: LinkProps<P>) {\n\tconst { href, children, ...rest } = props;\n\n\tconst builtHref = buildHref(href);\n\n\treturn (\n\t\t<NextLink href={builtHref} {...rest}>\n\t\t\t{children}\n\t\t</NextLink>\n\t);\n}\n\nexport { Link };\n","interface Href {\n path: string;\n pathParams?: Record<string, string>;\n queryParams?: Record<string, string>;\n}\n\nexport function buildHref(href: Href): string {\n let url: string = href.path;\n\n if (href.pathParams) {\n Object.entries(href.pathParams).forEach(([key, value]) => {\n url = url.replace(`[${key}]`, value);\n });\n }\n\n if (href.queryParams && Object.keys(href.queryParams).length > 0) {\n const params = new URLSearchParams(href.queryParams);\n url = `${url}?${params.toString()}`;\n }\n\n return url;\n}\n","import type {\n\tAppRouterInstance,\n\tNavigateOptions,\n\tPrefetchOptions,\n} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { useRouter } from 'next/navigation';\nimport { useCallback } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype InternalHref = {\n\tpath: string;\n\tpathParams?: Record<string, string>;\n\tqueryParams?: Record<string, string>;\n};\n\ninterface TypedAppRouterInstance\n\textends Omit<AppRouterInstance, 'push' | 'replace' | 'prefetch'> {\n\tpush: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\treplace: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\tprefetch: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: PrefetchOptions,\n\t) => void;\n}\n\nexport const useTypedRouter = (): TypedAppRouterInstance => {\n\tconst router = useRouter();\n\n\tconst push: TypedAppRouterInstance['push'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.push(builtHref, options);\n\t\t},\n\t\t[router.push],\n\t);\n\n\tconst replace: TypedAppRouterInstance['replace'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.replace(builtHref, options);\n\t\t},\n\t\t[router.replace],\n\t);\n\n\tconst prefetch: TypedAppRouterInstance['prefetch'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.prefetch(builtHref, options);\n\t\t},\n\t\t[router.prefetch],\n\t);\n\n\treturn {\n\t\t...router,\n\t\tpush,\n\t\treplace,\n\t\tprefetch,\n\t};\n};\n","import { useSearchParams } from 'next/navigation';\nimport type { PathType, QueryParamName, QueryParamValue } from './types';\n\ninterface
|
|
1
|
+
{"version":3,"sources":["../src/Link.tsx","../src/utils.ts","../src/useTypedRouter.ts","../src/useTypedSearchParams.ts"],"sourcesContent":["import type { LinkProps as NextLinkProps } from 'next/link';\nimport NextLink from 'next/link';\nimport type { ComponentProps } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype LinkProps<P extends PathType> = Omit<NextLinkProps, 'href'> &\n\tOmit<ComponentProps<'a'>, 'href'> & {\n\t\thref: TypedHref<P>;\n\t};\n\nfunction Link<P extends PathType>(props: LinkProps<P>) {\n\tconst { href, children, ...rest } = props;\n\n\tconst builtHref = buildHref(href);\n\n\treturn (\n\t\t<NextLink href={builtHref} {...rest}>\n\t\t\t{children}\n\t\t</NextLink>\n\t);\n}\n\nexport { Link };\n","interface Href {\n path: string;\n pathParams?: Record<string, string>;\n queryParams?: Record<string, string>;\n}\n\nexport function buildHref(href: Href): string {\n let url: string = href.path;\n\n if (href.pathParams) {\n Object.entries(href.pathParams).forEach(([key, value]) => {\n url = url.replace(`[${key}]`, value);\n });\n }\n\n if (href.queryParams && Object.keys(href.queryParams).length > 0) {\n const params = new URLSearchParams(href.queryParams);\n url = `${url}?${params.toString()}`;\n }\n\n return url;\n}\n","import type {\n\tAppRouterInstance,\n\tNavigateOptions,\n\tPrefetchOptions,\n} from 'next/dist/shared/lib/app-router-context.shared-runtime';\nimport { useRouter } from 'next/navigation';\nimport { useCallback } from 'react';\nimport type { PathType, TypedHref } from './types';\nimport { buildHref } from './utils';\n\ntype InternalHref = {\n\tpath: string;\n\tpathParams?: Record<string, string>;\n\tqueryParams?: Record<string, string>;\n};\n\ninterface TypedAppRouterInstance\n\textends Omit<AppRouterInstance, 'push' | 'replace' | 'prefetch'> {\n\tpush: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\treplace: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: NavigateOptions,\n\t) => void;\n\tprefetch: <P extends PathType>(\n\t\thref: TypedHref<P>,\n\t\toptions?: PrefetchOptions,\n\t) => void;\n}\n\nexport const useTypedRouter = (): TypedAppRouterInstance => {\n\tconst router = useRouter();\n\n\tconst push: TypedAppRouterInstance['push'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.push(builtHref, options);\n\t\t},\n\t\t[router.push],\n\t);\n\n\tconst replace: TypedAppRouterInstance['replace'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.replace(builtHref, options);\n\t\t},\n\t\t[router.replace],\n\t);\n\n\tconst prefetch: TypedAppRouterInstance['prefetch'] = useCallback(\n\t\t(href: InternalHref, options) => {\n\t\t\tconst builtHref = buildHref(href);\n\n\t\t\trouter.prefetch(builtHref, options);\n\t\t},\n\t\t[router.prefetch],\n\t);\n\n\treturn {\n\t\t...router,\n\t\tpush,\n\t\treplace,\n\t\tprefetch,\n\t};\n};\n","import { useSearchParams } from 'next/navigation';\nimport type { PathType, QueryParamName, QueryParamValue } from './types';\n\ninterface TypedReadonlyURLSearchParams<P extends PathType>\n\textends URLSearchParams {\n\tappend<K extends QueryParamName<P>>(\n\t\tname: QueryParamName<P>,\n\t\tvalue: QueryParamValue<P, K>,\n\t): void;\n\tdelete<K extends QueryParamName<P>>(\n\t\tname: K,\n\t\tvalue?: QueryParamValue<P, K>,\n\t): void;\n\tget<K extends QueryParamName<P>>(\n\t\tname: QueryParamName<P>,\n\t): QueryParamValue<P, K> | null;\n\thas<K extends QueryParamName<P>>(\n\t\tname: K,\n\t\tvalue?: QueryParamValue<P, K>,\n\t): boolean;\n\tset<K extends QueryParamName<P>>(name: K, value: QueryParamValue<P, K>): void;\n}\n\nexport const useTypedSearchParams = <P extends PathType>(\n\tpath: P,\n): TypedReadonlyURLSearchParams<P> => {\n\tconst searchParams = useSearchParams();\n\n\treturn searchParams as TypedReadonlyURLSearchParams<P>;\n};\n"],"mappings":";AACA,OAAO,cAAc;;;ACKd,SAAS,UAAU,MAAoB;AAC1C,MAAI,MAAc,KAAK;AAEvB,MAAI,KAAK,YAAY;AACjB,WAAO,QAAQ,KAAK,UAAU,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AACtD,YAAM,IAAI,QAAQ,IAAI,GAAG,KAAK,KAAK;AAAA,IACvC,CAAC;AAAA,EACL;AAEA,MAAI,KAAK,eAAe,OAAO,KAAK,KAAK,WAAW,EAAE,SAAS,GAAG;AAC9D,UAAM,SAAS,IAAI,gBAAgB,KAAK,WAAW;AACnD,UAAM,GAAG,GAAG,IAAI,OAAO,SAAS,CAAC;AAAA,EACrC;AAEA,SAAO;AACX;;;ADJE;AANF,SAAS,KAAyB,OAAqB;AACtD,QAAM,EAAE,MAAM,UAAU,GAAG,KAAK,IAAI;AAEpC,QAAM,YAAY,UAAU,IAAI;AAEhC,SACC,oBAAC,YAAS,MAAM,WAAY,GAAG,MAC7B,UACF;AAEF;;;AEhBA,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AA0BrB,IAAM,iBAAiB,MAA8B;AAC3D,QAAM,SAAS,UAAU;AAEzB,QAAM,OAAuC;AAAA,IAC5C,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,KAAK,WAAW,OAAO;AAAA,IAC/B;AAAA,IACA,CAAC,OAAO,IAAI;AAAA,EACb;AAEA,QAAM,UAA6C;AAAA,IAClD,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,QAAQ,WAAW,OAAO;AAAA,IAClC;AAAA,IACA,CAAC,OAAO,OAAO;AAAA,EAChB;AAEA,QAAM,WAA+C;AAAA,IACpD,CAAC,MAAoB,YAAY;AAChC,YAAM,YAAY,UAAU,IAAI;AAEhC,aAAO,SAAS,WAAW,OAAO;AAAA,IACnC;AAAA,IACA,CAAC,OAAO,QAAQ;AAAA,EACjB;AAEA,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;;;ACpEA,SAAS,uBAAuB;AAuBzB,IAAM,uBAAuB,CACnC,SACqC;AACrC,QAAM,eAAe,gBAAgB;AAErC,SAAO;AACR;","names":[]}
|