Skip to content

Custom Route Resolvers #2415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 92 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
474596f
feat: wip new matcher
posva Jun 25, 2024
745dabc
test: check parsed urls
posva Jun 25, 2024
3b893cf
chore: build location
posva Jun 25, 2024
f89a842
perf: parseURL minor improvements
posva Jun 26, 2024
38606b9
refactor: avoid double decoding
posva Jun 26, 2024
af7afb5
refactor: add fullPath
posva Jun 26, 2024
f26e919
chore: static path matcher
posva Jun 26, 2024
b7204fa
chore: error matches
posva Jun 26, 2024
684e970
test: static matcher
posva Jun 26, 2024
7cec10b
refactor: unused code
posva Jul 9, 2024
b0e0f0d
chore: ignore temp tsconfig
posva Dec 4, 2024
42bd1ac
test: better IM after hash
posva Dec 5, 2024
8204744
test: url parsing
posva Dec 5, 2024
ca95567
refactor: simplify parseURL
posva Dec 6, 2024
17bb729
chore: comment
posva Dec 6, 2024
f8cdff0
chore: comments
posva Dec 6, 2024
0d86f5a
refactor: renames and minor changes
posva Dec 6, 2024
c18e14f
refactor: simplify matcher interfaces
posva Dec 9, 2024
e1de9e6
refactor: remove unused code
posva Dec 9, 2024
00eef15
refactor: rename matcher-pattern
posva Dec 9, 2024
d061304
refactor: add methods needed by router
posva Dec 10, 2024
89035ea
feat: new dynamic path matcher
posva Dec 16, 2024
84ac19e
refactor: reorganize types and add initial experimental router
posva Dec 17, 2024
9af1441
chore: comments
posva Dec 23, 2024
e080bff
refactor: simplify router resolve
posva Dec 23, 2024
047858d
chore: wip encoding
posva Dec 24, 2024
a8e01d3
chore: small fix
posva Jan 7, 2025
0efc390
refactor: rename matcher to resolver
posva Jan 8, 2025
2d17e5b
chore: remove unused
posva Jan 8, 2025
1471a07
test: fix ts errors
posva Jan 8, 2025
9780e91
test: remove old matcher refs
posva Jan 8, 2025
800721f
chore: remove last ts errors
posva Jan 8, 2025
e9ba885
feat: support partial locations
posva Jan 8, 2025
3fe030a
chore: rename
posva Jan 9, 2025
b7b0bbf
feat: allow string in matcher resolve
posva Jan 9, 2025
a218b24
test: stricter no match test
posva Jan 9, 2025
ef995f4
feat: handle children
posva Jan 9, 2025
4b8ac59
refactor: simplify new resolver to be static
posva Jul 17, 2025
46aa26d
build: use tsdown
posva Jul 18, 2025
bce9486
docs: upgrade typedoc
posva Jul 18, 2025
38e5ed2
refactor: matchers tests
posva Jul 21, 2025
37aaddc
refactor: extended type of record
posva Jul 22, 2025
ce463fd
build: test out size
posva Jul 22, 2025
fe74a7b
chore: use mjs file
posva Jul 22, 2025
94e6813
feat: expose experimental package
posva Jul 23, 2025
de402ff
chore: add experimental playground'
posva Jul 23, 2025
ecc2666
chore: minor playground
posva Jul 23, 2025
5e2cd9e
chore: fix ts in playground
posva Jul 23, 2025
4477471
chore: show route info in playground
posva Jul 23, 2025
99cfc82
chore: add nested and layouts
posva Jul 25, 2025
a281602
chore: more
posva Jul 25, 2025
8859028
chore: add schema to tsconfig
posva Jul 25, 2025
d238f6d
refactor: loose children property in normalized records
posva Jul 25, 2025
316fb9b
chore: showaces layout level query params
posva Jul 25, 2025
5a60b24
chore: more links'
posva Jul 25, 2025
4ccd88a
refactor: reorg resolver
posva Jul 25, 2025
398b128
chore: ignore file
posva Jul 26, 2025
606c919
build: add experimental
posva Jul 26, 2025
0027186
chore: comment style
posva Jul 30, 2025
879fae6
feat: allow multiple query matchers per route
posva Jul 31, 2025
f48f51d
chore: playground
posva Jul 31, 2025
5e84856
feat: make children optional in experimental
posva Jul 31, 2025
93d36a0
refactor: use warn
posva Jul 31, 2025
ca12ba3
chore: comment
posva Jul 31, 2025
8fa7a70
chore: dx
posva Jul 31, 2025
bf813e8
chore: typo
posva Jul 31, 2025
3be0abd
fix(types): missing options in RouteLocationGeneric
posva Jul 31, 2025
6fec4ac
refactor: types
posva Jul 31, 2025
26bb388
chore: remove build
posva Jul 31, 2025
5fa416a
feat: MatcherPatternPathCustom
posva Aug 4, 2025
8b8cebf
feat: custom param
posva Aug 4, 2025
d746242
build: add node version back
posva Aug 4, 2025
01770df
build: remove non needed copy
posva Aug 5, 2025
7df84d9
chore: debug globals
posva Aug 7, 2025
f006032
chore: initial param parsers
posva Aug 7, 2025
86bc30f
build: cross compat
posva Aug 8, 2025
e0a6c2a
chore: import order
posva Aug 8, 2025
5b985d8
chore: fix non relative imports
posva Aug 8, 2025
9d15638
test: reuse utils
posva Aug 8, 2025
f846fad
refactor: add encoding within matcher
posva Aug 8, 2025
1d6b6ec
feat(types): typed MatcherPatternPathCustomParams
posva Aug 8, 2025
d3aff90
chore: unused import
posva Aug 8, 2025
27ab8e0
refactor: simpler param recognition in build
posva Aug 8, 2025
b931c7f
test: more
posva Aug 8, 2025
a1abbcb
refactor: leftover
posva Aug 8, 2025
08dfd9e
refactor: merge the parser config
posva Aug 8, 2025
18ccc00
refactor: identity fn
posva Aug 10, 2025
dce4df5
chore: outdated comments
posva Aug 10, 2025
441d75b
refactor: use identity instad of boolean
posva Aug 11, 2025
8fd456f
test: fix parser usage
posva Aug 11, 2025
e2966b0
refactor: put TOut type param first
posva Aug 11, 2025
2cfaaba
chore: rename to int
posva Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: add fullPath
  • Loading branch information
