@kitbag/router 0.21.0 → 0.22.0

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.
Files changed (54) hide show
  1. package/README.md +9 -0
  2. package/dist/components/routerLink.d.ts +3 -3
  3. package/dist/compositions/useLink.d.ts +2 -2
  4. package/dist/devtools/createRouterDevtools.d.ts +13 -0
  5. package/dist/devtools/filters.d.ts +12 -0
  6. package/dist/devtools/getDevtoolsLabel.d.ts +13 -0
  7. package/dist/devtools/types.d.ts +10 -0
  8. package/dist/errors/invalidRouteRedirectError.d.ts +11 -0
  9. package/dist/errors/multipleRouteRedirectsError.d.ts +13 -0
  10. package/dist/kitbag-router.js +5256 -2004
  11. package/dist/kitbag-router.umd.cjs +3 -3
  12. package/dist/main.d.ts +1 -1
  13. package/dist/models/hooks.d.ts +9 -7
  14. package/dist/services/createComponentHooks.d.ts +5 -5
  15. package/dist/services/createExternalRoute.d.ts +3 -2
  16. package/dist/services/createRoute.d.ts +2 -1
  17. package/dist/services/createRouteHooks.d.ts +17 -0
  18. package/dist/services/createRouteRedirects.d.ts +10 -0
  19. package/dist/services/createRouterAssets.d.ts +5 -5
  20. package/dist/services/createRouterHooks.d.ts +8 -9
  21. package/dist/services/insertBaseRoute.d.ts +2 -2
  22. package/dist/services/routeMatchRules.d.ts +0 -1
  23. package/dist/services/routeMatchScore.d.ts +1 -1
  24. package/dist/services/routeRegex.d.ts +1 -0
  25. package/dist/services/urlAssembly.d.ts +2 -2
  26. package/dist/services/urlCombine.d.ts +2 -3
  27. package/dist/services/urlCreator.d.ts +2 -3
  28. package/dist/services/urlParser.d.ts +1 -1
  29. package/dist/types/hooks.d.ts +56 -28
  30. package/dist/types/params.d.ts +5 -11
  31. package/dist/types/redirects.d.ts +40 -0
  32. package/dist/types/resolved.d.ts +12 -2
  33. package/dist/types/route.d.ts +0 -2
  34. package/dist/types/router.d.ts +12 -7
  35. package/dist/types/routerLink.d.ts +3 -3
  36. package/dist/types/routerPush.d.ts +2 -2
  37. package/dist/types/routerReplace.d.ts +2 -2
  38. package/dist/types/urlString.d.ts +23 -0
  39. package/dist/types/useLink.d.ts +2 -2
  40. package/dist/utilities/checkDuplicateParams.spec.d.ts +1 -0
  41. package/dist/utilities/index.d.ts +1 -1
  42. package/dist/utilities/isNamedRoute.d.ts +4 -0
  43. package/dist/utilities/makeOptional.d.ts +0 -1
  44. package/dist/utilities/testHelpers.d.ts +450 -18
  45. package/package.json +7 -7
  46. package/dist/errors/missingRouteContextError.d.ts +0 -10
  47. package/dist/services/createHooksFactory.d.ts +0 -15
  48. package/dist/services/createUrlParts.d.ts +0 -13
  49. package/dist/types/url.d.ts +0 -14
  50. package/dist/types/urlParts.d.ts +0 -53
  51. package/dist/utilities/checkMissingContext.d.ts +0 -2
  52. /package/dist/{utilities/checkDuplicateKeys.spec.d.ts → services/createRouteRedirects.spec.d.ts} +0 -0
  53. /package/dist/{utilities/checkMissingContext.spec copy.d.ts → types/redirects.spec-d.d.ts} +0 -0
  54. /package/dist/utilities/{checkDuplicateKeys.d.ts → checkDuplicateParams.d.ts} +0 -0
