| 281 | * @since 4.2.0 |
| 282 | */ |
| 283 | export interface Base<Routes extends Record<string, Any>> extends Schema.TaggedUnion<Cases<Routes>> { |
| 284 | /** The route definitions, by tag. */ |
| 285 | readonly routes: Routes |
| 286 | /** The tag of the catch-all route, the first declared `"/*"`, if any. */ |
| 287 | readonly catchAll: (keyof Routes & string) | undefined |
| 288 | /** Parses a URL path, with its search, into a route value, resolving redirects. */ |
| 289 | readonly parse: (url: string) => Option.Option<this["Type"]> |
| 290 | /** Like `parse`, and also reports whether the URL was redirected or normalised. */ |
| 291 | readonly resolve: (url: string) => Option.Option<Resolved<this["Type"]>> |
| 292 | /** |
| 293 | * Prints a route value as an absolute URL path under the base, with its |
| 294 | * search. A param equal to its field's decoding default is left out. |
| 295 | */ |
| 296 | readonly print: (route: this["Type"]) => string |
| 297 | /** |
| 298 | * Prints a route value's path under the base, without its search: the key |
| 299 | * of a page that updates in place when only the search changes. |
| 300 | */ |
| 301 | readonly printPath: (route: this["Type"]) => string |
| 302 | /** A union of some of the routes, for a section's props. It shares the base path. */ |
| 303 | readonly subset: <const Tags extends keyof Routes & string>( |
| 304 | tags: ReadonlyArray<Tags> |
| 305 | ) => Union<{ readonly [K in Tags]: Routes[K] }> |
| 306 | /** The base path: `""`, `"#"` or a path such as `"/en"` or `"/docs/"`. */ |
| 307 | readonly base: () => string |
| 308 | /** Sets the base path. Router and server Layers call it when built. */ |
| 309 | readonly setBase: (base: string) => void |
| 310 | } |
| 311 | |
| 312 | /** |
| 313 | * One constructor per route, keyed by tag. |