posva committed Jul 16, 2025
commit af7afb50686a88de0425c4cbe57d76982f52b1a4
33 changes: 23 additions & 10 deletions packages/router/src/new-matcher/matcher.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
import { type LocationQuery, parseQuery, normalizeQuery } from '../query'
import {
type LocationQuery,
parseQuery,
normalizeQuery,
stringifyQuery,
} from '../query'
import type { MatcherPattern } from './matcher-pattern'
import { warn } from '../warning'
import {
SLASH_RE,
encodePath,
encodeQueryValue as _encodeQueryValue,
} from '../encoding'
import { parseURL } from '../location'
import { parseURL, stringifyURL } from '../location'
import type {
MatcherLocationAsName,
MatcherLocationAsRelative,
Expand Down Expand Up @@ -84,6 +89,7 @@ type TODO = any

export interface NEW_MatcherLocationResolved {
name: MatcherName
fullPath: string
path: string
// TODO: generics?
params: MatcherParamsFormatted
Expand Down Expand Up @@ -137,6 +143,7 @@ export function decode(
}
return '' + text
}
// TODO: just add the null check to the original function in encoding.ts

interface FnStableNull {
(value: null | undefined): null
Expand Down Expand Up @@ -191,7 +198,10 @@ export const NO_MATCH_LOCATION = {
name: Symbol('no-match'),
params: {},
matched: [],
} satisfies Omit<NEW_MatcherLocationResolved, 'path' | 'hash' | 'query'>
} satisfies Omit<
NEW_MatcherLocationResolved,
'path' | 'hash' | 'query' | 'fullPath'
>

export function createCompiledMatcher(): NEW_Matcher_Resolve {
const matchers = new Map<MatcherName, MatcherPattern>()
Expand Down Expand Up @@ -239,7 +249,6 @@ export function createCompiledMatcher(): NEW_Matcher_Resolve {
}
}

// TODO: build fullPath
return {
...url,
name: matcher.name,
Expand All @@ -266,16 +275,20 @@ export function createCompiledMatcher(): NEW_Matcher_Resolve {
transformObject(String, encodeParam, mixedUnencodedParams[0])
)

// TODO: should pick query from the params but also from the location and merge them
const query = {
...normalizeQuery(location.query),
// ...matcher.extractQuery(mixedUnencodedParams[1])
}
const hash = mixedUnencodedParams[2] ?? location.hash ?? ''

return {
name,
fullPath: stringifyURL(stringifyQuery, { path, query: {}, hash }),
path,
params,
hash: mixedUnencodedParams[2] ?? location.hash ?? '',
// TODO: should pick query from the params but also from the location and merge them
query: {
...normalizeQuery(location.query),
// ...matcher.extractQuery(mixedUnencodedParams[1])
},
hash,
query,
matched: [],
}
}
Expand Down