boring-router
Advanced tools
Comparing version 0.5.10 to 0.5.12
@@ -5,5 +5,5 @@ import { IHistory } from '../history'; | ||
import { GeneralParamDict, RouteMatchShared, RouteMatchSharedOptions } from './route-match-shared'; | ||
export declare class NextRouteMatch<TParamDict extends GeneralParamDict = GeneralParamDict, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
export declare class NextRouteMatch<TParamDict extends GeneralParamDict = GeneralParamDict, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string, TMetadata extends object = object> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName, TMetadata> { | ||
readonly $parent: NextRouteMatch | undefined; | ||
constructor(name: string, router: Router<TGroupName>, source: RouteSource, parent: NextRouteMatch<TParamDict> | undefined, origin: RouteMatch<TParamDict>, history: IHistory, options: RouteMatchSharedOptions); | ||
} |
@@ -26,4 +26,5 @@ import { Dict, EmptyObjectPatch } from 'tslang'; | ||
group: string | undefined; | ||
metadata: object | undefined; | ||
} | ||
export declare abstract class RouteMatchShared<TParamDict extends GeneralParamDict = GeneralParamDict, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string> { | ||
export declare abstract class RouteMatchShared<TParamDict extends GeneralParamDict = GeneralParamDict, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string, TMetadata extends object = object> { | ||
/** | ||
@@ -38,2 +39,3 @@ * Name of this `RouteMatch`, correspondent to the field name of route | ||
readonly $group: TSpecificGroupName | undefined; | ||
readonly $metadata: TMetadata; | ||
/** | ||
@@ -44,3 +46,3 @@ * Parent of this route match. | ||
readonly $router: Router<TGroupName>; | ||
constructor(name: string, router: Router<TGroupName>, source: RouteSource, parent: RouteMatchShared | undefined, history: IHistory, { match, query, group }: RouteMatchSharedOptions); | ||
constructor(name: string, router: Router<TGroupName>, source: RouteSource, parent: RouteMatchShared | undefined, history: IHistory, { match, query, group, metadata }: RouteMatchSharedOptions); | ||
/** | ||
@@ -47,0 +49,0 @@ * A dictionary of the combination of query string and segments. |
@@ -9,3 +9,3 @@ "use strict"; | ||
class RouteMatchShared { | ||
constructor(name, router, source, parent, history, { match, query, group }) { | ||
constructor(name, router, source, parent, history, { match, query, group, metadata }) { | ||
var _a; | ||
@@ -31,2 +31,8 @@ /** | ||
}); | ||
Object.defineProperty(this, "$metadata", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
@@ -97,2 +103,6 @@ * Parent of this route match. | ||
]); | ||
this.$metadata = { | ||
...parent === null || parent === void 0 ? void 0 : parent.$metadata, | ||
...metadata, | ||
}; | ||
} | ||
@@ -99,0 +109,0 @@ /** |
@@ -115,9 +115,7 @@ import { IAutorunOptions, IReactionDisposer, IReactionOptions, IReactionPublic } from 'mobx'; | ||
exact: boolean | string; | ||
metadata: object | undefined; | ||
} | ||
export declare class RouteMatch<TParamDict extends GeneralParamDict = GeneralParamDict, TNextRouteMatch extends NextRouteMatch<TParamDict> = NextRouteMatch<TParamDict>, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string, TMetadata extends object = object> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
export declare class RouteMatch<TParamDict extends GeneralParamDict = GeneralParamDict, TNextRouteMatch extends NextRouteMatch<TParamDict> = NextRouteMatch<TParamDict>, TSpecificGroupName extends string | undefined = string | undefined, TGroupName extends string = string, TMetadata extends object = object> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName, TMetadata> { | ||
readonly $parent: RouteMatch | undefined; | ||
readonly $next: TNextRouteMatch; | ||
readonly $metadata: TMetadata; | ||
constructor(name: string, router: Router<TGroupName>, source: RouteSource, parent: RouteMatch | undefined, extension: object | undefined, history: IHistory, { exact, metadata, ...sharedOptions }: RouteMatchOptions); | ||
constructor(name: string, router: Router<TGroupName>, source: RouteSource, parent: RouteMatch | undefined, extension: object | undefined, history: IHistory, { exact, ...sharedOptions }: RouteMatchOptions); | ||
$beforeEnter(callback: RouteBeforeEnterCallback<this>): RouteHookRemovalCallback; | ||
@@ -124,0 +122,0 @@ $beforeUpdate(callback: RouteBeforeUpdateCallback<this>, options?: RouteBeforeUpdateOptions): RouteHookRemovalCallback; |
@@ -9,3 +9,3 @@ "use strict"; | ||
class RouteMatch extends route_match_shared_1.RouteMatchShared { | ||
constructor(name, router, source, parent, extension, history, { exact, metadata, ...sharedOptions }) { | ||
constructor(name, router, source, parent, extension, history, { exact, ...sharedOptions }) { | ||
super(name, router, source, parent, history, sharedOptions); | ||
@@ -18,8 +18,2 @@ Object.defineProperty(this, "$next", { | ||
}); | ||
Object.defineProperty(this, "$metadata", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
@@ -170,6 +164,2 @@ Object.defineProperty(this, "_beforeEnterCallbackSet", { | ||
} | ||
this.$metadata = { | ||
...parent === null || parent === void 0 ? void 0 : parent.$metadata, | ||
...metadata, | ||
}; | ||
this._allowExact = exact; | ||
@@ -176,0 +166,0 @@ } |
@@ -28,9 +28,9 @@ import { Dict, EmptyObjectPatch } from 'tslang'; | ||
}; | ||
declare type __RouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TParamDict extends Dict<string | undefined>, TMetadata extends object> = RouteMatch<TParamDict, __NextRouteMatchType<TRouteSchema, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, TParamDict>, TSpecificGroupName, TGroupName, RouteMatchMetadataType<TRouteSchema, TMetadata>> & RouteMatchSegmentType<NestedRouteSchemaDictType<TRouteSchema>, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, RouteMatchMetadataType<TRouteSchema, TMetadata>> & RouteMatchExtensionType<TRouteSchema>; | ||
declare type __RouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TParamDict extends Dict<string | undefined>, TMetadata extends object> = RouteMatch<TParamDict, __NextRouteMatchType<TRouteSchema, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, TParamDict, TMetadata>, TSpecificGroupName, TGroupName, RouteMatchMetadataType<TRouteSchema, TMetadata>> & RouteMatchSegmentType<NestedRouteSchemaDictType<TRouteSchema>, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, RouteMatchMetadataType<TRouteSchema, TMetadata>> & RouteMatchExtensionType<TRouteSchema>; | ||
export declare type RouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TMetadata extends object> = __RouteMatchType<TRouteSchema, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, Record<TQueryKey, string | undefined> & Record<TSegmentKey, string>, TMetadata>; | ||
declare type NextRouteMatchSegmentType<TRouteSchemaDict, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string> = { | ||
[K in Extract<keyof TRouteSchemaDict, string>]: NextRouteMatchType<TRouteSchemaDict[K], TSegmentKey | FilterRouteMatchNonStringSegment<TRouteSchemaDict[K], K>, TQueryKey | Extract<keyof RouteQuerySchemaType<TRouteSchemaDict[K]>, string>, TSpecificGroupName, TGroupName>; | ||
declare type NextRouteMatchSegmentType<TRouteSchemaDict, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TMetadata extends object> = { | ||
[K in Extract<keyof TRouteSchemaDict, string>]: NextRouteMatchType<TRouteSchemaDict[K], TSegmentKey | FilterRouteMatchNonStringSegment<TRouteSchemaDict[K], K>, TQueryKey | Extract<keyof RouteQuerySchemaType<TRouteSchemaDict[K]>, string>, TSpecificGroupName, TGroupName, TMetadata>; | ||
}; | ||
declare type __NextRouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TParamDict extends Dict<string | undefined>> = NextRouteMatch<TParamDict, TSpecificGroupName, TGroupName> & NextRouteMatchSegmentType<NestedRouteSchemaDictType<TRouteSchema>, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName>; | ||
declare type NextRouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string> = __NextRouteMatchType<TRouteSchema, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, Record<TQueryKey, string | undefined> & Record<TSegmentKey, string>>; | ||
declare type __NextRouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TParamDict extends Dict<string | undefined>, TMetadata extends object> = NextRouteMatch<TParamDict, TSpecificGroupName, TGroupName, TMetadata> & NextRouteMatchSegmentType<NestedRouteSchemaDictType<TRouteSchema>, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, TMetadata>; | ||
declare type NextRouteMatchType<TRouteSchema, TSegmentKey extends string, TQueryKey extends string, TSpecificGroupName extends string | undefined, TGroupName extends string, TMetadata extends object> = __NextRouteMatchType<TRouteSchema, TSegmentKey, TQueryKey, TSpecificGroupName, TGroupName, Record<TQueryKey, string | undefined> & Record<TSegmentKey, string>, TMetadata>; | ||
export declare type RootRouteMatchType<TRouteSchema, TSpecificGroupName extends string | undefined, TGroupName extends string, TMetadata extends object = {}> = RouteMatchType<TRouteSchema, never, Extract<keyof RouteQuerySchemaType<TRouteSchema>, string>, TSpecificGroupName, TGroupName, TMetadata>; | ||
@@ -37,0 +37,0 @@ export declare type RouterOnLeave = (path: string) => void; |
{ | ||
"name": "boring-router", | ||
"version": "0.5.10", | ||
"version": "0.5.12", | ||
"description": "A type-safe MobX router with parallel routing support.", | ||
@@ -37,3 +37,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "e64412ae2512795560fe163434831b97400bef42" | ||
"gitHead": "769c4c620af86d8045da767bd09af0e281b95fcd" | ||
} |
@@ -16,3 +16,9 @@ import {IHistory} from '../history'; | ||
TGroupName extends string = string, | ||
> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
TMetadata extends object = object, | ||
> extends RouteMatchShared< | ||
TParamDict, | ||
TSpecificGroupName, | ||
TGroupName, | ||
TMetadata | ||
> { | ||
declare readonly $parent: NextRouteMatch | undefined; | ||
@@ -19,0 +25,0 @@ |
@@ -39,2 +39,3 @@ import {computed, makeObservable} from 'mobx'; | ||
group: string | undefined; | ||
metadata: object | undefined; | ||
} | ||
@@ -46,2 +47,3 @@ | ||
TGroupName extends string = string, | ||
TMetadata extends object = object, | ||
> { | ||
@@ -59,2 +61,4 @@ /** | ||
readonly $metadata: TMetadata; | ||
/** | ||
@@ -88,3 +92,3 @@ * Parent of this route match. | ||
history: IHistory, | ||
{match, query, group}: RouteMatchSharedOptions, | ||
{match, query, group, metadata}: RouteMatchSharedOptions, | ||
) { | ||
@@ -112,2 +116,7 @@ makeObservable(this); | ||
]); | ||
this.$metadata = { | ||
...parent?.$metadata, | ||
...metadata, | ||
} as TMetadata; | ||
} | ||
@@ -114,0 +123,0 @@ |
@@ -282,3 +282,2 @@ import { | ||
exact: boolean | string; | ||
metadata: object | undefined; | ||
} | ||
@@ -292,3 +291,8 @@ | ||
TMetadata extends object = object, | ||
> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
> extends RouteMatchShared< | ||
TParamDict, | ||
TSpecificGroupName, | ||
TGroupName, | ||
TMetadata | ||
> { | ||
declare readonly $parent: RouteMatch | undefined; | ||
@@ -298,4 +302,2 @@ | ||
readonly $metadata: TMetadata; | ||
/** @internal */ | ||
@@ -363,3 +365,3 @@ private _beforeEnterCallbackSet = new Set<RouteBeforeEnterCallback>(); | ||
history: IHistory, | ||
{exact, metadata, ...sharedOptions}: RouteMatchOptions, | ||
{exact, ...sharedOptions}: RouteMatchOptions, | ||
) { | ||
@@ -390,7 +392,2 @@ super(name, router, source, parent, history, sharedOptions); | ||
this.$metadata = { | ||
...parent?.$metadata, | ||
...metadata, | ||
} as TMetadata; | ||
this._allowExact = exact; | ||
@@ -397,0 +394,0 @@ } |
@@ -103,3 +103,4 @@ import hyphenate from 'hyphenate'; | ||
TGroupName, | ||
TParamDict | ||
TParamDict, | ||
TMetadata | ||
>, | ||
@@ -143,2 +144,3 @@ TSpecificGroupName, | ||
TGroupName extends string, | ||
TMetadata extends object, | ||
> = { | ||
@@ -151,3 +153,4 @@ [K in Extract<keyof TRouteSchemaDict, string>]: NextRouteMatchType< | ||
TSpecificGroupName, | ||
TGroupName | ||
TGroupName, | ||
TMetadata | ||
>; | ||
@@ -163,3 +166,4 @@ }; | ||
TParamDict extends Dict<string | undefined>, | ||
> = NextRouteMatch<TParamDict, TSpecificGroupName, TGroupName> & | ||
TMetadata extends object, | ||
> = NextRouteMatch<TParamDict, TSpecificGroupName, TGroupName, TMetadata> & | ||
NextRouteMatchSegmentType< | ||
@@ -170,3 +174,4 @@ NestedRouteSchemaDictType<TRouteSchema>, | ||
TSpecificGroupName, | ||
TGroupName | ||
TGroupName, | ||
TMetadata | ||
>; | ||
@@ -180,2 +185,3 @@ | ||
TGroupName extends string, | ||
TMetadata extends object, | ||
> = __NextRouteMatchType< | ||
@@ -187,3 +193,4 @@ TRouteSchema, | ||
TGroupName, | ||
Record<TQueryKey, string | undefined> & Record<TSegmentKey, string> | ||
Record<TQueryKey, string | undefined> & Record<TSegmentKey, string>, | ||
TMetadata | ||
>; | ||
@@ -190,0 +197,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
254009
5095