@@ -1,15 +0,0 @@
1
- import { AddBeforeHook, AddAfterHook, AddErrorHook } from '../types/hooks';
2
- import { Routes } from '../types/route';
3
- import { Hooks } from '../models/hooks';
4
- import { Rejection } from '../types/rejection';
5
- export type RouteHooks<TRoutes extends Routes = Routes, TRejections extends Rejection[] = Rejection[]> = {
6
- onBeforeRouteEnter: AddBeforeHook<TRoutes[number], TRoutes, TRejections>;
7
- onBeforeRouteUpdate: AddBeforeHook<TRoutes[number], TRoutes, TRejections>;
8
- onBeforeRouteLeave: AddBeforeHook<TRoutes[number], TRoutes, TRejections>;
9
- onAfterRouteEnter: AddAfterHook<TRoutes[number], TRoutes, TRejections>;
10
- onAfterRouteUpdate: AddAfterHook<TRoutes[number], TRoutes, TRejections>;
11
- onAfterRouteLeave: AddAfterHook<TRoutes[number], TRoutes, TRejections>;
12
- onError: AddErrorHook<TRoutes[number], TRoutes, TRejections>;
13
- store: Hooks;
14
- };
15
- export declare function createHooksFactory(): RouteHooks;
@@ -1,13 +0,0 @@
1
- import { UrlParts } from '../types/urlParts';
2
- import { ToWithParams, WithParams } from './withParams';
3
- type CreateUrlPartsOptions = {
4
- protocol?: string | WithParams | undefined;
5
- host?: string | WithParams | undefined;
6
- port?: string | WithParams | undefined;
7
- pathname?: string | WithParams | undefined;
8
- search?: string | WithParams | undefined;
9
- hash?: string | WithParams | undefined;
10
- };
11
- type ToUrlParts<T extends CreateUrlPartsOptions> = UrlParts<ToWithParams<T['protocol']>, ToWithParams<T['host']>, ToWithParams<T['port']>, ToWithParams<T['pathname']>, ToWithParams<T['search']>, ToWithParams<T['hash']>>;
12
- export declare function createUrlParts<const T extends CreateUrlPartsOptions>(options: T): ToUrlParts<T>;
13
- export {};
@@ -1,14 +0,0 @@
1
- export type Url = `http://${string}` | `https://${string}` | `/${string}`;
2
- /**
3
- * A type guard for determining if a value is a valid URL.
4
- * @param value - The value to check.
5
- * @returns `true` if the value is a valid URL, otherwise `false`.
6
- * @group Type Guards
7
- */
8
- export declare function isUrl(value: unknown): value is Url;
9
- /**
10
- * Converts a string to a valid URL.
11
- * @param value - The string to convert.
12
- * @returns The valid URL.
13
- */
14
- export declare function asUrl(value: string): Url;
@@ -1,53 +0,0 @@
1
- import { WithParams } from '../services/withParams';
2
- import { ExtractRouteParamTypesWriting } from './params';
3
- /**
4
- * Represents the structure of a url parts. Can be used to create a url with support for params.
5
- */
6
- export type UrlParts<TProtocol extends WithParams = WithParams, THost extends WithParams = WithParams, TPort extends WithParams = WithParams, TPath extends WithParams = WithParams, TQuery extends WithParams = WithParams, THash extends WithParams = WithParams> = {
7
- /**
8
- * Represents the protocol for this route. Used for external routes.
9
- */
10
- protocol: TProtocol;
11
- /**
12
- * Represents the host for this route. Used for external routes.
13
- */
14
- host: THost;
15
- /**
16
- * Represents the port for this route. Used for external routes.
17
- */
18
- port: TPort;
19
- /**
20
- * Represents the structured path of the route, including path params.
21
- */
22
- pathname: TPath;
23
- /**
24
- * Represents the structured query of the route, including query params.
25
- */
26
- search: TQuery;
27
- /**
28
- * Represents the hash of the route.
29
- */
30
- hash: THash;
31
- /**
32
- * Converts the url parts to a full url.
33
- */
34
- assemble: (params: ExtractRouteParamTypesWriting<{
35
- protocol: TProtocol;
36
- host: THost;
37
- port: TPort;
38
- pathname: TPath;
39
- search: TQuery;
40
- hash: THash;
41
- }>) => string;
42
- /**
43
- * Converts the url parts to a full url.
44
- */
45
- href: (params: ExtractRouteParamTypesWriting<{
46
- protocol: TProtocol;
47
- host: THost;
48
- port: TPort;
49
- pathname: TPath;
50
- search: TQuery;
51
- hash: THash;
52
- }>) => string;
53
- };
@@ -1,2 +0,0 @@
1
- import { Routes } from '../types/route';
2
- export declare function checkMissingContext(routes: Routes): void;