Comparing version 8.0.3 to 8.0.4
@@ -0,1 +1,6 @@ | ||
## v8.0.4 (2024-03-06) | ||
- [#336] Calling recognize should not affect the transition.from query params for subsequent transitions ([@chbonser](https://github.com/chbonser)) | ||
## v8.0.3 (2022-08-27) | ||
@@ -2,0 +7,0 @@ |
@@ -42,3 +42,6 @@ import { Promise } from 'rsvp'; | ||
} | ||
export declare function toReadOnlyRouteInfo<R extends Route>(routeInfos: InternalRouteInfo<R>[], queryParams?: Dict<unknown>, includeAttributes?: boolean): RouteInfoWithAttributes[] | RouteInfo[]; | ||
export declare function toReadOnlyRouteInfo<R extends Route>(routeInfos: InternalRouteInfo<R>[], queryParams?: Dict<unknown>, options?: { | ||
includeAttributes?: boolean; | ||
localizeMapUpdates?: boolean; | ||
}): RouteInfoWithAttributes[] | RouteInfo[]; | ||
export default class InternalRouteInfo<R extends Route> { | ||
@@ -45,0 +48,0 @@ private _routePromise?; |
@@ -19,3 +19,7 @@ "use strict"; | ||
function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = false) { | ||
function toReadOnlyRouteInfo(routeInfos, queryParams = {}, options = { | ||
includeAttributes: false, | ||
localizeMapUpdates: false | ||
}) { | ||
const LOCAL_ROUTE_INFOS = new WeakMap(); | ||
return routeInfos.map((info, i) => { | ||
@@ -32,10 +36,16 @@ let { | ||
if (ROUTE_INFOS.has(key) && includeAttributes) { | ||
if (ROUTE_INFOS.has(key) && options.includeAttributes) { | ||
let routeInfo = ROUTE_INFOS.get(key); | ||
routeInfo = attachMetadata(route, routeInfo); | ||
let routeInfoWithAttribute = createRouteInfoWithAttributes(routeInfo, context); | ||
ROUTE_INFOS.set(key, routeInfoWithAttribute); | ||
LOCAL_ROUTE_INFOS.set(key, routeInfo); | ||
if (!options.localizeMapUpdates) { | ||
ROUTE_INFOS.set(key, routeInfoWithAttribute); | ||
} | ||
return routeInfoWithAttribute; | ||
} | ||
const routeInfosRef = options.localizeMapUpdates ? LOCAL_ROUTE_INFOS : ROUTE_INFOS; | ||
let routeInfo = { | ||
@@ -48,3 +58,3 @@ find(predicate, thisArg) { | ||
arr = routeInfos.map( // SAFETY: This should be safe since it is just for use as a key | ||
info => ROUTE_INFOS.get(info)); | ||
info => routeInfosRef.get(info)); | ||
} | ||
@@ -54,3 +64,3 @@ | ||
// SAFETY: This should be safe since it is just for use as a key | ||
publicInfo = ROUTE_INFOS.get(routeInfos[i]); | ||
publicInfo = routeInfosRef.get(routeInfos[i]); | ||
@@ -85,3 +95,3 @@ if (predicate.call(thisArg, publicInfo, i, arr)) { | ||
return ROUTE_INFOS.get(parent); | ||
return routeInfosRef.get(parent); | ||
}, | ||
@@ -97,3 +107,3 @@ | ||
return ROUTE_INFOS.get(child); | ||
return routeInfosRef.get(child); | ||
}, | ||
@@ -116,3 +126,3 @@ | ||
if (includeAttributes) { | ||
if (options.includeAttributes) { | ||
routeInfo = createRouteInfoWithAttributes(routeInfo, context); | ||
@@ -122,3 +132,9 @@ } // SAFETY: This should be safe since it is just for use as a key | ||
ROUTE_INFOS.set(info, routeInfo); | ||
LOCAL_ROUTE_INFOS.set(info, routeInfo); | ||
if (!options.localizeMapUpdates) { | ||
// SAFETY: This should be safe since it is just for use as a key | ||
ROUTE_INFOS.set(info, routeInfo); | ||
} | ||
return routeInfo; | ||
@@ -125,0 +141,0 @@ }); |
@@ -122,3 +122,6 @@ "use strict"; | ||
let readonlyInfos = (0, _routeInfo.toReadOnlyRouteInfo)(newState.routeInfos, newState.queryParams); | ||
let readonlyInfos = (0, _routeInfo.toReadOnlyRouteInfo)(newState.routeInfos, newState.queryParams, { | ||
includeAttributes: false, | ||
localizeMapUpdates: true | ||
}); | ||
return readonlyInfos[readonlyInfos.length - 1]; | ||
@@ -137,3 +140,6 @@ } | ||
return newTransition.then(() => { | ||
let routeInfosWithAttributes = (0, _routeInfo.toReadOnlyRouteInfo)(newState.routeInfos, newTransition[_transition.QUERY_PARAMS_SYMBOL], true); | ||
let routeInfosWithAttributes = (0, _routeInfo.toReadOnlyRouteInfo)(newState.routeInfos, newTransition[_transition.QUERY_PARAMS_SYMBOL], { | ||
includeAttributes: true, | ||
localizeMapUpdates: false | ||
}); | ||
return routeInfosWithAttributes[routeInfosWithAttributes.length - 1]; | ||
@@ -626,3 +632,6 @@ }); | ||
if (newTransition !== undefined && oldRouteInfos.length > 0) { | ||
let fromInfos = (0, _routeInfo.toReadOnlyRouteInfo)(oldRouteInfos, Object.assign({}, this._lastQueryParams), true); | ||
let fromInfos = (0, _routeInfo.toReadOnlyRouteInfo)(oldRouteInfos, Object.assign({}, this._lastQueryParams), { | ||
includeAttributes: true, | ||
localizeMapUpdates: false | ||
}); | ||
newTransition.from = fromInfos[fromInfos.length - 1] || null; | ||
@@ -634,3 +643,6 @@ } | ||
if (newTransition !== undefined && newRouteInfos.length > 0) { | ||
let toInfos = (0, _routeInfo.toReadOnlyRouteInfo)(newRouteInfos, Object.assign({}, newTransition[_transition.QUERY_PARAMS_SYMBOL]), includeAttributes); | ||
let toInfos = (0, _routeInfo.toReadOnlyRouteInfo)(newRouteInfos, Object.assign({}, newTransition[_transition.QUERY_PARAMS_SYMBOL]), { | ||
includeAttributes, | ||
localizeMapUpdates: false | ||
}); | ||
newTransition.to = toInfos[toInfos.length - 1] || null; | ||
@@ -637,0 +649,0 @@ } |
@@ -42,3 +42,6 @@ import { Promise } from 'rsvp'; | ||
} | ||
export declare function toReadOnlyRouteInfo<R extends Route>(routeInfos: InternalRouteInfo<R>[], queryParams?: Dict<unknown>, includeAttributes?: boolean): RouteInfoWithAttributes[] | RouteInfo[]; | ||
export declare function toReadOnlyRouteInfo<R extends Route>(routeInfos: InternalRouteInfo<R>[], queryParams?: Dict<unknown>, options?: { | ||
includeAttributes?: boolean; | ||
localizeMapUpdates?: boolean; | ||
}): RouteInfoWithAttributes[] | RouteInfo[]; | ||
export default class InternalRouteInfo<R extends Route> { | ||
@@ -45,0 +48,0 @@ private _routePromise?; |
@@ -6,3 +6,4 @@ import { Promise } from 'rsvp'; | ||
let ROUTE_INFOS = new WeakMap(); | ||
export function toReadOnlyRouteInfo(routeInfos, queryParams = {}, includeAttributes = false) { | ||
export function toReadOnlyRouteInfo(routeInfos, queryParams = {}, options = { includeAttributes: false, localizeMapUpdates: false }) { | ||
const LOCAL_ROUTE_INFOS = new WeakMap(); | ||
return routeInfos.map((info, i) => { | ||
@@ -12,9 +13,13 @@ let { name, params, paramNames, context, route } = info; | ||
let key = info; | ||
if (ROUTE_INFOS.has(key) && includeAttributes) { | ||
if (ROUTE_INFOS.has(key) && options.includeAttributes) { | ||
let routeInfo = ROUTE_INFOS.get(key); | ||
routeInfo = attachMetadata(route, routeInfo); | ||
let routeInfoWithAttribute = createRouteInfoWithAttributes(routeInfo, context); | ||
ROUTE_INFOS.set(key, routeInfoWithAttribute); | ||
LOCAL_ROUTE_INFOS.set(key, routeInfo); | ||
if (!options.localizeMapUpdates) { | ||
ROUTE_INFOS.set(key, routeInfoWithAttribute); | ||
} | ||
return routeInfoWithAttribute; | ||
} | ||
const routeInfosRef = options.localizeMapUpdates ? LOCAL_ROUTE_INFOS : ROUTE_INFOS; | ||
let routeInfo = { | ||
@@ -27,7 +32,7 @@ find(predicate, thisArg) { | ||
// SAFETY: This should be safe since it is just for use as a key | ||
(info) => ROUTE_INFOS.get(info)); | ||
(info) => routeInfosRef.get(info)); | ||
} | ||
for (let i = 0; routeInfos.length > i; i++) { | ||
// SAFETY: This should be safe since it is just for use as a key | ||
publicInfo = ROUTE_INFOS.get(routeInfos[i]); | ||
publicInfo = routeInfosRef.get(routeInfos[i]); | ||
if (predicate.call(thisArg, publicInfo, i, arr)) { | ||
@@ -54,3 +59,3 @@ return publicInfo; | ||
// SAFETY: This should be safe since it is just for use as a key | ||
return ROUTE_INFOS.get(parent); | ||
return routeInfosRef.get(parent); | ||
}, | ||
@@ -63,3 +68,3 @@ get child() { | ||
// SAFETY: This should be safe since it is just for use as a key | ||
return ROUTE_INFOS.get(child); | ||
return routeInfosRef.get(child); | ||
}, | ||
@@ -77,7 +82,11 @@ get localName() { | ||
}; | ||
if (includeAttributes) { | ||
if (options.includeAttributes) { | ||
routeInfo = createRouteInfoWithAttributes(routeInfo, context); | ||
} | ||
// SAFETY: This should be safe since it is just for use as a key | ||
ROUTE_INFOS.set(info, routeInfo); | ||
LOCAL_ROUTE_INFOS.set(info, routeInfo); | ||
if (!options.localizeMapUpdates) { | ||
// SAFETY: This should be safe since it is just for use as a key | ||
ROUTE_INFOS.set(info, routeInfo); | ||
} | ||
return routeInfo; | ||
@@ -84,0 +93,0 @@ }); |
@@ -91,3 +91,6 @@ import RouteRecognizer from 'route-recognizer'; | ||
} | ||
let readonlyInfos = toReadOnlyRouteInfo(newState.routeInfos, newState.queryParams); | ||
let readonlyInfos = toReadOnlyRouteInfo(newState.routeInfos, newState.queryParams, { | ||
includeAttributes: false, | ||
localizeMapUpdates: true, | ||
}); | ||
return readonlyInfos[readonlyInfos.length - 1]; | ||
@@ -103,3 +106,6 @@ } | ||
return newTransition.then(() => { | ||
let routeInfosWithAttributes = toReadOnlyRouteInfo(newState.routeInfos, newTransition[QUERY_PARAMS_SYMBOL], true); | ||
let routeInfosWithAttributes = toReadOnlyRouteInfo(newState.routeInfos, newTransition[QUERY_PARAMS_SYMBOL], { | ||
includeAttributes: true, | ||
localizeMapUpdates: false, | ||
}); | ||
return routeInfosWithAttributes[routeInfosWithAttributes.length - 1]; | ||
@@ -550,3 +556,6 @@ }); | ||
if (newTransition !== undefined && oldRouteInfos.length > 0) { | ||
let fromInfos = toReadOnlyRouteInfo(oldRouteInfos, Object.assign({}, this._lastQueryParams), true); | ||
let fromInfos = toReadOnlyRouteInfo(oldRouteInfos, Object.assign({}, this._lastQueryParams), { | ||
includeAttributes: true, | ||
localizeMapUpdates: false, | ||
}); | ||
newTransition.from = fromInfos[fromInfos.length - 1] || null; | ||
@@ -557,3 +566,3 @@ } | ||
if (newTransition !== undefined && newRouteInfos.length > 0) { | ||
let toInfos = toReadOnlyRouteInfo(newRouteInfos, Object.assign({}, newTransition[QUERY_PARAMS_SYMBOL]), includeAttributes); | ||
let toInfos = toReadOnlyRouteInfo(newRouteInfos, Object.assign({}, newTransition[QUERY_PARAMS_SYMBOL]), { includeAttributes, localizeMapUpdates: false }); | ||
newTransition.to = toInfos[toInfos.length - 1] || null; | ||
@@ -560,0 +569,0 @@ } |
{ | ||
"name": "router_js", | ||
"version": "8.0.3", | ||
"version": "8.0.4", | ||
"description": "A lightweight JavaScript library is built on top of route-recognizer and rsvp.js to provide an API for handling routes", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
365661
5341