boring-router
Advanced tools
Comparing version 0.4.7 to 0.5.0
@@ -6,3 +6,8 @@ "use strict"; | ||
constructor() { | ||
this.changeCallbackSet = new Set(); | ||
Object.defineProperty(this, "changeCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
} | ||
@@ -9,0 +14,0 @@ listen(callback) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./history"), exports); | ||
tslib_1.__exportStar(require("./memory-history"), exports); | ||
tslib_1.__exportStar(require("./readonly-history"), exports); | ||
(0, tslib_1.__exportStar)(require("./history"), exports); | ||
(0, tslib_1.__exportStar)(require("./memory-history"), exports); | ||
(0, tslib_1.__exportStar)(require("./readonly-history"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -9,2 +9,20 @@ "use strict"; | ||
super(); | ||
Object.defineProperty(this, "snapshot", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "lastId", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "prefix", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.prefix = prefix; | ||
@@ -40,3 +58,3 @@ if (!initialRef.startsWith('/')) { | ||
let { entries } = snapshot; | ||
let index = history_1.getActiveHistoryEntryIndex(snapshot); | ||
let index = (0, history_1.getActiveHistoryEntryIndex)(snapshot); | ||
if (index <= 0) { | ||
@@ -56,3 +74,3 @@ return; | ||
let { entries } = snapshot; | ||
let index = history_1.getActiveHistoryEntryIndex(snapshot); | ||
let index = (0, history_1.getActiveHistoryEntryIndex)(snapshot); | ||
if (index >= entries.length - 1) { | ||
@@ -72,3 +90,3 @@ return; | ||
let { entries } = snapshot; | ||
let index = history_1.getActiveHistoryEntryIndex(snapshot); | ||
let index = (0, history_1.getActiveHistoryEntryIndex)(snapshot); | ||
snapshot = { | ||
@@ -84,3 +102,3 @@ entries: [...entries.slice(0, index + 1), { id, ref, data }], | ||
let { entries, active: activeId } = snapshot; | ||
let index = history_1.getActiveHistoryEntryIndex(snapshot); | ||
let index = (0, history_1.getActiveHistoryEntryIndex)(snapshot); | ||
snapshot = { | ||
@@ -87,0 +105,0 @@ entries: [ |
@@ -8,2 +8,14 @@ "use strict"; | ||
super(); | ||
Object.defineProperty(this, "snapshot", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "prefix", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.prefix = prefix; | ||
@@ -10,0 +22,0 @@ let id = 0; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./route-match"), exports); | ||
tslib_1.__exportStar(require("./router"), exports); | ||
tslib_1.__exportStar(require("./schema"), exports); | ||
tslib_1.__exportStar(require("./history"), exports); | ||
tslib_1.__exportStar(require("./route-builder"), exports); | ||
(0, tslib_1.__exportStar)(require("./route-match"), exports); | ||
(0, tslib_1.__exportStar)(require("./router"), exports); | ||
(0, tslib_1.__exportStar)(require("./schema"), exports); | ||
(0, tslib_1.__exportStar)(require("./history"), exports); | ||
(0, tslib_1.__exportStar)(require("./route-builder"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -5,10 +5,30 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const lodash_1 = tslib_1.__importDefault(require("lodash")); | ||
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); | ||
const _utils_1 = require("./@utils"); | ||
class RouteBuilder { | ||
constructor(router, sourceType, buildingParts = [], leavingGroupSet = new Set()) { | ||
this.router = router; | ||
this.sourceType = sourceType; | ||
this.buildingParts = buildingParts; | ||
this.leavingGroupSet = leavingGroupSet; | ||
Object.defineProperty(this, "router", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: router | ||
}); | ||
Object.defineProperty(this, "sourceType", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: sourceType | ||
}); | ||
Object.defineProperty(this, "buildingParts", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: buildingParts | ||
}); | ||
Object.defineProperty(this, "leavingGroupSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: leavingGroupSet | ||
}); | ||
} | ||
@@ -107,3 +127,3 @@ /** | ||
let segmentDict = lodash_1.default.fromPairs(lodash_1.default.sortBy(lodash_1.default.entries(lodash_1.default.merge(restSegmentDict, nextSegmentDict)), ([key]) => nextSegmentNames.indexOf(key))); | ||
pathMap.set(group, _utils_1.buildPath(segmentDict, paramDict)); | ||
pathMap.set(group, (0, _utils_1.buildPath)(segmentDict, paramDict)); | ||
let { queryMap: sourceQueryMap } = route._source; | ||
@@ -115,3 +135,3 @@ let queryKeyToIdMap = route._queryKeyToIdMap; | ||
routeQueryId === undefined || | ||
!_utils_1.isQueryIdsMatched(routeQueryId, id)) { | ||
!(0, _utils_1.isQueryIdsMatched)(routeQueryId, id)) { | ||
continue; | ||
@@ -133,3 +153,3 @@ } | ||
} | ||
return _utils_1.buildRef(pathMap, queryMap); | ||
return (0, _utils_1.buildRef)(pathMap, queryMap); | ||
} | ||
@@ -165,3 +185,3 @@ $href() { | ||
primaryPath = part.slice(0, searchIndex); | ||
queryMap = _utils_1.parseSearch(part.slice(searchIndex)); | ||
queryMap = (0, _utils_1.parseSearch)(part.slice(searchIndex)); | ||
} | ||
@@ -168,0 +188,0 @@ else { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./next-route-match"), exports); | ||
tslib_1.__exportStar(require("./route-match"), exports); | ||
tslib_1.__exportStar(require("./route-match-shared"), exports); | ||
(0, tslib_1.__exportStar)(require("./next-route-match"), exports); | ||
(0, tslib_1.__exportStar)(require("./route-match"), exports); | ||
(0, tslib_1.__exportStar)(require("./route-match-shared"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -8,2 +8,9 @@ "use strict"; | ||
super(name, router, source, parent, history, options); | ||
/** @internal */ | ||
Object.defineProperty(this, "_origin", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this._origin = origin; | ||
@@ -10,0 +17,0 @@ } |
@@ -11,2 +11,71 @@ "use strict"; | ||
var _a; | ||
/** | ||
* Name of this `RouteMatch`, correspondent to the field name of route | ||
* schema. | ||
*/ | ||
Object.defineProperty(this, "$name", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Group of this `RouteMatch`, specified in the root route. | ||
*/ | ||
Object.defineProperty(this, "$group", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** | ||
* Parent of this route match. | ||
*/ | ||
Object.defineProperty(this, "$parent", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "$router", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_source", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_queryKeyToIdMap", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_children", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_history", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_matchPattern", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
this.$name = name; | ||
@@ -109,3 +178,3 @@ this.$group = group; | ||
let sourceQuery = sourceQueryMap.get(key); | ||
if (!sourceQuery || !_utils_1.isQueryIdsMatched(sourceQuery.id, id)) { | ||
if (!sourceQuery || !(0, _utils_1.isQueryIdsMatched)(sourceQuery.id, id)) { | ||
return dict; | ||
@@ -144,2 +213,3 @@ } | ||
} | ||
// eslint-disable-next-line @mufan/no-unnecessary-type-assertion | ||
leaves.push(group); | ||
@@ -152,24 +222,24 @@ } | ||
} | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "$params", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "$rest", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "_matchEntry", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "_segment", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "_paramSegments", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "_pathSegments", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
], RouteMatchShared.prototype, "_rest", null); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.computed | ||
@@ -176,0 +246,0 @@ ], RouteMatchShared.prototype, "_query", null); |
@@ -62,4 +62,4 @@ import { IAutorunOptions, IReactionDisposer, IReactionOptions, IReactionPublic } from 'mobx'; | ||
export declare type RouteReactionExpression<T> = (reaction: IReactionPublic) => T; | ||
export declare type RouteReactionEffect<T> = (value: T, reaction: IReactionPublic) => void; | ||
export declare type RouteReactionOptions = IReactionOptions | undefined; | ||
export declare type RouteReactionEffect<T> = (value: T, previousValue: T, reaction: IReactionPublic) => void; | ||
export declare type RouteReactionOptions<T> = IReactionOptions<T> | undefined; | ||
export declare type RouteHookRemovalCallback = () => void; | ||
@@ -120,3 +120,3 @@ export declare type RouteBeforeEnterOrUpdateCallback<TRouteMatch extends RouteMatch = RouteMatch> = (next: TRouteMatch['$next']) => Promise<boolean | void> | boolean | void; | ||
$autorun(view: RouteAutorunView, options?: RouteAutorunOptions): RouteHookRemovalCallback; | ||
$reaction<T>(expression: RouteReactionExpression<T>, effect: RouteReactionEffect<T>, options?: RouteReactionOptions): RouteHookRemovalCallback; | ||
$reaction<T>(expression: RouteReactionExpression<T>, effect: RouteReactionEffect<T>, options?: RouteReactionOptions<T>): RouteHookRemovalCallback; | ||
$beforeEnterOrUpdate(callback: RouteBeforeEnterOrUpdateCallback<this>, beforeUpdateOptions?: RouteBeforeUpdateOptions): RouteHookRemovalCallback; | ||
@@ -123,0 +123,0 @@ $willEnterOrUpdate(callback: RouteWillEnterOrUpdateCallback<this>, willUpdateOptions?: RouteWillUpdateOptions): RouteHookRemovalCallback; |
@@ -11,22 +11,119 @@ "use strict"; | ||
super(name, router, source, parent, history, sharedOptions); | ||
Object.defineProperty(this, "$next", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
Object.defineProperty(this, "$metadata", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
this._beforeEnterCallbackSet = new Set(); | ||
Object.defineProperty(this, "_beforeEnterCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._beforeUpdateEntrySet = new Set(); | ||
Object.defineProperty(this, "_beforeUpdateEntrySet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._beforeLeaveCallbackSet = new Set(); | ||
Object.defineProperty(this, "_beforeLeaveCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._willEnterCallbackSet = new Set(); | ||
Object.defineProperty(this, "_willEnterCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._willUpdateEntrySet = new Set(); | ||
Object.defineProperty(this, "_willUpdateEntrySet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._willLeaveCallbackSet = new Set(); | ||
Object.defineProperty(this, "_willLeaveCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._afterEnterCallbackSet = new Set(); | ||
Object.defineProperty(this, "_afterEnterCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._afterUpdateEntrySet = new Set(); | ||
Object.defineProperty(this, "_afterUpdateEntrySet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._afterLeaveCallbackSet = new Set(); | ||
Object.defineProperty(this, "_afterLeaveCallbackSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
this._reactiveEntrySet = new Set(); | ||
Object.defineProperty(this, "_reactiveEntrySet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_service", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_servicePromise", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_serviceFactory", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_allowExact", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_parallel", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
if (extension) { | ||
@@ -125,4 +222,4 @@ for (let key of Object.keys(extension)) { | ||
if (this.$matched) { | ||
_utils_1.tolerate(() => { | ||
autorunEntry.disposer = mobx_1.autorun(view, options); | ||
(0, _utils_1.tolerate)(() => { | ||
autorunEntry.disposer = (0, mobx_1.autorun)(view, options); | ||
}); | ||
@@ -148,4 +245,4 @@ } | ||
if (this.$matched) { | ||
_utils_1.tolerate(() => { | ||
reactionEntry.disposer = mobx_1.reaction(expression, effect, options); | ||
(0, _utils_1.tolerate)(() => { | ||
reactionEntry.disposer = (0, mobx_1.reaction)(expression, effect, options); | ||
}); | ||
@@ -211,3 +308,3 @@ } | ||
if (parent instanceof RouteMatch && parent._parallel) { | ||
let { groups: parentGroups = [], matches: parentMatches = [], } = parent._parallel; | ||
let { groups: parentGroups = [], matches: parentMatches = [] } = parent._parallel; | ||
let parentGroupSet = new Set(parentGroups); | ||
@@ -253,3 +350,3 @@ let parentMatchSet = new Set(parentMatches); | ||
if (typeof pattern === 'string') { | ||
if (_utils_1.testPathPrefix(upperRest, pattern)) { | ||
if ((0, _utils_1.testPathPrefix)(upperRest, pattern)) { | ||
segment = pattern; | ||
@@ -270,3 +367,3 @@ rest = upperRest.slice(pattern.length); | ||
let matched = groups[0]; | ||
if (_utils_1.testPathPrefix(upperRest, matched)) { | ||
if ((0, _utils_1.testPathPrefix)(upperRest, matched)) { | ||
segment = matched; | ||
@@ -313,7 +410,7 @@ rest = upperRest.slice(matched.length); | ||
let results = await Promise.all([ | ||
...Array.from(this._beforeLeaveCallbackSet).map(callback => _utils_1.tolerate(callback)), | ||
...Array.from(this._beforeLeaveCallbackSet).map(callback => (0, _utils_1.tolerate)(callback)), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.beforeLeave) { | ||
return _utils_1.tolerate(() => service.beforeLeave()); | ||
return (0, _utils_1.tolerate)(() => service.beforeLeave()); | ||
} | ||
@@ -328,7 +425,7 @@ })(), | ||
let results = await Promise.all([ | ||
...Array.from(this._beforeEnterCallbackSet).map(callback => _utils_1.tolerate(callback, next)), | ||
...Array.from(this._beforeEnterCallbackSet).map(callback => (0, _utils_1.tolerate)(callback, next)), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.beforeEnter) { | ||
return _utils_1.tolerate(() => service.beforeEnter(next)); | ||
return (0, _utils_1.tolerate)(() => service.beforeEnter(next)); | ||
} | ||
@@ -345,7 +442,7 @@ })(), | ||
.filter(({ options }) => triggeredByDescendants ? options && options.traceDescendants : true) | ||
.map(({ callback }) => _utils_1.tolerate(callback, next, { descendants: triggeredByDescendants })), | ||
.map(({ callback }) => (0, _utils_1.tolerate)(callback, next, { descendants: triggeredByDescendants })), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.beforeUpdate) { | ||
return _utils_1.tolerate(() => service.beforeUpdate(next, { descendants: triggeredByDescendants })); | ||
return (0, _utils_1.tolerate)(() => service.beforeUpdate(next, { descendants: triggeredByDescendants })); | ||
} | ||
@@ -365,7 +462,7 @@ })(), | ||
await Promise.all([ | ||
...Array.from(this._willLeaveCallbackSet).map(callback => _utils_1.tolerate(callback)), | ||
...Array.from(this._willLeaveCallbackSet).map(callback => (0, _utils_1.tolerate)(callback)), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.willLeave) { | ||
return _utils_1.tolerate(() => service.willLeave()); | ||
return (0, _utils_1.tolerate)(() => service.willLeave()); | ||
} | ||
@@ -379,7 +476,7 @@ })(), | ||
await Promise.all([ | ||
...Array.from(this._willEnterCallbackSet).map(callback => _utils_1.tolerate(callback, next)), | ||
...Array.from(this._willEnterCallbackSet).map(callback => (0, _utils_1.tolerate)(callback, next)), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.willEnter) { | ||
return _utils_1.tolerate(() => service.willEnter(next)); | ||
return (0, _utils_1.tolerate)(() => service.willEnter(next)); | ||
} | ||
@@ -395,7 +492,7 @@ })(), | ||
.filter(({ options }) => triggeredByDescendants ? options && options.traceDescendants : true) | ||
.map(({ callback }) => _utils_1.tolerate(callback, next, { descendants: triggeredByDescendants })), | ||
.map(({ callback }) => (0, _utils_1.tolerate)(callback, next, { descendants: triggeredByDescendants })), | ||
(async () => { | ||
let service = await this._getService(); | ||
if (service && service.willUpdate) { | ||
return _utils_1.tolerate(() => service.willUpdate(next, { descendants: triggeredByDescendants })); | ||
return (0, _utils_1.tolerate)(() => service.willUpdate(next, { descendants: triggeredByDescendants })); | ||
} | ||
@@ -408,7 +505,7 @@ })(), | ||
for (let callback of this._afterLeaveCallbackSet) { | ||
_utils_1.tolerate(callback); | ||
(0, _utils_1.tolerate)(callback); | ||
} | ||
let service = await this._getService(); | ||
if (service && service.afterLeave) { | ||
_utils_1.tolerate(() => service.afterLeave()); | ||
(0, _utils_1.tolerate)(() => service.afterLeave()); | ||
} | ||
@@ -419,7 +516,7 @@ } | ||
for (let callback of this._afterEnterCallbackSet) { | ||
_utils_1.tolerate(callback); | ||
(0, _utils_1.tolerate)(callback); | ||
} | ||
let service = await this._getService(); | ||
if (service && service.afterEnter) { | ||
_utils_1.tolerate(() => service.afterEnter()); | ||
(0, _utils_1.tolerate)(() => service.afterEnter()); | ||
} | ||
@@ -431,9 +528,9 @@ for (let reactiveEntry of this._reactiveEntrySet) { | ||
} | ||
_utils_1.tolerate(() => { | ||
(0, _utils_1.tolerate)(() => { | ||
switch (reactiveEntry.type) { | ||
case 'autorun': | ||
reactiveEntry.disposer = mobx_1.autorun(reactiveEntry.view, reactiveEntry.options); | ||
reactiveEntry.disposer = (0, mobx_1.autorun)(reactiveEntry.view, reactiveEntry.options); | ||
break; | ||
case 'reaction': | ||
reactiveEntry.disposer = mobx_1.reaction(reactiveEntry.expression, reactiveEntry.effect, reactiveEntry.options); | ||
reactiveEntry.disposer = (0, mobx_1.reaction)(reactiveEntry.expression, reactiveEntry.effect, reactiveEntry.options); | ||
break; | ||
@@ -448,3 +545,3 @@ } | ||
if (triggeredByDescendants ? options && options.traceDescendants : true) { | ||
_utils_1.tolerate(callback, { descendants: triggeredByDescendants }); | ||
(0, _utils_1.tolerate)(callback, { descendants: triggeredByDescendants }); | ||
} | ||
@@ -454,3 +551,3 @@ } | ||
if (service && service.afterUpdate) { | ||
_utils_1.tolerate(() => service.afterUpdate({ descendants: triggeredByDescendants })); | ||
(0, _utils_1.tolerate)(() => service.afterUpdate({ descendants: triggeredByDescendants })); | ||
} | ||
@@ -477,3 +574,3 @@ } | ||
} | ||
let output = _utils_1.tolerate(factory, this); | ||
let output = (0, _utils_1.tolerate)(factory, this); | ||
if (output instanceof Promise) { | ||
@@ -491,5 +588,15 @@ return (this._servicePromise = output.then(service => { | ||
} | ||
RouteMatch.SEGMENT = /[^/]+/; | ||
RouteMatch.REST = /.*/; | ||
tslib_1.__decorate([ | ||
Object.defineProperty(RouteMatch, "SEGMENT", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: /[^/]+/ | ||
}); | ||
Object.defineProperty(RouteMatch, "REST", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: /.*/ | ||
}); | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.observable | ||
@@ -496,0 +603,0 @@ ], RouteMatch.prototype, "_service", void 0); |
@@ -5,4 +5,4 @@ "use strict"; | ||
const tslib_1 = require("tslib"); | ||
const hyphenate_1 = tslib_1.__importDefault(require("hyphenate")); | ||
const lodash_1 = tslib_1.__importDefault(require("lodash")); | ||
const hyphenate_1 = (0, tslib_1.__importDefault)(require("hyphenate")); | ||
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash")); | ||
const mobx_1 = require("mobx"); | ||
@@ -13,127 +13,196 @@ const _utils_1 = require("./@utils"); | ||
const route_match_1 = require("./route-match"); | ||
const DEFAULT_SEGMENT_MATCHER_CALLBACK = key => hyphenate_1.default(key, { lowerCase: true }); | ||
const DEFAULT_SEGMENT_MATCHER_CALLBACK = key => (0, hyphenate_1.default)(key, { lowerCase: true }); | ||
class Router { | ||
constructor(history, { segmentMatcher } = {}) { | ||
/** @internal */ | ||
this._groupToRouteMatchMap = new Map(); | ||
Object.defineProperty(this, "_history", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
this._source = mobx_1.observable({ | ||
groupToMatchToMatchEntryMapMap: new Map(), | ||
queryMap: new Map(), | ||
pathMap: new Map(), | ||
Object.defineProperty(this, "_groupToRouteMatchMap", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Map() | ||
}); | ||
/** @internal */ | ||
this._matchingSource = mobx_1.observable({ | ||
groupToMatchToMatchEntryMapMap: new Map(), | ||
queryMap: new Map(), | ||
pathMap: new Map(), | ||
Object.defineProperty(this, "_segmentMatcher", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
this._changing = Promise.resolve(); | ||
Object.defineProperty(this, "_snapshot", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
this._routing = 0; | ||
Object.defineProperty(this, "_nextSnapshot", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: void 0 | ||
}); | ||
/** @internal */ | ||
this._beforeLeaveHookCalledMatchSet = new Set(); | ||
Object.defineProperty(this, "_source", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (0, mobx_1.observable)({ | ||
groupToMatchToMatchEntryMapMap: new Map(), | ||
queryMap: new Map(), | ||
pathMap: new Map(), | ||
}) | ||
}); | ||
/** @internal */ | ||
this._onHistoryChange = (snapshot) => { | ||
this._nextSnapshot = snapshot; | ||
if (!this.$routing) { | ||
this._beforeLeaveHookCalledMatchSet.clear(); | ||
} | ||
mobx_1.runInAction(() => { | ||
this._routing++; | ||
}); | ||
this._changing = this._changing | ||
.then(() => this._asyncOnHistoryChange(snapshot)) | ||
.finally(() => { | ||
mobx_1.runInAction(() => { | ||
this._routing--; | ||
}); | ||
Object.defineProperty(this, "_matchingSource", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (0, mobx_1.observable)({ | ||
groupToMatchToMatchEntryMapMap: new Map(), | ||
queryMap: new Map(), | ||
pathMap: new Map(), | ||
}) | ||
.catch(console.error); | ||
}; | ||
}); | ||
/** @internal */ | ||
this._asyncOnHistoryChange = async (nextSnapshot) => { | ||
if (this._isNextSnapshotOutDated(nextSnapshot)) { | ||
return; | ||
Object.defineProperty(this, "_changing", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: Promise.resolve() | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_routing", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: 0 | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_beforeLeaveHookCalledMatchSet", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: new Set() | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_onHistoryChange", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: (snapshot) => { | ||
this._nextSnapshot = snapshot; | ||
if (!this.$routing) { | ||
this._beforeLeaveHookCalledMatchSet.clear(); | ||
} | ||
(0, mobx_1.runInAction)(() => { | ||
this._routing++; | ||
}); | ||
this._changing = this._changing | ||
.then(() => this._asyncOnHistoryChange(snapshot)) | ||
.finally(() => { | ||
(0, mobx_1.runInAction)(() => { | ||
this._routing--; | ||
}); | ||
}) | ||
.catch(console.error); | ||
} | ||
let { ref, data } = history_1.getActiveHistoryEntry(nextSnapshot); | ||
let navigateCompleteListener = data && data.navigateCompleteListener; | ||
let { pathname, search } = _utils_1.parseRef(ref); | ||
let snapshot = this._snapshot; | ||
if (snapshot && lodash_1.default.isEqual(snapshot, nextSnapshot)) { | ||
return; | ||
} | ||
let queryMap = _utils_1.parseSearch(search); | ||
let pathMap = new Map(); | ||
pathMap.set(undefined, pathname || '/'); | ||
let groups = this.$groups; | ||
// Extract group route paths in query | ||
for (let group of groups) { | ||
let key = `_${group}`; | ||
if (!queryMap.has(key)) { | ||
continue; | ||
}); | ||
/** @internal */ | ||
Object.defineProperty(this, "_asyncOnHistoryChange", { | ||
enumerable: true, | ||
configurable: true, | ||
writable: true, | ||
value: async (nextSnapshot) => { | ||
if (this._isNextSnapshotOutDated(nextSnapshot)) { | ||
return; | ||
} | ||
let path = queryMap.get(key); | ||
if (path) { | ||
pathMap.set(group, path); | ||
let { ref, data } = (0, history_1.getActiveHistoryEntry)(nextSnapshot); | ||
let navigateCompleteListener = data && data.navigateCompleteListener; | ||
let { pathname, search } = (0, _utils_1.parseRef)(ref); | ||
let snapshot = this._snapshot; | ||
if (snapshot && lodash_1.default.isEqual(snapshot, nextSnapshot)) { | ||
return; | ||
} | ||
queryMap.delete(key); | ||
} | ||
// Match parallel routes | ||
let groupToMatchEntriesMap = new Map(); | ||
let groupToRouteMatchMap = this._groupToRouteMatchMap; | ||
for (let [group, path] of pathMap) { | ||
let routeMatch = groupToRouteMatchMap.get(group); | ||
let routeMatchEntries = this._match([routeMatch], path) || []; | ||
if (!routeMatchEntries.length) { | ||
continue; | ||
let queryMap = (0, _utils_1.parseSearch)(search); | ||
let pathMap = new Map(); | ||
pathMap.set(undefined, pathname || '/'); | ||
let groups = this.$groups; | ||
// Extract group route paths in query | ||
for (let group of groups) { | ||
let key = `_${group}`; | ||
if (!queryMap.has(key)) { | ||
continue; | ||
} | ||
let path = queryMap.get(key); | ||
if (path) { | ||
pathMap.set(group, path); | ||
} | ||
queryMap.delete(key); | ||
} | ||
let [{ match }] = routeMatchEntries; | ||
if (match.$group !== group) { | ||
continue; | ||
// Match parallel routes | ||
let groupToMatchEntriesMap = new Map(); | ||
let groupToRouteMatchMap = this._groupToRouteMatchMap; | ||
for (let [group, path] of pathMap) { | ||
let routeMatch = groupToRouteMatchMap.get(group); | ||
let routeMatchEntries = this._match([routeMatch], path) || []; | ||
if (!routeMatchEntries.length) { | ||
continue; | ||
} | ||
let [{ match }] = routeMatchEntries; | ||
if (match.$group !== group) { | ||
continue; | ||
} | ||
groupToMatchEntriesMap.set(group, routeMatchEntries); | ||
} | ||
groupToMatchEntriesMap.set(group, routeMatchEntries); | ||
} | ||
// Check primary match parallel options | ||
let groupToMatchToMatchEntryMapMap = new Map(); | ||
let primaryMatchEntries = groupToMatchEntriesMap.get(undefined); | ||
{ | ||
let primaryMatch = primaryMatchEntries === null || primaryMatchEntries === void 0 ? void 0 : primaryMatchEntries[primaryMatchEntries.length - 1].match; | ||
let options = primaryMatch === null || primaryMatch === void 0 ? void 0 : primaryMatch._parallel; | ||
let { groups = [], matches = [] } = options || {}; | ||
for (let [group, entries] of groupToMatchEntriesMap) { | ||
if (!group || | ||
!options || | ||
groups.includes(group) || | ||
entries.some(({ match }) => matches.includes(match))) { | ||
groupToMatchToMatchEntryMapMap.set(group, new Map(entries.map((entry) => [ | ||
entry.match, | ||
entry, | ||
]))); | ||
// Check primary match parallel options | ||
let groupToMatchToMatchEntryMapMap = new Map(); | ||
let primaryMatchEntries = groupToMatchEntriesMap.get(undefined); | ||
{ | ||
let primaryMatch = primaryMatchEntries === null || primaryMatchEntries === void 0 ? void 0 : primaryMatchEntries[primaryMatchEntries.length - 1].match; | ||
let options = primaryMatch === null || primaryMatch === void 0 ? void 0 : primaryMatch._parallel; | ||
let { groups = [], matches = [] } = options || {}; | ||
for (let [group, entries] of groupToMatchEntriesMap) { | ||
if (!group || | ||
!options || | ||
groups.includes(group) || | ||
entries.some(({ match }) => matches.includes(match))) { | ||
groupToMatchToMatchEntryMapMap.set(group, new Map(entries.map((entry) => [ | ||
entry.match, | ||
entry, | ||
]))); | ||
} | ||
} | ||
} | ||
let matchingSource = this._matchingSource; | ||
(0, mobx_1.runInAction)(() => { | ||
matchingSource.groupToMatchToMatchEntryMapMap = | ||
groupToMatchToMatchEntryMapMap; | ||
matchingSource.pathMap = pathMap; | ||
let matchingQueryKeyToIdMap = new Map(lodash_1.default.flatMap(Array.from(groupToRouteMatchMap.values()).reverse(), route => [...route.$next.$rest._queryKeyToIdMap])); | ||
matchingSource.queryMap = new Map(lodash_1.default.compact(Array.from(queryMap).map(([key, value]) => matchingQueryKeyToIdMap.has(key) | ||
? [key, { id: matchingQueryKeyToIdMap.get(key), value }] | ||
: undefined))); | ||
}); | ||
let generalGroups = [undefined, ...groups]; | ||
let interUpdateDataArray = await Promise.all(generalGroups.map(async (group) => this._beforeUpdate(nextSnapshot, group, groupToMatchToMatchEntryMapMap.get(group)))); | ||
if (interUpdateDataArray.some(data => !data)) { | ||
return; | ||
} | ||
await Promise.all(interUpdateDataArray.map(data => this._willUpdate(data))); | ||
this._update(generalGroups); | ||
this._snapshot = nextSnapshot; | ||
await Promise.all(interUpdateDataArray.map(data => this._afterUpdate(data))); | ||
if (navigateCompleteListener) { | ||
navigateCompleteListener(); | ||
} | ||
} | ||
let matchingSource = this._matchingSource; | ||
mobx_1.runInAction(() => { | ||
matchingSource.groupToMatchToMatchEntryMapMap = groupToMatchToMatchEntryMapMap; | ||
matchingSource.pathMap = pathMap; | ||
let matchingQueryKeyToIdMap = new Map(lodash_1.default.flatMap(Array.from(groupToRouteMatchMap.values()).reverse(), route => [...route.$next.$rest._queryKeyToIdMap])); | ||
matchingSource.queryMap = new Map(lodash_1.default.compact(Array.from(queryMap).map(([key, value]) => matchingQueryKeyToIdMap.has(key) | ||
? [key, { id: matchingQueryKeyToIdMap.get(key), value }] | ||
: undefined))); | ||
}); | ||
let generalGroups = [undefined, ...groups]; | ||
let interUpdateDataArray = await Promise.all(generalGroups.map(async (group) => this._beforeUpdate(nextSnapshot, group, groupToMatchToMatchEntryMapMap.get(group)))); | ||
if (interUpdateDataArray.some(data => !data)) { | ||
return; | ||
} | ||
await Promise.all(interUpdateDataArray.map(data => this._willUpdate(data))); | ||
this._update(generalGroups); | ||
this._snapshot = nextSnapshot; | ||
await Promise.all(interUpdateDataArray.map(data => this._afterUpdate(data))); | ||
if (navigateCompleteListener) { | ||
navigateCompleteListener(); | ||
} | ||
}; | ||
}); | ||
this._history = history; | ||
@@ -219,3 +288,3 @@ this._segmentMatcher = segmentMatcher || DEFAULT_SEGMENT_MATCHER_CALLBACK; | ||
previousMatchToMatchEntryMap = new Map(); | ||
mobx_1.runInAction(() => { | ||
(0, mobx_1.runInAction)(() => { | ||
this._source.groupToMatchToMatchEntryMapMap.set(group, previousMatchToMatchEntryMap); | ||
@@ -416,9 +485,9 @@ }); | ||
} | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.observable | ||
], Router.prototype, "_matchingSource", void 0); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.observable | ||
], Router.prototype, "_routing", void 0); | ||
tslib_1.__decorate([ | ||
(0, tslib_1.__decorate)([ | ||
mobx_1.action | ||
@@ -425,0 +494,0 @@ ], Router.prototype, "_update", null); |
{ | ||
"name": "boring-router", | ||
"version": "0.4.7", | ||
"version": "0.5.0", | ||
"description": "A type-safe MobX router with parallel routing support.", | ||
"license": "MIT", | ||
"author": "Chengdu Mufan Technology Co., Ltd.", | ||
"repository": { | ||
@@ -9,3 +11,2 @@ "type": "git", | ||
}, | ||
"license": "MIT", | ||
"scripts": { | ||
@@ -22,18 +23,18 @@ "test": "jest" | ||
"peerDependencies": { | ||
"mobx": "5" | ||
"mobx": "6" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^26.0.2", | ||
"@types/lodash": "^4.14.157", | ||
"jest": "^26.1.0", | ||
"mobx": "^5.15.4", | ||
"ts-jest": "^26.1.1" | ||
"@types/jest": "^27.0.1", | ||
"@types/lodash": "^4.14.172", | ||
"jest": "^27.1.1", | ||
"mobx": "^6.3.3", | ||
"ts-jest": "^27.0.5" | ||
}, | ||
"dependencies": { | ||
"hyphenate": "^0.2.5", | ||
"lodash": "^4.17.15", | ||
"tslang": "^0.1.22", | ||
"tslib": "^2.0.0" | ||
"lodash": "^4.17.21", | ||
"tslang": "^0.1.23", | ||
"tslib": "^2.3.1" | ||
}, | ||
"gitHead": "88c7eade23aac2c02b83e46207f72f337e3d8cab" | ||
"gitHead": "31837e1d406f81c6927d97987e48be30bcc1ab1e" | ||
} |
@@ -6,1 +6,5 @@ # Boring Router | ||
Checkout https://makeflow.github.io/boring-router/ for documentation. | ||
## License | ||
MIT License. |
@@ -98,7 +98,6 @@ import {GeneralParamDict, GeneralSegmentDict} from './route-match'; | ||
export type ToleratedReturnType< | ||
TOriginalReturnType | ||
> = TOriginalReturnType extends Promise<infer T> | ||
? Promise<T | undefined> | undefined | ||
: TOriginalReturnType | undefined; | ||
export type ToleratedReturnType<TOriginalReturnType> = | ||
TOriginalReturnType extends Promise<infer T> | ||
? Promise<T | undefined> | undefined | ||
: TOriginalReturnType | undefined; | ||
@@ -105,0 +104,0 @@ export function tolerate<T extends (...args: any[]) => any>( |
@@ -152,6 +152,5 @@ import _ from 'lodash'; | ||
buildingPartQueryMap = new Map([ | ||
...Array.from(route._source.queryMap).map(([key, {value}]): [ | ||
string, | ||
string, | ||
] => [key, value]), | ||
...Array.from(route._source.queryMap).map( | ||
([key, {value}]): [string, string] => [key, value], | ||
), | ||
...buildingPartQueryMap, | ||
@@ -158,0 +157,0 @@ ]); |
@@ -15,5 +15,5 @@ import {IHistory} from '../history'; | ||
TSpecificGroupName extends string | undefined = string | undefined, | ||
TGroupName extends string = string | ||
TGroupName extends string = string, | ||
> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
readonly $parent: NextRouteMatch | undefined; | ||
declare readonly $parent: NextRouteMatch | undefined; | ||
@@ -20,0 +20,0 @@ /** @internal */ |
@@ -15,7 +15,6 @@ import {computed} from 'mobx'; | ||
export type RouteMatchSharedToParamDict< | ||
TRouteMatchShared | ||
> = TRouteMatchShared extends RouteMatchShared<infer TParamDict> | ||
? TParamDict | ||
: never; | ||
export type RouteMatchSharedToParamDict<TRouteMatchShared> = | ||
TRouteMatchShared extends RouteMatchShared<infer TParamDict> | ||
? TParamDict | ||
: never; | ||
@@ -46,3 +45,3 @@ export interface RouteMatchBuildOptions<TGroupName extends string> { | ||
TSpecificGroupName extends string | undefined = string | undefined, | ||
TGroupName extends string = string | ||
TGroupName extends string = string, | ||
> { | ||
@@ -281,3 +280,4 @@ /** | ||
leaves.push((group as string) as TGroupName); | ||
// eslint-disable-next-line @mufan/no-unnecessary-type-assertion | ||
leaves.push(group as string as TGroupName); | ||
} | ||
@@ -284,0 +284,0 @@ |
@@ -41,3 +41,3 @@ import { | ||
export type RouteBeforeEnterCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = (next: TRouteMatch['$next']) => Promise<boolean | void> | boolean | void; | ||
@@ -53,3 +53,3 @@ | ||
export type RouteBeforeUpdateCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = ( | ||
@@ -65,3 +65,3 @@ next: TRouteMatch['$next'], | ||
export interface RouteBeforeUpdateEntry< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> { | ||
@@ -87,3 +87,3 @@ callback: RouteBeforeUpdateCallback<TRouteMatch>; | ||
export type RouteWillEnterCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = (next: TRouteMatch['$next']) => Promise<void> | void; | ||
@@ -94,3 +94,3 @@ | ||
export type RouteWillUpdateCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = ( | ||
@@ -106,3 +106,3 @@ next: TRouteMatch['$next'], | ||
export interface RouteWillUpdateEntry< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> { | ||
@@ -160,6 +160,7 @@ callback: RouteWillUpdateCallback<TRouteMatch>; | ||
value: T, | ||
previousValue: T, | ||
reaction: IReactionPublic, | ||
) => void; | ||
export type RouteReactionOptions = IReactionOptions | undefined; | ||
export type RouteReactionOptions<T> = IReactionOptions<T> | undefined; | ||
@@ -170,3 +171,3 @@ interface RouteReactionEntry<T = unknown> { | ||
effect: RouteReactionEffect<T>; | ||
options: RouteReactionOptions | undefined; | ||
options: RouteReactionOptions<T> | undefined; | ||
disposer: RouteReactiveDisposer | undefined; | ||
@@ -182,7 +183,7 @@ } | ||
export type RouteBeforeEnterOrUpdateCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = (next: TRouteMatch['$next']) => Promise<boolean | void> | boolean | void; | ||
export type RouteWillEnterOrUpdateCallback< | ||
TRouteMatch extends RouteMatch = RouteMatch | ||
TRouteMatch extends RouteMatch = RouteMatch, | ||
> = (next: TRouteMatch['$next']) => Promise<void> | void; | ||
@@ -210,9 +211,8 @@ | ||
export type RouteServiceExtension< | ||
TRouteMatch extends RouteMatch | ||
> = OmitValueWithType< | ||
OmitValueOfKey<TRouteMatch, keyof RouteMatch>, | ||
RouteMatch, | ||
false | ||
>; | ||
export type RouteServiceExtension<TRouteMatch extends RouteMatch> = | ||
OmitValueWithType< | ||
OmitValueOfKey<TRouteMatch, keyof RouteMatch>, | ||
RouteMatch, | ||
false | ||
>; | ||
@@ -267,10 +267,8 @@ type RouteReactiveEntry = RouteAutorunEntry | RouteReactionEntry; | ||
TParamDict extends GeneralParamDict = GeneralParamDict, | ||
TNextRouteMatch extends NextRouteMatch<TParamDict> = NextRouteMatch< | ||
TParamDict | ||
>, | ||
TNextRouteMatch extends NextRouteMatch<TParamDict> = NextRouteMatch<TParamDict>, | ||
TSpecificGroupName extends string | undefined = string | undefined, | ||
TGroupName extends string = string, | ||
TMetadata extends object = object | ||
TMetadata extends object = object, | ||
> extends RouteMatchShared<TParamDict, TSpecificGroupName, TGroupName> { | ||
readonly $parent: RouteMatch | undefined; | ||
declare readonly $parent: RouteMatch | undefined; | ||
@@ -490,3 +488,3 @@ readonly $next!: TNextRouteMatch; | ||
effect: RouteReactionEffect<T>, | ||
options?: RouteReactionOptions, | ||
options?: RouteReactionOptions<T>, | ||
): RouteHookRemovalCallback { | ||
@@ -593,6 +591,4 @@ let reactionEntry: RouteReactionEntry = { | ||
if (parent instanceof RouteMatch && parent._parallel) { | ||
let { | ||
groups: parentGroups = [], | ||
matches: parentMatches = [], | ||
} = parent._parallel; | ||
let {groups: parentGroups = [], matches: parentMatches = []} = | ||
parent._parallel; | ||
@@ -599,0 +595,0 @@ let parentGroupSet = new Set(parentGroups); |
@@ -45,9 +45,6 @@ import hyphenate from 'hyphenate'; | ||
type NestedRouteSchemaDictType< | ||
TRouteSchema | ||
> = TRouteSchema extends RouteSchemaChildrenSection< | ||
infer TNestedRouteSchemaDict | ||
> | ||
? TNestedRouteSchemaDict | ||
: {}; | ||
type NestedRouteSchemaDictType<TRouteSchema> = | ||
TRouteSchema extends RouteSchemaChildrenSection<infer TNestedRouteSchemaDict> | ||
? TNestedRouteSchemaDict | ||
: {}; | ||
@@ -62,14 +59,11 @@ interface RouteSchemaExtensionSection<TRouteMatchExtension> { | ||
type RouteMatchMetadataType< | ||
TRouteSchema, | ||
TUpperMetadata | ||
> = TRouteSchema extends RouteSchemaMetadataSection<infer TMetadata> | ||
? TMetadata & TUpperMetadata | ||
: TUpperMetadata; | ||
type RouteMatchMetadataType<TRouteSchema, TUpperMetadata> = | ||
TRouteSchema extends RouteSchemaMetadataSection<infer TMetadata> | ||
? TMetadata & TUpperMetadata | ||
: TUpperMetadata; | ||
type RouteMatchExtensionType< | ||
TRouteSchema | ||
> = TRouteSchema extends RouteSchemaExtensionSection<infer TRouteMatchExtension> | ||
? TRouteMatchExtension | ||
: {}; | ||
type RouteMatchExtensionType<TRouteSchema> = | ||
TRouteSchema extends RouteSchemaExtensionSection<infer TRouteMatchExtension> | ||
? TRouteMatchExtension | ||
: {}; | ||
@@ -82,3 +76,3 @@ type RouteMatchSegmentType< | ||
TGroupName extends string, | ||
TMetadata extends object | ||
TMetadata extends object, | ||
> = { | ||
@@ -103,3 +97,3 @@ [K in Extract<keyof TRouteSchemaDict, string>]: RouteMatchType< | ||
TParamDict extends Dict<string | undefined>, | ||
TMetadata extends object | ||
TMetadata extends object, | ||
> = RouteMatch< | ||
@@ -135,3 +129,3 @@ TParamDict, | ||
TGroupName extends string, | ||
TMetadata extends object | ||
TMetadata extends object, | ||
> = __RouteMatchType< | ||
@@ -152,3 +146,3 @@ TRouteSchema, | ||
TSpecificGroupName extends string | undefined, | ||
TGroupName extends string | ||
TGroupName extends string, | ||
> = { | ||
@@ -171,3 +165,3 @@ [K in Extract<keyof TRouteSchemaDict, string>]: NextRouteMatchType< | ||
TGroupName extends string, | ||
TParamDict extends Dict<string | undefined> | ||
TParamDict extends Dict<string | undefined>, | ||
> = NextRouteMatch<TParamDict, TSpecificGroupName, TGroupName> & | ||
@@ -187,3 +181,3 @@ NextRouteMatchSegmentType< | ||
TSpecificGroupName extends string | undefined, | ||
TGroupName extends string | ||
TGroupName extends string, | ||
> = __NextRouteMatchType< | ||
@@ -202,3 +196,3 @@ TRouteSchema, | ||
TGroupName extends string, | ||
TMetadata extends object = {} | ||
TMetadata extends object = {}, | ||
> = RouteMatchType< | ||
@@ -319,3 +313,3 @@ TRouteSchema, | ||
TRouteSchema extends RootRouteSchema, | ||
TSpecificGroupName extends TGroupName | ||
TSpecificGroupName extends TGroupName, | ||
>( | ||
@@ -535,3 +529,4 @@ group: TSpecificGroupName, | ||
runInAction(() => { | ||
matchingSource.groupToMatchToMatchEntryMapMap = groupToMatchToMatchEntryMapMap; | ||
matchingSource.groupToMatchToMatchEntryMapMap = | ||
groupToMatchToMatchEntryMapMap; | ||
matchingSource.pathMap = pathMap; | ||
@@ -548,8 +543,7 @@ | ||
_.compact( | ||
Array.from(queryMap).map(([key, value]): | ||
| [string, RouteSourceQuery] | ||
| undefined => | ||
matchingQueryKeyToIdMap.has(key) | ||
? [key, {id: matchingQueryKeyToIdMap.get(key)!, value}] | ||
: undefined, | ||
Array.from(queryMap).map( | ||
([key, value]): [string, RouteSourceQuery] | undefined => | ||
matchingQueryKeyToIdMap.has(key) | ||
? [key, {id: matchingQueryKeyToIdMap.get(key)!, value}] | ||
: undefined, | ||
), | ||
@@ -605,5 +599,4 @@ ), | ||
let previousMatchToMatchEntryMap = this._source.groupToMatchToMatchEntryMapMap.get( | ||
group, | ||
); | ||
let previousMatchToMatchEntryMap = | ||
this._source.groupToMatchToMatchEntryMapMap.get(group); | ||
@@ -740,5 +733,4 @@ if (!previousMatchToMatchEntryMap) { | ||
let matchToMatchEntryMap = matchingSource.groupToMatchToMatchEntryMapMap.get( | ||
group, | ||
)!; | ||
let matchToMatchEntryMap = | ||
matchingSource.groupToMatchToMatchEntryMapMap.get(group)!; | ||
@@ -793,5 +785,4 @@ source.groupToMatchToMatchEntryMapMap.set(group, matchToMatchEntryMap); | ||
for (let routeMatch of routeMatches) { | ||
let {matched, exactlyMatched, segment, rest} = routeMatch._match( | ||
upperRest, | ||
); | ||
let {matched, exactlyMatched, segment, rest} = | ||
routeMatch._match(upperRest); | ||
@@ -798,0 +789,0 @@ if (!matched) { |
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
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
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
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
238408
57
4744
1
10
+ Addedmobx@6.13.6(transitive)
- Removedmobx@5.15.7(transitive)
Updatedlodash@^4.17.21
Updatedtslang@^0.1.23
Updatedtslib@^2.3.1