@uirouter/core
Advanced tools
Comparing version 5.0.19 to 5.0.20
@@ -140,5 +140,4 @@ /** | ||
} | ||
var _defaultsList = defaultsList.concat({}).reverse(); | ||
var defaultVals = extend.apply(null, _defaultsList); | ||
return extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals))); | ||
var defaultVals = extend.apply(void 0, [{}].concat(defaultsList.reverse())); | ||
return extend(defaultVals, pick(opts || {}, Object.keys(defaultVals))); | ||
} | ||
@@ -145,0 +144,0 @@ /** Reduce function that merges each element of the list into a single object, using extend */ |
import { Predicate } from './common'; | ||
import { StateObject } from '../state/stateObject'; | ||
export declare const isUndefined: (x: any) => boolean; | ||
@@ -14,3 +13,2 @@ export declare const isDefined: Predicate<any>; | ||
export declare const isRegExp: (x: any) => x is RegExp; | ||
export declare const isState: (x: any) => x is StateObject; | ||
/** | ||
@@ -17,0 +15,0 @@ * Predicate which checks if a value is injectable |
@@ -10,3 +10,2 @@ /** Predicates | ||
import { and, not, pipe, prop, or } from './hof'; | ||
import { StateObject } from '../state/stateObject'; | ||
var toStr = Object.prototype.toString; | ||
@@ -25,3 +24,2 @@ var tis = function (t) { return function (x) { return typeof x === t; }; }; | ||
export var isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; }); | ||
export var isState = StateObject.isState; | ||
/** | ||
@@ -28,0 +26,0 @@ * Predicate which checks if a value is injectable |
@@ -0,1 +1,8 @@ | ||
/** | ||
* Functions that manipulate strings | ||
* | ||
* Although these functions are exported, they are subject to change without notice. | ||
* | ||
* @module common_strings | ||
*/ /** */ | ||
import { IInjectable } from './common'; | ||
@@ -2,0 +9,0 @@ /** |
@@ -8,8 +8,6 @@ /** | ||
*/ /** */ | ||
import { isString, isArray, isDefined, isNull, isPromise, isInjectable, isObject } from './predicates'; | ||
import { isArray, isFunction, isInjectable, isNull, isObject, isPromise, isString, isUndefined } from './predicates'; | ||
import { Rejection } from '../transition/rejectFactory'; | ||
import { identity, tail, pushR } from './common'; | ||
import { pattern, is, not, val, invoke } from './hof'; | ||
import { Transition } from '../transition/transition'; | ||
import { Resolvable } from '../resolve/resolvable'; | ||
import { identity, pushR, tail } from './common'; | ||
import { pattern, val } from './hof'; | ||
/** | ||
@@ -48,11 +46,2 @@ * Returns a string shortened to a maximum length | ||
} | ||
function _toJson(obj) { | ||
return JSON.stringify(obj); | ||
} | ||
function _fromJson(json) { | ||
return isString(json) ? JSON.parse(json) : json; | ||
} | ||
function promiseToString(p) { | ||
return "Promise(" + JSON.stringify(p) + ")"; | ||
} | ||
export function functionToString(fn) { | ||
@@ -72,20 +61,15 @@ var fnStr = fnToString(fn); | ||
} | ||
var stringifyPatternFn = null; | ||
var stringifyPattern = function (value) { | ||
var isRejection = Rejection.isRejectionPromise; | ||
stringifyPatternFn = | ||
stringifyPatternFn || | ||
pattern([ | ||
[not(isDefined), val('undefined')], | ||
[isNull, val('null')], | ||
[isPromise, val('[Promise]')], | ||
[isRejection, function (x) { return x._transitionRejection.toString(); }], | ||
[is(Rejection), invoke('toString')], | ||
[is(Transition), invoke('toString')], | ||
[is(Resolvable), invoke('toString')], | ||
[isInjectable, functionToString], | ||
[val(true), identity], | ||
]); | ||
return stringifyPatternFn(value); | ||
var isRejection = Rejection.isRejectionPromise; | ||
var hasToString = function (obj) { | ||
return isObject(obj) && !isArray(obj) && obj.constructor !== Object && isFunction(obj.toString); | ||
}; | ||
var stringifyPattern = pattern([ | ||
[isUndefined, val('undefined')], | ||
[isNull, val('null')], | ||
[isPromise, val('[Promise]')], | ||
[isRejection, function (x) { return x._transitionRejection.toString(); }], | ||
[hasToString, function (x) { return x.toString(); }], | ||
[isInjectable, functionToString], | ||
[val(true), identity], | ||
]); | ||
export function stringify(o) { | ||
@@ -101,2 +85,8 @@ var seen = []; | ||
} | ||
if (isUndefined(o)) { | ||
// Workaround for IE & Edge Spec incompatibility where replacer function would not be called when JSON.stringify | ||
// is given `undefined` as value. To work around that, we simply detect `undefined` and bail out early by | ||
// manually stringifying it. | ||
return format(o); | ||
} | ||
return JSON.stringify(o, function (key, value) { return format(value); }).replace(/\\"/g, '"'); | ||
@@ -103,0 +93,0 @@ } |
@@ -28,3 +28,3 @@ import { Transition } from '../transition/transition'; | ||
UIVIEW = 3, | ||
VIEWCONFIG = 4, | ||
VIEWCONFIG = 4 | ||
} | ||
@@ -43,3 +43,3 @@ export { Category }; | ||
/** @hidden */ | ||
private _set(enabled, categories); | ||
private _set; | ||
/** | ||
@@ -46,0 +46,0 @@ * Enables a trace [[Category]] |
@@ -213,6 +213,6 @@ /** | ||
var uiView = _a.uiView, viewConfig = _a.viewConfig; | ||
var _b; | ||
var uiv = uiView && uiView.fqn; | ||
var cfg = viewConfig && viewConfig.viewDecl.$context.name + ": (" + viewConfig.viewDecl.$name + ")"; | ||
return _b = {}, _b[uivheader] = uiv, _b[cfgheader] = cfg, _b; | ||
var _b; | ||
}) | ||
@@ -219,0 +219,0 @@ .sort(function (a, b) { return (a[uivheader] || '').localeCompare(b[uivheader] || ''); }); |
@@ -0,2 +1,3 @@ | ||
/** @module hooks */ /** */ | ||
import { TransitionService } from '../transition/transitionService'; | ||
export declare const registerIgnoredTransitionHook: (transitionService: TransitionService) => Function; |
@@ -0,1 +1,11 @@ | ||
/** | ||
* # Core classes and interfaces | ||
* | ||
* The classes and interfaces that are core to ui-router and do not belong | ||
* to a more specific subsystem (such as resolve). | ||
* | ||
* @coreapi | ||
* @preferred | ||
* @module core | ||
*/ /** for typedoc */ | ||
import { UIRouter } from './router'; | ||
@@ -2,0 +12,0 @@ /** |
@@ -132,3 +132,3 @@ /** | ||
*/ | ||
type: string | ParamType; | ||
type?: string | ParamType; | ||
/** | ||
@@ -167,3 +167,3 @@ * The parameter's `array` mode | ||
*/ | ||
array: boolean; | ||
array?: boolean; | ||
/** | ||
@@ -222,3 +222,3 @@ * Squash mode: omit default parameter values in URL | ||
*/ | ||
squash: boolean | string; | ||
squash?: boolean | string; | ||
/** | ||
@@ -241,3 +241,3 @@ * @internalapi | ||
*/ | ||
replace: Replace[]; | ||
replace?: Replace[]; | ||
/** | ||
@@ -249,3 +249,3 @@ * @hidden | ||
*/ | ||
isOptional: boolean; | ||
isOptional?: boolean; | ||
/** | ||
@@ -271,3 +271,3 @@ * Dynamic flag | ||
*/ | ||
dynamic: boolean; | ||
dynamic?: boolean; | ||
/** | ||
@@ -309,3 +309,3 @@ * Disables url-encoding of parameter values | ||
*/ | ||
raw: boolean; | ||
raw?: boolean; | ||
/** | ||
@@ -347,3 +347,3 @@ * Enables/disables inheriting of this parameter's value | ||
*/ | ||
inherit: boolean; | ||
inherit?: boolean; | ||
} | ||
@@ -350,0 +350,0 @@ /** @internalapi */ |
@@ -1,4 +0,5 @@ | ||
import { RawParams, ParamDeclaration } from '../params/interface'; | ||
import { RawParams } from '../params/interface'; | ||
import { ParamType } from './paramType'; | ||
import { UrlMatcherFactory } from '../url/urlMatcherFactory'; | ||
import { StateDeclaration } from '../state'; | ||
/** @internalapi */ | ||
@@ -8,3 +9,3 @@ declare enum DefType { | ||
SEARCH = 1, | ||
CONFIG = 2, | ||
CONFIG = 2 | ||
} | ||
@@ -57,3 +58,3 @@ export { DefType }; | ||
static validates(params: Param[], values?: RawParams): boolean; | ||
constructor(id: string, type: ParamType, config: ParamDeclaration, location: DefType, urlMatcherFactory: UrlMatcherFactory); | ||
constructor(id: string, type: ParamType, location: DefType, urlMatcherFactory: UrlMatcherFactory, state: StateDeclaration); | ||
isDefaultValue(value: any): boolean; | ||
@@ -60,0 +61,0 @@ /** |
@@ -24,5 +24,12 @@ /** | ||
export { DefType }; | ||
function getParamDeclaration(paramName, location, state) { | ||
var noReloadOnSearch = (state.reloadOnSearch === false && location === DefType.SEARCH) || undefined; | ||
var dynamic = [state.dynamic, noReloadOnSearch].find(isDefined); | ||
var defaultConfig = isDefined(dynamic) ? { dynamic: dynamic } : {}; | ||
var paramConfig = unwrapShorthand(state && state.params && state.params[paramName]); | ||
return extend(defaultConfig, paramConfig); | ||
} | ||
/** @hidden */ | ||
function unwrapShorthand(cfg) { | ||
cfg = (isShorthand(cfg) && { value: cfg }) || cfg; | ||
cfg = isShorthand(cfg) ? { value: cfg } : cfg; | ||
getStaticDefaultValue['__cacheable'] = true; | ||
@@ -32,5 +39,4 @@ function getStaticDefaultValue() { | ||
} | ||
return extend(cfg, { | ||
$$fn: isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue, | ||
}); | ||
var $$fn = isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue; | ||
return extend(cfg, { $$fn: $$fn }); | ||
} | ||
@@ -85,4 +91,4 @@ /** @hidden */ | ||
var Param = /** @class */ (function () { | ||
function Param(id, type, config, location, urlMatcherFactory) { | ||
config = unwrapShorthand(config); | ||
function Param(id, type, location, urlMatcherFactory, state) { | ||
var config = getParamDeclaration(id, location, state); | ||
type = getType(config, type, location, id, urlMatcherFactory.paramTypes); | ||
@@ -89,0 +95,0 @@ var arrayMode = getArrayMode(); |
@@ -148,2 +148,3 @@ /** | ||
inherit: type.inherit, | ||
raw: type.raw, | ||
is: arrayHandler(type.is.bind(type), true), | ||
@@ -150,0 +151,0 @@ $arrayMode: mode, |
@@ -52,3 +52,3 @@ /** | ||
/** Provides services related to ui-view synchronization */ | ||
this.viewService = new ViewService(); | ||
this.viewService = new ViewService(this); | ||
/** Global router state */ | ||
@@ -55,0 +55,0 @@ this.globals = new UIRouterGlobals(); |
@@ -106,25 +106,2 @@ /** | ||
* ``` | ||
* | ||
* A state declaration may also be an ES6 class which implements the StateDeclaration interface | ||
* and has a `@State()` decorator | ||
* | ||
* #### Example: | ||
* ```js | ||
* import { State } from "@uirouter/core" | ||
* import { FolderService } from "../folder.service" | ||
* // StateDeclaration class | ||
* @State() | ||
* export class FoldersState implements StateDeclaration { | ||
* name: 'folders', | ||
* url: '/folders', | ||
* component: FoldersComponent | ||
* | ||
* @Resolve({ deps: [ FolderService ] }) | ||
* allfolders(FolderService) { | ||
* return FolderService.list(); | ||
* }, | ||
* } | ||
* | ||
* registry.register(FoldersState); | ||
* ``` | ||
*/ | ||
@@ -687,4 +664,15 @@ export interface StateDeclaration { | ||
/** | ||
* @deprecated define individual parameters as [[ParamDeclaration.dynamic]] | ||
* Marks all the state's parameters as `dynamic`. | ||
* | ||
* All parameters on the state will use this value for `dynamic` as a default. | ||
* Individual parameters may override this default using [[ParamDeclaration.dynamic]] in the [[params]] block. | ||
* | ||
* Note: this value overrides the `dynamic` value on a custom parameter type ([[ParamTypeDefinition.dynamic]]). | ||
*/ | ||
dynamic?: boolean; | ||
/** | ||
* Marks all query parameters as [[ParamDeclaration.dynamic]] | ||
* | ||
* @deprecated use either [[dynamic]] or [[ParamDeclaration.dynamic]] | ||
*/ | ||
reloadOnSearch?: boolean; | ||
@@ -691,0 +679,0 @@ } |
@@ -1,6 +0,7 @@ | ||
/** @module state */ /** for typedoc */ | ||
import { omit, noop, extend, inherit, values, applyPairs, tail, mapObj, identity } from '../common/common'; | ||
import { isDefined, isFunction, isString, isArray } from '../common/predicates'; | ||
/** @module state */ | ||
/** for typedoc */ | ||
import { applyPairs, extend, identity, inherit, mapObj, noop, omit, tail, values } from '../common/common'; | ||
import { isArray, isDefined, isFunction, isString } from '../common/predicates'; | ||
import { stringify } from '../common/strings'; | ||
import { prop, pattern, is, pipe, val } from '../common/hof'; | ||
import { is, pattern, pipe, prop, val } from '../common/hof'; | ||
import { Resolvable } from '../resolve/resolvable'; | ||
@@ -28,24 +29,16 @@ import { services } from '../common/coreservices'; | ||
var getUrlBuilder = function ($urlMatcherFactoryProvider, root) { | ||
return function urlBuilder(state) { | ||
var stateDec = state; | ||
return function urlBuilder(stateObject) { | ||
var state = stateObject.self; | ||
// For future states, i.e., states whose name ends with `.**`, | ||
// match anything that starts with the url prefix | ||
if (stateDec && stateDec.url && stateDec.name && stateDec.name.match(/\.\*\*$/)) { | ||
stateDec.url += '{remainder:any}'; // match any path (.*) | ||
if (state && state.url && state.name && state.name.match(/\.\*\*$/)) { | ||
state.url += '{remainder:any}'; // match any path (.*) | ||
} | ||
var parsed = parseUrl(stateDec.url), parent = state.parent; | ||
var url = !parsed | ||
? stateDec.url | ||
: $urlMatcherFactoryProvider.compile(parsed.val, { | ||
params: state.params || {}, | ||
paramMap: function (paramConfig, isSearch) { | ||
if (stateDec.reloadOnSearch === false && isSearch) | ||
paramConfig = extend(paramConfig || {}, { dynamic: true }); | ||
return paramConfig; | ||
}, | ||
}); | ||
var parent = stateObject.parent; | ||
var parsed = parseUrl(state.url); | ||
var url = !parsed ? state.url : $urlMatcherFactoryProvider.compile(parsed.val, { state: state }); | ||
if (!url) | ||
return null; | ||
if (!$urlMatcherFactoryProvider.isMatcher(url)) | ||
throw new Error("Invalid url '" + url + "' in state '" + state + "'"); | ||
throw new Error("Invalid url '" + url + "' in state '" + stateObject + "'"); | ||
return parsed && parsed.root ? url : ((parent && parent.navigable) || root()).url.append(url); | ||
@@ -61,3 +54,3 @@ }; | ||
return function paramsBuilder(state) { | ||
var makeConfigParam = function (config, id) { return paramFactory.fromConfig(id, null, config); }; | ||
var makeConfigParam = function (config, id) { return paramFactory.fromConfig(id, null, state.self); }; | ||
var urlParams = (state.url && state.url.parameters({ inherit: false })) || []; | ||
@@ -150,3 +143,3 @@ var nonUrlParams = values(mapObj(omit(state.params || {}, urlParams.map(prop('id'))), makeConfigParam)); | ||
var getToken = function (p) { return p.provide || p.token; }; | ||
/** Given a literal resolve or provider object, returns a Resolvable */ | ||
// prettier-ignore: Given a literal resolve or provider object, returns a Resolvable | ||
var literal2Resolvable = pattern([ | ||
@@ -159,13 +152,9 @@ [prop('resolveFn'), function (p) { return new Resolvable(getToken(p), p.resolveFn, p.deps, p.policy); }], | ||
]); | ||
// prettier-ignore | ||
var tuple2Resolvable = pattern([ | ||
[pipe(prop('val'), isString), function (tuple) { return new Resolvable(tuple.token, identity, [tuple.val], tuple.policy); }], | ||
[ | ||
pipe(prop('val'), isArray), | ||
function (tuple) { return new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy); }, | ||
], | ||
[ | ||
pipe(prop('val'), isFunction), | ||
function (tuple) { return new Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy); }, | ||
], | ||
[pipe(prop('val'), isArray), function (tuple) { return new Resolvable(tuple.token, tail(tuple.val), tuple.val.slice(0, -1), tuple.policy); }], | ||
[pipe(prop('val'), isFunction), function (tuple) { return new Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy); }], | ||
]); | ||
// prettier-ignore | ||
var item2Resolvable = pattern([ | ||
@@ -176,8 +165,3 @@ [is(Resolvable), function (r) { return r; }], | ||
[isTupleFromObj, tuple2Resolvable], | ||
[ | ||
val(true), | ||
function (obj) { | ||
throw new Error('Invalid resolve value: ' + stringify(obj)); | ||
}, | ||
], | ||
[val(true), function (obj) { throw new Error('Invalid resolve value: ' + stringify(obj)); },], | ||
]); | ||
@@ -184,0 +168,0 @@ // If resolveBlock is already an array, use it as-is. |
@@ -32,3 +32,3 @@ /** | ||
/** @internalapi */ | ||
private _registerRoot(); | ||
private _registerRoot; | ||
/** @internalapi */ | ||
@@ -91,3 +91,3 @@ dispose(): void; | ||
/** @hidden */ | ||
private _deregisterTree(state); | ||
private _deregisterTree; | ||
/** | ||
@@ -94,0 +94,0 @@ * Removes a state from the registry |
@@ -60,3 +60,3 @@ import { HookResult, TransitionOptions } from '../transition/interface'; | ||
*/ | ||
private _handleInvalidTargetState(fromPath, toState); | ||
private _handleInvalidTargetState; | ||
/** | ||
@@ -181,3 +181,3 @@ * Registers an Invalid State handler | ||
target(identifier: StateOrName, params?: RawParams, options?: TransitionOptions): TargetState; | ||
private getCurrentPath(); | ||
private getCurrentPath; | ||
/** | ||
@@ -184,0 +184,0 @@ * Low-level method for transitioning to a new state. |
@@ -0,1 +1,5 @@ | ||
/** | ||
* @coreapi | ||
* @module transition | ||
*/ /** for typedoc */ | ||
import { TreeChanges, TransitionHookPhase } from './interface'; | ||
@@ -2,0 +6,0 @@ import { Transition } from './transition'; |
@@ -51,3 +51,3 @@ import { IHookRegistry } from './interface'; | ||
*/ | ||
private _matchingNodes(nodes, criterion); | ||
private _matchingNodes; | ||
/** | ||
@@ -67,3 +67,3 @@ * Gets the default match criteria (all `true`) | ||
*/ | ||
private _getDefaultMatchCriteria(); | ||
private _getDefaultMatchCriteria; | ||
/** | ||
@@ -84,3 +84,3 @@ * Gets matching nodes as [[IMatchingNodes]] | ||
*/ | ||
private _getMatchingNodes(treeChanges); | ||
private _getMatchingNodes; | ||
/** | ||
@@ -87,0 +87,0 @@ * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]] |
@@ -798,8 +798,8 @@ /** | ||
SUCCESS = 3, | ||
ERROR = 4, | ||
ERROR = 4 | ||
} | ||
declare enum TransitionHookScope { | ||
TRANSITION = 0, | ||
STATE = 1, | ||
STATE = 1 | ||
} | ||
export { TransitionHookPhase, TransitionHookScope }; |
@@ -37,3 +37,3 @@ declare enum RejectType { | ||
*/ | ||
ERROR = 6, | ||
ERROR = 6 | ||
} | ||
@@ -40,0 +40,0 @@ export { RejectType }; |
@@ -88,3 +88,3 @@ import { StateDeclaration, StateOrName } from '../state/interface'; | ||
*/ | ||
private createTransitionHookRegFns(); | ||
private createTransitionHookRegFns; | ||
/** @internalapi */ | ||
@@ -105,3 +105,3 @@ getHooks(hookName: string): RegisteredHook[]; | ||
constructor(fromPath: PathNode[], targetState: TargetState, router: UIRouter); | ||
private applyViewConfigs(router); | ||
private applyViewConfigs; | ||
/** | ||
@@ -181,2 +181,65 @@ * @internalapi | ||
/** | ||
* Gets the new values of any parameters that changed during this transition. | ||
* | ||
* Returns any parameter values that have changed during a transition, as key/value pairs. | ||
* | ||
* - Any parameter values that have changed will be present on the returned object reflecting the new value. | ||
* - Any parameters that *not* have changed will not be present on the returned object. | ||
* - Any new parameters that weren't present in the "from" state, but are now present in the "to" state will be present on the returned object. | ||
* - Any previous parameters that are no longer present (because the "to" state doesn't have them) will be included with a value of `undefined`. | ||
* | ||
* The returned object is immutable. | ||
* | ||
* #### Examples: | ||
* | ||
* Given: | ||
* ```js | ||
* var stateA = { name: 'stateA', url: '/stateA/:param1/param2' } | ||
* var stateB = { name: 'stateB', url: '/stateB/:param3' } | ||
* var stateC = { name: 'stateB.nest', url: '/nest/:param4' } | ||
* ``` | ||
* | ||
* #### Example 1 | ||
* | ||
* From `/stateA/abc/def` to `/stateA/abc/xyz` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param2: 'xyz' } | ||
* ``` | ||
* | ||
* The value of `param2` changed to `xyz`. | ||
* The value of `param1` stayed the same so its value is not present. | ||
* | ||
* #### Example 2 | ||
* | ||
* From `/stateA/abc/def` to `/stateB/123` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param1: undefined, param2: undefined, param3: '123' } | ||
* ``` | ||
* | ||
* The value `param3` is present because it is a new param. | ||
* Both `param1` and `param2` are no longer present so their value is undefined. | ||
* | ||
* #### Example 3 | ||
* | ||
* From `/stateB/123` to `/stateB/123/nest/456` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param4: '456' } | ||
* ``` | ||
* | ||
* The value `param4` is present because it is a new param. | ||
* The value of `param3` did not change, so its value is not present. | ||
* | ||
* @returns an immutable object with changed parameter keys/values. | ||
*/ | ||
paramsChanged(): { | ||
[paramName: string]: any; | ||
}; | ||
paramsChanged<T>(): T; | ||
/** | ||
* Creates a [[UIInjector]] Dependency Injector | ||
@@ -409,3 +472,3 @@ * | ||
/** @hidden If a transition doesn't exit/enter any states, returns any [[Param]] whose value changed */ | ||
private _changedParams(); | ||
private _changedParams; | ||
/** | ||
@@ -412,0 +475,0 @@ * Returns true if the transition is dynamic. |
@@ -21,2 +21,3 @@ /** | ||
import { Rejection } from './rejectFactory'; | ||
import { flattenR, uniqR } from '../common'; | ||
/** @hidden */ | ||
@@ -190,2 +191,18 @@ var stateSelf = prop('self'); | ||
}; | ||
Transition.prototype.paramsChanged = function () { | ||
var fromParams = this.params('from'); | ||
var toParams = this.params('to'); | ||
// All the parameters declared on both the "to" and "from" paths | ||
var allParamDescriptors = [] | ||
.concat(this._treeChanges.to) | ||
.concat(this._treeChanges.from) | ||
.map(function (pathNode) { return pathNode.paramSchema; }) | ||
.reduce(flattenR, []) | ||
.reduce(uniqR, []); | ||
var changedParamDescriptors = Param.changed(allParamDescriptors, fromParams, toParams); | ||
return changedParamDescriptors.reduce(function (changedValues, descriptor) { | ||
changedValues[descriptor.id] = toParams[descriptor.id]; | ||
return changedValues; | ||
}, {}); | ||
}; | ||
/** | ||
@@ -192,0 +209,0 @@ * Creates a [[UIInjector]] Dependency Injector |
@@ -92,4 +92,4 @@ /** | ||
*/ | ||
private getNotCurrentRejection(); | ||
private getNotCurrentRejection; | ||
toString(): string; | ||
} |
@@ -164,9 +164,9 @@ /** | ||
/** @hidden */ | ||
private _defineCoreEvents(); | ||
private _defineCoreEvents; | ||
/** @hidden */ | ||
private _defineCorePaths(); | ||
private _defineCorePaths; | ||
/** @hidden */ | ||
_defineEvent(name: string, hookPhase: TransitionHookPhase, hookOrder: number, criteriaMatchPath: PathType, reverseSort?: boolean, getResultHandler?: GetResultHandler, getErrorHandler?: GetErrorHandler, synchronous?: boolean): void; | ||
/** @hidden */ | ||
private _getEvents(phase?); | ||
private _getEvents; | ||
/** | ||
@@ -185,9 +185,9 @@ * Adds a Path to be used as a criterion against a TreeChanges path | ||
*/ | ||
private _definePathType(name, hookScope); | ||
private _definePathType; | ||
/** * @hidden */ | ||
private _getPathTypes(); | ||
private _getPathTypes; | ||
/** @hidden */ | ||
getHooks(hookName: string): RegisteredHook[]; | ||
/** @hidden */ | ||
private _registerCoreTransitionHooks(); | ||
private _registerCoreTransitionHooks; | ||
} |
@@ -14,3 +14,2 @@ /** | ||
import { ParamType } from '../params/paramType'; | ||
import { Param } from '../params/param'; | ||
import { UIRouter } from '../router'; | ||
@@ -21,11 +20,8 @@ import { TargetState } from '../state/targetState'; | ||
import { StateObject } from '../state/stateObject'; | ||
import { ParamTypeDefinition } from '../params/interface'; | ||
/** @internalapi */ | ||
export interface ParamFactory { | ||
/** Creates a new [[Param]] from a CONFIG block */ | ||
fromConfig(id: string, type: ParamType, config: any): Param; | ||
/** Creates a new [[Param]] from a url PATH */ | ||
fromPath(id: string, type: ParamType, config: any): Param; | ||
/** Creates a new [[Param]] from a url SEARCH */ | ||
fromSearch(id: string, type: ParamType, config: any): Param; | ||
import { ParamTypeDefinition } from '../params'; | ||
import { StateDeclaration } from '../state'; | ||
export interface UrlMatcherCompileConfig { | ||
state?: StateDeclaration; | ||
strict?: boolean; | ||
caseInsensitive?: boolean; | ||
} | ||
@@ -32,0 +28,0 @@ /** |
import { Param } from '../params/param'; | ||
import { ParamTypes } from '../params/paramTypes'; | ||
import { RawParams } from '../params/interface'; | ||
import { ParamFactory } from './interface'; | ||
import { UrlMatcherCompileConfig } from './interface'; | ||
import { ParamFactory } from './urlMatcherFactory'; | ||
/** | ||
@@ -57,3 +58,2 @@ * Matches URLs against patterns. | ||
export declare class UrlMatcher { | ||
config: any; | ||
/** @hidden */ | ||
@@ -71,2 +71,4 @@ static nameValidator: RegExp; | ||
private _compiled; | ||
/** @hidden */ | ||
private readonly config; | ||
/** The pattern that was passed into the constructor */ | ||
@@ -93,7 +95,6 @@ pattern: string; | ||
* @param paramTypes The [[ParamTypes]] registry | ||
* @param config A configuration object | ||
* - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`. | ||
* - `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`. | ||
* @param paramFactory A [[ParamFactory]] object | ||
* @param config A [[UrlMatcherCompileConfig]] configuration object | ||
*/ | ||
constructor(pattern: string, paramTypes: ParamTypes, paramFactory: ParamFactory, config?: any); | ||
constructor(pattern: string, paramTypes: ParamTypes, paramFactory: ParamFactory, config?: UrlMatcherCompileConfig); | ||
/** | ||
@@ -100,0 +101,0 @@ * Creates a new concatenated UrlMatcher |
@@ -6,3 +6,3 @@ /** | ||
/** for typedoc */ | ||
import { map, defaults, inherit, identity, unnest, tail, find, allTrueR, unnestR, arrayTuples, } from '../common/common'; | ||
import { map, inherit, identity, unnest, tail, find, allTrueR, unnestR, arrayTuples } from '../common/common'; | ||
import { prop, propEq } from '../common/hof'; | ||
@@ -12,2 +12,3 @@ import { isArray, isString, isDefined } from '../common/predicates'; | ||
import { joinNeighborsR, splitOnDelim } from '../common/strings'; | ||
import { defaults } from '../common'; | ||
/** @hidden */ | ||
@@ -36,2 +37,7 @@ function quoteRegExp(str, param) { | ||
var splitOnSlash = splitOnDelim('/'); | ||
var defaultConfig = { | ||
state: { params: {} }, | ||
strict: true, | ||
caseInsensitive: true, | ||
}; | ||
/** | ||
@@ -92,9 +98,7 @@ * Matches URLs against patterns. | ||
* @param paramTypes The [[ParamTypes]] registry | ||
* @param config A configuration object | ||
* - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`. | ||
* - `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`. | ||
* @param paramFactory A [[ParamFactory]] object | ||
* @param config A [[UrlMatcherCompileConfig]] configuration object | ||
*/ | ||
function UrlMatcher(pattern, paramTypes, paramFactory, config) { | ||
var _this = this; | ||
this.config = config; | ||
/** @hidden */ | ||
@@ -110,9 +114,4 @@ this._cache = { path: [this] }; | ||
this._compiled = []; | ||
this.config = config = defaults(config, defaultConfig); | ||
this.pattern = pattern; | ||
this.config = defaults(this.config, { | ||
params: {}, | ||
strict: true, | ||
caseInsensitive: false, | ||
paramMap: identity, | ||
}); | ||
// Find all placeholders and create a compiled pattern, using either classic or curly syntax: | ||
@@ -134,3 +133,4 @@ // '*' name | ||
var patterns = []; | ||
var last = 0, matchArray; | ||
var last = 0; | ||
var matchArray; | ||
var checkParamErrors = function (id) { | ||
@@ -156,3 +156,2 @@ if (!UrlMatcher.nameValidator.test(id)) | ||
regexp: regexp, | ||
cfg: _this.config.params[id], | ||
segment: pattern.substring(last, m.index), | ||
@@ -162,12 +161,13 @@ type: !regexp ? null : paramTypes.type(regexp) || makeRegexpType(regexp), | ||
}; | ||
var p, segment; | ||
var details; | ||
var segment; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((matchArray = placeholder.exec(pattern))) { | ||
p = matchDetails(matchArray, false); | ||
if (p.segment.indexOf('?') >= 0) | ||
details = matchDetails(matchArray, false); | ||
if (details.segment.indexOf('?') >= 0) | ||
break; // we're into the search part | ||
checkParamErrors(p.id); | ||
this._params.push(paramFactory.fromPath(p.id, p.type, this.config.paramMap(p.cfg, false))); | ||
this._segments.push(p.segment); | ||
patterns.push([p.segment, tail(this._params)]); | ||
checkParamErrors(details.id); | ||
this._params.push(paramFactory.fromPath(details.id, details.type, config.state)); | ||
this._segments.push(details.segment); | ||
patterns.push([details.segment, tail(this._params)]); | ||
last = placeholder.lastIndex; | ||
@@ -185,5 +185,5 @@ } | ||
while ((matchArray = searchPlaceholder.exec(search))) { | ||
p = matchDetails(matchArray, true); | ||
checkParamErrors(p.id); | ||
this._params.push(paramFactory.fromSearch(p.id, p.type, this.config.paramMap(p.cfg, true))); | ||
details = matchDetails(matchArray, true); | ||
checkParamErrors(details.id); | ||
this._params.push(paramFactory.fromSearch(details.id, details.type, config.state)); | ||
last = placeholder.lastIndex; | ||
@@ -190,0 +190,0 @@ // check if ?& |
import { UrlMatcher } from './urlMatcher'; | ||
import { Param } from '../params/param'; | ||
import { ParamTypes } from '../params/paramTypes'; | ||
import { ParamTypeDefinition } from '../params/interface'; | ||
import { Disposable } from '../interface'; | ||
import { ParamFactory, UrlMatcherConfig } from './interface'; | ||
import { ParamType } from '../params/paramType'; | ||
import { UrlMatcherCompileConfig, UrlMatcherConfig } from './interface'; | ||
import { StateDeclaration } from '../state'; | ||
/** @internalapi */ | ||
export declare class ParamFactory { | ||
private umf; | ||
fromConfig(id: string, type: ParamType, state: StateDeclaration): Param; | ||
fromPath(id: string, type: ParamType, state: StateDeclaration): Param; | ||
fromSearch(id: string, type: ParamType, state: StateDeclaration): Param; | ||
constructor(umf: UrlMatcherFactory); | ||
} | ||
/** | ||
@@ -26,4 +37,2 @@ * Factory for [[UrlMatcher]] instances. | ||
defaultSquashPolicy(value?: boolean | string): string | boolean; | ||
/** @hidden */ | ||
private _getConfig; | ||
/** | ||
@@ -36,5 +45,3 @@ * Creates a [[UrlMatcher]] for the specified pattern. | ||
*/ | ||
compile(pattern: string, config?: { | ||
[key: string]: any; | ||
}): UrlMatcher; | ||
compile(pattern: string, config?: UrlMatcherCompileConfig): UrlMatcher; | ||
/** | ||
@@ -41,0 +48,0 @@ * Returns true if the specified object is a [[UrlMatcher]], or false otherwise. |
@@ -0,1 +1,9 @@ | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
/** | ||
@@ -10,2 +18,19 @@ * @internalapi | ||
import { ParamTypes } from '../params/paramTypes'; | ||
/** @internalapi */ | ||
var ParamFactory = /** @class */ (function () { | ||
function ParamFactory(umf) { | ||
this.umf = umf; | ||
} | ||
ParamFactory.prototype.fromConfig = function (id, type, state) { | ||
return new Param(id, type, DefType.CONFIG, this.umf, state); | ||
}; | ||
ParamFactory.prototype.fromPath = function (id, type, state) { | ||
return new Param(id, type, DefType.PATH, this.umf, state); | ||
}; | ||
ParamFactory.prototype.fromSearch = function (id, type, state) { | ||
return new Param(id, type, DefType.SEARCH, this.umf, state); | ||
}; | ||
return ParamFactory; | ||
}()); | ||
export { ParamFactory }; | ||
/** | ||
@@ -19,3 +44,2 @@ * Factory for [[UrlMatcher]] instances. | ||
function UrlMatcherFactory() { | ||
var _this = this; | ||
/** @hidden */ this.paramTypes = new ParamTypes(); | ||
@@ -26,14 +50,3 @@ /** @hidden */ this._isCaseInsensitive = false; | ||
/** @internalapi Creates a new [[Param]] for a given location (DefType) */ | ||
this.paramFactory = { | ||
/** Creates a new [[Param]] from a CONFIG block */ | ||
fromConfig: function (id, type, config) { return new Param(id, type, config, DefType.CONFIG, _this); }, | ||
/** Creates a new [[Param]] from a url PATH */ | ||
fromPath: function (id, type, config) { return new Param(id, type, config, DefType.PATH, _this); }, | ||
/** Creates a new [[Param]] from a url SEARCH */ | ||
fromSearch: function (id, type, config) { return new Param(id, type, config, DefType.SEARCH, _this); }, | ||
}; | ||
/** @hidden */ | ||
this._getConfig = function (config) { | ||
return extend({ strict: _this._isStrictMode, caseInsensitive: _this._isCaseInsensitive }, config); | ||
}; | ||
this.paramFactory = new ParamFactory(this); | ||
extend(this, { UrlMatcher: UrlMatcher, Param: Param }); | ||
@@ -63,3 +76,7 @@ } | ||
UrlMatcherFactory.prototype.compile = function (pattern, config) { | ||
return new UrlMatcher(pattern, this.paramTypes, this.paramFactory, this._getConfig(config)); | ||
// backward-compatible support for config.params -> config.state.params | ||
var params = config && !config.state && config.params; | ||
config = params ? __assign({ state: { params: params } }, config) : config; | ||
var globalConfig = { strict: this._isStrictMode, caseInsensitive: this._isCaseInsensitive }; | ||
return new UrlMatcher(pattern, this.paramTypes, this.paramFactory, extend(globalConfig, config)); | ||
}; | ||
@@ -66,0 +83,0 @@ /** |
@@ -38,4 +38,4 @@ import { UrlMatcher } from './urlMatcher'; | ||
sort(compareFn?: (a: UrlRule, b: UrlRule) => number): void; | ||
private ensureSorted(); | ||
private stableSort(arr, compareFn); | ||
private ensureSorted; | ||
private stableSort; | ||
/** | ||
@@ -42,0 +42,0 @@ * Given a URL, check all rules and return the best [[MatchResult]] |
@@ -6,5 +6,6 @@ /** | ||
import { UrlMatcher } from './urlMatcher'; | ||
import { isString, isDefined, isFunction, isState } from '../common/predicates'; | ||
import { isString, isDefined, isFunction } from '../common/predicates'; | ||
import { identity, extend } from '../common/common'; | ||
import { is, pattern } from '../common/hof'; | ||
import { StateObject } from '../state/stateObject'; | ||
/** | ||
@@ -30,2 +31,3 @@ * Creates a [[UrlRule]] | ||
var _this = this; | ||
var isState = StateObject.isState; | ||
var makeRule = pattern([ | ||
@@ -32,0 +34,0 @@ [isString, function (_what) { return makeRule(_this.compile(_what)); }], |
@@ -14,4 +14,4 @@ import { LocationConfig } from '../common/coreservices'; | ||
baseHref(href?: string): string; | ||
applyDocumentBaseHref(): string; | ||
private getBaseHref; | ||
dispose(): void; | ||
} |
@@ -6,3 +6,3 @@ /** | ||
/** */ | ||
import { isDefined } from '../common/predicates'; | ||
import { isDefined, isUndefined } from '../common/predicates'; | ||
/** A `LocationConfig` that delegates to the browser's `location` object */ | ||
@@ -35,9 +35,13 @@ var BrowserLocationConfig = /** @class */ (function () { | ||
BrowserLocationConfig.prototype.baseHref = function (href) { | ||
return isDefined(href) | ||
? (this._baseHref = href) | ||
: isDefined(this._baseHref) ? this._baseHref : this.applyDocumentBaseHref(); | ||
if (isDefined(href)) | ||
this._baseHref = href; | ||
if (isUndefined(this._baseHref)) | ||
this._baseHref = this.getBaseHref(); | ||
return this._baseHref; | ||
}; | ||
BrowserLocationConfig.prototype.applyDocumentBaseHref = function () { | ||
BrowserLocationConfig.prototype.getBaseHref = function () { | ||
var baseTag = document.getElementsByTagName('base')[0]; | ||
return (this._baseHref = baseTag ? baseTag.href.substr(location.origin.length) : location.pathname || '/'); | ||
if (!baseTag || !baseTag.href) | ||
return location.pathname || '/'; | ||
return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, ''); | ||
}; | ||
@@ -44,0 +48,0 @@ BrowserLocationConfig.prototype.dispose = function () { }; |
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
private _getBasePrefix(); | ||
private _getBasePrefix; | ||
protected _get(): string; | ||
@@ -36,0 +36,0 @@ protected _set(state: any, title: string, url: string, replace: boolean): void; |
@@ -9,2 +9,3 @@ /** | ||
import { _ViewDeclaration } from '../state/interface'; | ||
import { UIRouter } from '../router'; | ||
export declare type ViewConfigFactory = (path: PathNode[], decl: _ViewDeclaration) => ViewConfig | ViewConfig[]; | ||
@@ -14,2 +15,4 @@ export interface ViewServicePluginAPI { | ||
_viewConfigFactory(viewType: string, factory: ViewConfigFactory): any; | ||
/** @param id router.$id + "." + uiView.id */ | ||
_registeredUIView(id: string): ActiveUIView; | ||
_registeredUIViews(): ActiveUIView[]; | ||
@@ -43,2 +46,3 @@ _activeViewConfigs(): ViewConfig[]; | ||
export declare class ViewService { | ||
private router; | ||
private _uiViews; | ||
@@ -123,5 +127,5 @@ private _viewConfigs; | ||
}; | ||
constructor(); | ||
private _rootViewContext(context?); | ||
private _viewConfigFactory(viewType, factory); | ||
constructor(router: UIRouter); | ||
private _rootViewContext; | ||
private _viewConfigFactory; | ||
createViewConfig(path: PathNode[], decl: _ViewDeclaration): ViewConfig[]; | ||
@@ -128,0 +132,0 @@ /** |
@@ -5,3 +5,3 @@ /** | ||
*/ /** for typedoc */ | ||
import { equals, applyPairs, removeFrom, inArray } from '../common/common'; | ||
import { equals, applyPairs, removeFrom, inArray, find } from '../common/common'; | ||
import { curry, prop } from '../common/hof'; | ||
@@ -27,4 +27,5 @@ import { isString, isArray } from '../common/predicates'; | ||
var ViewService = /** @class */ (function () { | ||
function ViewService() { | ||
function ViewService(router) { | ||
var _this = this; | ||
this.router = router; | ||
this._uiViews = []; | ||
@@ -37,2 +38,3 @@ this._viewConfigs = []; | ||
_viewConfigFactory: this._viewConfigFactory.bind(this), | ||
_registeredUIView: function (id) { return find(_this._uiViews, function (view) { return _this.router.$id + "." + view.id === id; }); }, | ||
_registeredUIViews: function () { return _this._uiViews; }, | ||
@@ -39,0 +41,0 @@ _activeViewConfigs: function () { return _this._viewConfigs; }, |
@@ -148,5 +148,4 @@ "use strict"; | ||
} | ||
var _defaultsList = defaultsList.concat({}).reverse(); | ||
var defaultVals = exports.extend.apply(null, _defaultsList); | ||
return exports.extend({}, defaultVals, pick(opts || {}, Object.keys(defaultVals))); | ||
var defaultVals = exports.extend.apply(void 0, [{}].concat(defaultsList.reverse())); | ||
return exports.extend(defaultVals, pick(opts || {}, Object.keys(defaultVals))); | ||
} | ||
@@ -153,0 +152,0 @@ exports.defaults = defaults; |
import { Predicate } from './common'; | ||
import { StateObject } from '../state/stateObject'; | ||
export declare const isUndefined: (x: any) => boolean; | ||
@@ -14,3 +13,2 @@ export declare const isDefined: Predicate<any>; | ||
export declare const isRegExp: (x: any) => x is RegExp; | ||
export declare const isState: (x: any) => x is StateObject; | ||
/** | ||
@@ -17,0 +15,0 @@ * Predicate which checks if a value is injectable |
@@ -12,3 +12,2 @@ "use strict"; | ||
var hof_1 = require("./hof"); | ||
var stateObject_1 = require("../state/stateObject"); | ||
var toStr = Object.prototype.toString; | ||
@@ -27,3 +26,2 @@ var tis = function (t) { return function (x) { return typeof x === t; }; }; | ||
exports.isRegExp = (function (x) { return toStr.call(x) === '[object RegExp]'; }); | ||
exports.isState = stateObject_1.StateObject.isState; | ||
/** | ||
@@ -30,0 +28,0 @@ * Predicate which checks if a value is injectable |
@@ -0,1 +1,8 @@ | ||
/** | ||
* Functions that manipulate strings | ||
* | ||
* Although these functions are exported, they are subject to change without notice. | ||
* | ||
* @module common_strings | ||
*/ /** */ | ||
import { IInjectable } from './common'; | ||
@@ -2,0 +9,0 @@ /** |
@@ -14,4 +14,2 @@ "use strict"; | ||
var hof_1 = require("./hof"); | ||
var transition_1 = require("../transition/transition"); | ||
var resolvable_1 = require("../resolve/resolvable"); | ||
/** | ||
@@ -53,11 +51,2 @@ * Returns a string shortened to a maximum length | ||
exports.kebobString = kebobString; | ||
function _toJson(obj) { | ||
return JSON.stringify(obj); | ||
} | ||
function _fromJson(json) { | ||
return predicates_1.isString(json) ? JSON.parse(json) : json; | ||
} | ||
function promiseToString(p) { | ||
return "Promise(" + JSON.stringify(p) + ")"; | ||
} | ||
function functionToString(fn) { | ||
@@ -79,20 +68,15 @@ var fnStr = fnToString(fn); | ||
exports.fnToString = fnToString; | ||
var stringifyPatternFn = null; | ||
var stringifyPattern = function (value) { | ||
var isRejection = rejectFactory_1.Rejection.isRejectionPromise; | ||
stringifyPatternFn = | ||
stringifyPatternFn || | ||
hof_1.pattern([ | ||
[hof_1.not(predicates_1.isDefined), hof_1.val('undefined')], | ||
[predicates_1.isNull, hof_1.val('null')], | ||
[predicates_1.isPromise, hof_1.val('[Promise]')], | ||
[isRejection, function (x) { return x._transitionRejection.toString(); }], | ||
[hof_1.is(rejectFactory_1.Rejection), hof_1.invoke('toString')], | ||
[hof_1.is(transition_1.Transition), hof_1.invoke('toString')], | ||
[hof_1.is(resolvable_1.Resolvable), hof_1.invoke('toString')], | ||
[predicates_1.isInjectable, functionToString], | ||
[hof_1.val(true), common_1.identity], | ||
]); | ||
return stringifyPatternFn(value); | ||
var isRejection = rejectFactory_1.Rejection.isRejectionPromise; | ||
var hasToString = function (obj) { | ||
return predicates_1.isObject(obj) && !predicates_1.isArray(obj) && obj.constructor !== Object && predicates_1.isFunction(obj.toString); | ||
}; | ||
var stringifyPattern = hof_1.pattern([ | ||
[predicates_1.isUndefined, hof_1.val('undefined')], | ||
[predicates_1.isNull, hof_1.val('null')], | ||
[predicates_1.isPromise, hof_1.val('[Promise]')], | ||
[isRejection, function (x) { return x._transitionRejection.toString(); }], | ||
[hasToString, function (x) { return x.toString(); }], | ||
[predicates_1.isInjectable, functionToString], | ||
[hof_1.val(true), common_1.identity], | ||
]); | ||
function stringify(o) { | ||
@@ -108,2 +92,8 @@ var seen = []; | ||
} | ||
if (predicates_1.isUndefined(o)) { | ||
// Workaround for IE & Edge Spec incompatibility where replacer function would not be called when JSON.stringify | ||
// is given `undefined` as value. To work around that, we simply detect `undefined` and bail out early by | ||
// manually stringifying it. | ||
return format(o); | ||
} | ||
return JSON.stringify(o, function (key, value) { return format(value); }).replace(/\\"/g, '"'); | ||
@@ -110,0 +100,0 @@ } |
@@ -28,3 +28,3 @@ import { Transition } from '../transition/transition'; | ||
UIVIEW = 3, | ||
VIEWCONFIG = 4, | ||
VIEWCONFIG = 4 | ||
} | ||
@@ -43,3 +43,3 @@ export { Category }; | ||
/** @hidden */ | ||
private _set(enabled, categories); | ||
private _set; | ||
/** | ||
@@ -46,0 +46,0 @@ * Enables a trace [[Category]] |
@@ -215,6 +215,6 @@ "use strict"; | ||
var uiView = _a.uiView, viewConfig = _a.viewConfig; | ||
var _b; | ||
var uiv = uiView && uiView.fqn; | ||
var cfg = viewConfig && viewConfig.viewDecl.$context.name + ": (" + viewConfig.viewDecl.$name + ")"; | ||
return _b = {}, _b[uivheader] = uiv, _b[cfgheader] = cfg, _b; | ||
var _b; | ||
}) | ||
@@ -221,0 +221,0 @@ .sort(function (a, b) { return (a[uivheader] || '').localeCompare(b[uivheader] || ''); }); |
@@ -0,2 +1,3 @@ | ||
/** @module hooks */ /** */ | ||
import { TransitionService } from '../transition/transitionService'; | ||
export declare const registerIgnoredTransitionHook: (transitionService: TransitionService) => Function; |
@@ -0,1 +1,11 @@ | ||
/** | ||
* # Core classes and interfaces | ||
* | ||
* The classes and interfaces that are core to ui-router and do not belong | ||
* to a more specific subsystem (such as resolve). | ||
* | ||
* @coreapi | ||
* @preferred | ||
* @module core | ||
*/ /** for typedoc */ | ||
import { UIRouter } from './router'; | ||
@@ -2,0 +12,0 @@ /** |
@@ -132,3 +132,3 @@ /** | ||
*/ | ||
type: string | ParamType; | ||
type?: string | ParamType; | ||
/** | ||
@@ -167,3 +167,3 @@ * The parameter's `array` mode | ||
*/ | ||
array: boolean; | ||
array?: boolean; | ||
/** | ||
@@ -222,3 +222,3 @@ * Squash mode: omit default parameter values in URL | ||
*/ | ||
squash: boolean | string; | ||
squash?: boolean | string; | ||
/** | ||
@@ -241,3 +241,3 @@ * @internalapi | ||
*/ | ||
replace: Replace[]; | ||
replace?: Replace[]; | ||
/** | ||
@@ -249,3 +249,3 @@ * @hidden | ||
*/ | ||
isOptional: boolean; | ||
isOptional?: boolean; | ||
/** | ||
@@ -271,3 +271,3 @@ * Dynamic flag | ||
*/ | ||
dynamic: boolean; | ||
dynamic?: boolean; | ||
/** | ||
@@ -309,3 +309,3 @@ * Disables url-encoding of parameter values | ||
*/ | ||
raw: boolean; | ||
raw?: boolean; | ||
/** | ||
@@ -347,3 +347,3 @@ * Enables/disables inheriting of this parameter's value | ||
*/ | ||
inherit: boolean; | ||
inherit?: boolean; | ||
} | ||
@@ -350,0 +350,0 @@ /** @internalapi */ |
@@ -1,4 +0,5 @@ | ||
import { RawParams, ParamDeclaration } from '../params/interface'; | ||
import { RawParams } from '../params/interface'; | ||
import { ParamType } from './paramType'; | ||
import { UrlMatcherFactory } from '../url/urlMatcherFactory'; | ||
import { StateDeclaration } from '../state'; | ||
/** @internalapi */ | ||
@@ -8,3 +9,3 @@ declare enum DefType { | ||
SEARCH = 1, | ||
CONFIG = 2, | ||
CONFIG = 2 | ||
} | ||
@@ -57,3 +58,3 @@ export { DefType }; | ||
static validates(params: Param[], values?: RawParams): boolean; | ||
constructor(id: string, type: ParamType, config: ParamDeclaration, location: DefType, urlMatcherFactory: UrlMatcherFactory); | ||
constructor(id: string, type: ParamType, location: DefType, urlMatcherFactory: UrlMatcherFactory, state: StateDeclaration); | ||
isDefaultValue(value: any): boolean; | ||
@@ -60,0 +61,0 @@ /** |
@@ -26,5 +26,12 @@ "use strict"; | ||
exports.DefType = DefType; | ||
function getParamDeclaration(paramName, location, state) { | ||
var noReloadOnSearch = (state.reloadOnSearch === false && location === DefType.SEARCH) || undefined; | ||
var dynamic = [state.dynamic, noReloadOnSearch].find(predicates_1.isDefined); | ||
var defaultConfig = predicates_1.isDefined(dynamic) ? { dynamic: dynamic } : {}; | ||
var paramConfig = unwrapShorthand(state && state.params && state.params[paramName]); | ||
return common_1.extend(defaultConfig, paramConfig); | ||
} | ||
/** @hidden */ | ||
function unwrapShorthand(cfg) { | ||
cfg = (isShorthand(cfg) && { value: cfg }) || cfg; | ||
cfg = isShorthand(cfg) ? { value: cfg } : cfg; | ||
getStaticDefaultValue['__cacheable'] = true; | ||
@@ -34,5 +41,4 @@ function getStaticDefaultValue() { | ||
} | ||
return common_1.extend(cfg, { | ||
$$fn: predicates_1.isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue, | ||
}); | ||
var $$fn = predicates_1.isInjectable(cfg.value) ? cfg.value : getStaticDefaultValue; | ||
return common_1.extend(cfg, { $$fn: $$fn }); | ||
} | ||
@@ -87,4 +93,4 @@ /** @hidden */ | ||
var Param = /** @class */ (function () { | ||
function Param(id, type, config, location, urlMatcherFactory) { | ||
config = unwrapShorthand(config); | ||
function Param(id, type, location, urlMatcherFactory, state) { | ||
var config = getParamDeclaration(id, location, state); | ||
type = getType(config, type, location, id, urlMatcherFactory.paramTypes); | ||
@@ -91,0 +97,0 @@ var arrayMode = getArrayMode(); |
@@ -150,2 +150,3 @@ "use strict"; | ||
inherit: type.inherit, | ||
raw: type.raw, | ||
is: arrayHandler(type.is.bind(type), true), | ||
@@ -152,0 +153,0 @@ $arrayMode: mode, |
@@ -54,3 +54,3 @@ "use strict"; | ||
/** Provides services related to ui-view synchronization */ | ||
this.viewService = new view_1.ViewService(); | ||
this.viewService = new view_1.ViewService(this); | ||
/** Global router state */ | ||
@@ -57,0 +57,0 @@ this.globals = new globals_1.UIRouterGlobals(); |
@@ -106,25 +106,2 @@ /** | ||
* ``` | ||
* | ||
* A state declaration may also be an ES6 class which implements the StateDeclaration interface | ||
* and has a `@State()` decorator | ||
* | ||
* #### Example: | ||
* ```js | ||
* import { State } from "@uirouter/core" | ||
* import { FolderService } from "../folder.service" | ||
* // StateDeclaration class | ||
* @State() | ||
* export class FoldersState implements StateDeclaration { | ||
* name: 'folders', | ||
* url: '/folders', | ||
* component: FoldersComponent | ||
* | ||
* @Resolve({ deps: [ FolderService ] }) | ||
* allfolders(FolderService) { | ||
* return FolderService.list(); | ||
* }, | ||
* } | ||
* | ||
* registry.register(FoldersState); | ||
* ``` | ||
*/ | ||
@@ -687,4 +664,15 @@ export interface StateDeclaration { | ||
/** | ||
* @deprecated define individual parameters as [[ParamDeclaration.dynamic]] | ||
* Marks all the state's parameters as `dynamic`. | ||
* | ||
* All parameters on the state will use this value for `dynamic` as a default. | ||
* Individual parameters may override this default using [[ParamDeclaration.dynamic]] in the [[params]] block. | ||
* | ||
* Note: this value overrides the `dynamic` value on a custom parameter type ([[ParamTypeDefinition.dynamic]]). | ||
*/ | ||
dynamic?: boolean; | ||
/** | ||
* Marks all query parameters as [[ParamDeclaration.dynamic]] | ||
* | ||
* @deprecated use either [[dynamic]] or [[ParamDeclaration.dynamic]] | ||
*/ | ||
reloadOnSearch?: boolean; | ||
@@ -691,0 +679,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** @module state */ /** for typedoc */ | ||
/** @module state */ | ||
/** for typedoc */ | ||
var common_1 = require("../common/common"); | ||
@@ -30,24 +31,16 @@ var predicates_1 = require("../common/predicates"); | ||
var getUrlBuilder = function ($urlMatcherFactoryProvider, root) { | ||
return function urlBuilder(state) { | ||
var stateDec = state; | ||
return function urlBuilder(stateObject) { | ||
var state = stateObject.self; | ||
// For future states, i.e., states whose name ends with `.**`, | ||
// match anything that starts with the url prefix | ||
if (stateDec && stateDec.url && stateDec.name && stateDec.name.match(/\.\*\*$/)) { | ||
stateDec.url += '{remainder:any}'; // match any path (.*) | ||
if (state && state.url && state.name && state.name.match(/\.\*\*$/)) { | ||
state.url += '{remainder:any}'; // match any path (.*) | ||
} | ||
var parsed = parseUrl(stateDec.url), parent = state.parent; | ||
var url = !parsed | ||
? stateDec.url | ||
: $urlMatcherFactoryProvider.compile(parsed.val, { | ||
params: state.params || {}, | ||
paramMap: function (paramConfig, isSearch) { | ||
if (stateDec.reloadOnSearch === false && isSearch) | ||
paramConfig = common_1.extend(paramConfig || {}, { dynamic: true }); | ||
return paramConfig; | ||
}, | ||
}); | ||
var parent = stateObject.parent; | ||
var parsed = parseUrl(state.url); | ||
var url = !parsed ? state.url : $urlMatcherFactoryProvider.compile(parsed.val, { state: state }); | ||
if (!url) | ||
return null; | ||
if (!$urlMatcherFactoryProvider.isMatcher(url)) | ||
throw new Error("Invalid url '" + url + "' in state '" + state + "'"); | ||
throw new Error("Invalid url '" + url + "' in state '" + stateObject + "'"); | ||
return parsed && parsed.root ? url : ((parent && parent.navigable) || root()).url.append(url); | ||
@@ -63,3 +56,3 @@ }; | ||
return function paramsBuilder(state) { | ||
var makeConfigParam = function (config, id) { return paramFactory.fromConfig(id, null, config); }; | ||
var makeConfigParam = function (config, id) { return paramFactory.fromConfig(id, null, state.self); }; | ||
var urlParams = (state.url && state.url.parameters({ inherit: false })) || []; | ||
@@ -152,3 +145,3 @@ var nonUrlParams = common_1.values(common_1.mapObj(common_1.omit(state.params || {}, urlParams.map(hof_1.prop('id'))), makeConfigParam)); | ||
var getToken = function (p) { return p.provide || p.token; }; | ||
/** Given a literal resolve or provider object, returns a Resolvable */ | ||
// prettier-ignore: Given a literal resolve or provider object, returns a Resolvable | ||
var literal2Resolvable = hof_1.pattern([ | ||
@@ -161,13 +154,9 @@ [hof_1.prop('resolveFn'), function (p) { return new resolvable_1.Resolvable(getToken(p), p.resolveFn, p.deps, p.policy); }], | ||
]); | ||
// prettier-ignore | ||
var tuple2Resolvable = hof_1.pattern([ | ||
[hof_1.pipe(hof_1.prop('val'), predicates_1.isString), function (tuple) { return new resolvable_1.Resolvable(tuple.token, common_1.identity, [tuple.val], tuple.policy); }], | ||
[ | ||
hof_1.pipe(hof_1.prop('val'), predicates_1.isArray), | ||
function (tuple) { return new resolvable_1.Resolvable(tuple.token, common_1.tail(tuple.val), tuple.val.slice(0, -1), tuple.policy); }, | ||
], | ||
[ | ||
hof_1.pipe(hof_1.prop('val'), predicates_1.isFunction), | ||
function (tuple) { return new resolvable_1.Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy); }, | ||
], | ||
[hof_1.pipe(hof_1.prop('val'), predicates_1.isArray), function (tuple) { return new resolvable_1.Resolvable(tuple.token, common_1.tail(tuple.val), tuple.val.slice(0, -1), tuple.policy); }], | ||
[hof_1.pipe(hof_1.prop('val'), predicates_1.isFunction), function (tuple) { return new resolvable_1.Resolvable(tuple.token, tuple.val, annotate(tuple.val), tuple.policy); }], | ||
]); | ||
// prettier-ignore | ||
var item2Resolvable = hof_1.pattern([ | ||
@@ -178,8 +167,3 @@ [hof_1.is(resolvable_1.Resolvable), function (r) { return r; }], | ||
[isTupleFromObj, tuple2Resolvable], | ||
[ | ||
hof_1.val(true), | ||
function (obj) { | ||
throw new Error('Invalid resolve value: ' + strings_1.stringify(obj)); | ||
}, | ||
], | ||
[hof_1.val(true), function (obj) { throw new Error('Invalid resolve value: ' + strings_1.stringify(obj)); },], | ||
]); | ||
@@ -186,0 +170,0 @@ // If resolveBlock is already an array, use it as-is. |
@@ -32,3 +32,3 @@ /** | ||
/** @internalapi */ | ||
private _registerRoot(); | ||
private _registerRoot; | ||
/** @internalapi */ | ||
@@ -91,3 +91,3 @@ dispose(): void; | ||
/** @hidden */ | ||
private _deregisterTree(state); | ||
private _deregisterTree; | ||
/** | ||
@@ -94,0 +94,0 @@ * Removes a state from the registry |
@@ -60,3 +60,3 @@ import { HookResult, TransitionOptions } from '../transition/interface'; | ||
*/ | ||
private _handleInvalidTargetState(fromPath, toState); | ||
private _handleInvalidTargetState; | ||
/** | ||
@@ -181,3 +181,3 @@ * Registers an Invalid State handler | ||
target(identifier: StateOrName, params?: RawParams, options?: TransitionOptions): TargetState; | ||
private getCurrentPath(); | ||
private getCurrentPath; | ||
/** | ||
@@ -184,0 +184,0 @@ * Low-level method for transitioning to a new state. |
@@ -0,1 +1,5 @@ | ||
/** | ||
* @coreapi | ||
* @module transition | ||
*/ /** for typedoc */ | ||
import { TreeChanges, TransitionHookPhase } from './interface'; | ||
@@ -2,0 +6,0 @@ import { Transition } from './transition'; |
@@ -51,3 +51,3 @@ import { IHookRegistry } from './interface'; | ||
*/ | ||
private _matchingNodes(nodes, criterion); | ||
private _matchingNodes; | ||
/** | ||
@@ -67,3 +67,3 @@ * Gets the default match criteria (all `true`) | ||
*/ | ||
private _getDefaultMatchCriteria(); | ||
private _getDefaultMatchCriteria; | ||
/** | ||
@@ -84,3 +84,3 @@ * Gets matching nodes as [[IMatchingNodes]] | ||
*/ | ||
private _getMatchingNodes(treeChanges); | ||
private _getMatchingNodes; | ||
/** | ||
@@ -87,0 +87,0 @@ * Determines if this hook's [[matchCriteria]] match the given [[TreeChanges]] |
@@ -798,8 +798,8 @@ /** | ||
SUCCESS = 3, | ||
ERROR = 4, | ||
ERROR = 4 | ||
} | ||
declare enum TransitionHookScope { | ||
TRANSITION = 0, | ||
STATE = 1, | ||
STATE = 1 | ||
} | ||
export { TransitionHookPhase, TransitionHookScope }; |
@@ -37,3 +37,3 @@ declare enum RejectType { | ||
*/ | ||
ERROR = 6, | ||
ERROR = 6 | ||
} | ||
@@ -40,0 +40,0 @@ export { RejectType }; |
@@ -88,3 +88,3 @@ import { StateDeclaration, StateOrName } from '../state/interface'; | ||
*/ | ||
private createTransitionHookRegFns(); | ||
private createTransitionHookRegFns; | ||
/** @internalapi */ | ||
@@ -105,3 +105,3 @@ getHooks(hookName: string): RegisteredHook[]; | ||
constructor(fromPath: PathNode[], targetState: TargetState, router: UIRouter); | ||
private applyViewConfigs(router); | ||
private applyViewConfigs; | ||
/** | ||
@@ -181,2 +181,65 @@ * @internalapi | ||
/** | ||
* Gets the new values of any parameters that changed during this transition. | ||
* | ||
* Returns any parameter values that have changed during a transition, as key/value pairs. | ||
* | ||
* - Any parameter values that have changed will be present on the returned object reflecting the new value. | ||
* - Any parameters that *not* have changed will not be present on the returned object. | ||
* - Any new parameters that weren't present in the "from" state, but are now present in the "to" state will be present on the returned object. | ||
* - Any previous parameters that are no longer present (because the "to" state doesn't have them) will be included with a value of `undefined`. | ||
* | ||
* The returned object is immutable. | ||
* | ||
* #### Examples: | ||
* | ||
* Given: | ||
* ```js | ||
* var stateA = { name: 'stateA', url: '/stateA/:param1/param2' } | ||
* var stateB = { name: 'stateB', url: '/stateB/:param3' } | ||
* var stateC = { name: 'stateB.nest', url: '/nest/:param4' } | ||
* ``` | ||
* | ||
* #### Example 1 | ||
* | ||
* From `/stateA/abc/def` to `/stateA/abc/xyz` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param2: 'xyz' } | ||
* ``` | ||
* | ||
* The value of `param2` changed to `xyz`. | ||
* The value of `param1` stayed the same so its value is not present. | ||
* | ||
* #### Example 2 | ||
* | ||
* From `/stateA/abc/def` to `/stateB/123` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param1: undefined, param2: undefined, param3: '123' } | ||
* ``` | ||
* | ||
* The value `param3` is present because it is a new param. | ||
* Both `param1` and `param2` are no longer present so their value is undefined. | ||
* | ||
* #### Example 3 | ||
* | ||
* From `/stateB/123` to `/stateB/123/nest/456` | ||
* | ||
* ```js | ||
* var changed = transition.paramsChanged() | ||
* // changed is { param4: '456' } | ||
* ``` | ||
* | ||
* The value `param4` is present because it is a new param. | ||
* The value of `param3` did not change, so its value is not present. | ||
* | ||
* @returns an immutable object with changed parameter keys/values. | ||
*/ | ||
paramsChanged(): { | ||
[paramName: string]: any; | ||
}; | ||
paramsChanged<T>(): T; | ||
/** | ||
* Creates a [[UIInjector]] Dependency Injector | ||
@@ -409,3 +472,3 @@ * | ||
/** @hidden If a transition doesn't exit/enter any states, returns any [[Param]] whose value changed */ | ||
private _changedParams(); | ||
private _changedParams; | ||
/** | ||
@@ -412,0 +475,0 @@ * Returns true if the transition is dynamic. |
@@ -23,2 +23,3 @@ "use strict"; | ||
var rejectFactory_1 = require("./rejectFactory"); | ||
var common_2 = require("../common"); | ||
/** @hidden */ | ||
@@ -192,2 +193,18 @@ var stateSelf = hof_1.prop('self'); | ||
}; | ||
Transition.prototype.paramsChanged = function () { | ||
var fromParams = this.params('from'); | ||
var toParams = this.params('to'); | ||
// All the parameters declared on both the "to" and "from" paths | ||
var allParamDescriptors = [] | ||
.concat(this._treeChanges.to) | ||
.concat(this._treeChanges.from) | ||
.map(function (pathNode) { return pathNode.paramSchema; }) | ||
.reduce(common_2.flattenR, []) | ||
.reduce(common_2.uniqR, []); | ||
var changedParamDescriptors = param_1.Param.changed(allParamDescriptors, fromParams, toParams); | ||
return changedParamDescriptors.reduce(function (changedValues, descriptor) { | ||
changedValues[descriptor.id] = toParams[descriptor.id]; | ||
return changedValues; | ||
}, {}); | ||
}; | ||
/** | ||
@@ -194,0 +211,0 @@ * Creates a [[UIInjector]] Dependency Injector |
@@ -92,4 +92,4 @@ /** | ||
*/ | ||
private getNotCurrentRejection(); | ||
private getNotCurrentRejection; | ||
toString(): string; | ||
} |
@@ -164,9 +164,9 @@ /** | ||
/** @hidden */ | ||
private _defineCoreEvents(); | ||
private _defineCoreEvents; | ||
/** @hidden */ | ||
private _defineCorePaths(); | ||
private _defineCorePaths; | ||
/** @hidden */ | ||
_defineEvent(name: string, hookPhase: TransitionHookPhase, hookOrder: number, criteriaMatchPath: PathType, reverseSort?: boolean, getResultHandler?: GetResultHandler, getErrorHandler?: GetErrorHandler, synchronous?: boolean): void; | ||
/** @hidden */ | ||
private _getEvents(phase?); | ||
private _getEvents; | ||
/** | ||
@@ -185,9 +185,9 @@ * Adds a Path to be used as a criterion against a TreeChanges path | ||
*/ | ||
private _definePathType(name, hookScope); | ||
private _definePathType; | ||
/** * @hidden */ | ||
private _getPathTypes(); | ||
private _getPathTypes; | ||
/** @hidden */ | ||
getHooks(hookName: string): RegisteredHook[]; | ||
/** @hidden */ | ||
private _registerCoreTransitionHooks(); | ||
private _registerCoreTransitionHooks; | ||
} |
@@ -14,3 +14,2 @@ /** | ||
import { ParamType } from '../params/paramType'; | ||
import { Param } from '../params/param'; | ||
import { UIRouter } from '../router'; | ||
@@ -21,11 +20,8 @@ import { TargetState } from '../state/targetState'; | ||
import { StateObject } from '../state/stateObject'; | ||
import { ParamTypeDefinition } from '../params/interface'; | ||
/** @internalapi */ | ||
export interface ParamFactory { | ||
/** Creates a new [[Param]] from a CONFIG block */ | ||
fromConfig(id: string, type: ParamType, config: any): Param; | ||
/** Creates a new [[Param]] from a url PATH */ | ||
fromPath(id: string, type: ParamType, config: any): Param; | ||
/** Creates a new [[Param]] from a url SEARCH */ | ||
fromSearch(id: string, type: ParamType, config: any): Param; | ||
import { ParamTypeDefinition } from '../params'; | ||
import { StateDeclaration } from '../state'; | ||
export interface UrlMatcherCompileConfig { | ||
state?: StateDeclaration; | ||
strict?: boolean; | ||
caseInsensitive?: boolean; | ||
} | ||
@@ -32,0 +28,0 @@ /** |
import { Param } from '../params/param'; | ||
import { ParamTypes } from '../params/paramTypes'; | ||
import { RawParams } from '../params/interface'; | ||
import { ParamFactory } from './interface'; | ||
import { UrlMatcherCompileConfig } from './interface'; | ||
import { ParamFactory } from './urlMatcherFactory'; | ||
/** | ||
@@ -57,3 +58,2 @@ * Matches URLs against patterns. | ||
export declare class UrlMatcher { | ||
config: any; | ||
/** @hidden */ | ||
@@ -71,2 +71,4 @@ static nameValidator: RegExp; | ||
private _compiled; | ||
/** @hidden */ | ||
private readonly config; | ||
/** The pattern that was passed into the constructor */ | ||
@@ -93,7 +95,6 @@ pattern: string; | ||
* @param paramTypes The [[ParamTypes]] registry | ||
* @param config A configuration object | ||
* - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`. | ||
* - `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`. | ||
* @param paramFactory A [[ParamFactory]] object | ||
* @param config A [[UrlMatcherCompileConfig]] configuration object | ||
*/ | ||
constructor(pattern: string, paramTypes: ParamTypes, paramFactory: ParamFactory, config?: any); | ||
constructor(pattern: string, paramTypes: ParamTypes, paramFactory: ParamFactory, config?: UrlMatcherCompileConfig); | ||
/** | ||
@@ -100,0 +101,0 @@ * Creates a new concatenated UrlMatcher |
@@ -13,2 +13,3 @@ "use strict"; | ||
var strings_1 = require("../common/strings"); | ||
var common_2 = require("../common"); | ||
/** @hidden */ | ||
@@ -37,2 +38,7 @@ function quoteRegExp(str, param) { | ||
var splitOnSlash = strings_1.splitOnDelim('/'); | ||
var defaultConfig = { | ||
state: { params: {} }, | ||
strict: true, | ||
caseInsensitive: true, | ||
}; | ||
/** | ||
@@ -93,9 +99,7 @@ * Matches URLs against patterns. | ||
* @param paramTypes The [[ParamTypes]] registry | ||
* @param config A configuration object | ||
* - `caseInsensitive` - `true` if URL matching should be case insensitive, otherwise `false`, the default value (for backward compatibility) is `false`. | ||
* - `strict` - `false` if matching against a URL with a trailing slash should be treated as equivalent to a URL without a trailing slash, the default value is `true`. | ||
* @param paramFactory A [[ParamFactory]] object | ||
* @param config A [[UrlMatcherCompileConfig]] configuration object | ||
*/ | ||
function UrlMatcher(pattern, paramTypes, paramFactory, config) { | ||
var _this = this; | ||
this.config = config; | ||
/** @hidden */ | ||
@@ -111,9 +115,4 @@ this._cache = { path: [this] }; | ||
this._compiled = []; | ||
this.config = config = common_2.defaults(config, defaultConfig); | ||
this.pattern = pattern; | ||
this.config = common_1.defaults(this.config, { | ||
params: {}, | ||
strict: true, | ||
caseInsensitive: false, | ||
paramMap: common_1.identity, | ||
}); | ||
// Find all placeholders and create a compiled pattern, using either classic or curly syntax: | ||
@@ -135,3 +134,4 @@ // '*' name | ||
var patterns = []; | ||
var last = 0, matchArray; | ||
var last = 0; | ||
var matchArray; | ||
var checkParamErrors = function (id) { | ||
@@ -157,3 +157,2 @@ if (!UrlMatcher.nameValidator.test(id)) | ||
regexp: regexp, | ||
cfg: _this.config.params[id], | ||
segment: pattern.substring(last, m.index), | ||
@@ -163,12 +162,13 @@ type: !regexp ? null : paramTypes.type(regexp) || makeRegexpType(regexp), | ||
}; | ||
var p, segment; | ||
var details; | ||
var segment; | ||
// tslint:disable-next-line:no-conditional-assignment | ||
while ((matchArray = placeholder.exec(pattern))) { | ||
p = matchDetails(matchArray, false); | ||
if (p.segment.indexOf('?') >= 0) | ||
details = matchDetails(matchArray, false); | ||
if (details.segment.indexOf('?') >= 0) | ||
break; // we're into the search part | ||
checkParamErrors(p.id); | ||
this._params.push(paramFactory.fromPath(p.id, p.type, this.config.paramMap(p.cfg, false))); | ||
this._segments.push(p.segment); | ||
patterns.push([p.segment, common_1.tail(this._params)]); | ||
checkParamErrors(details.id); | ||
this._params.push(paramFactory.fromPath(details.id, details.type, config.state)); | ||
this._segments.push(details.segment); | ||
patterns.push([details.segment, common_1.tail(this._params)]); | ||
last = placeholder.lastIndex; | ||
@@ -186,5 +186,5 @@ } | ||
while ((matchArray = searchPlaceholder.exec(search))) { | ||
p = matchDetails(matchArray, true); | ||
checkParamErrors(p.id); | ||
this._params.push(paramFactory.fromSearch(p.id, p.type, this.config.paramMap(p.cfg, true))); | ||
details = matchDetails(matchArray, true); | ||
checkParamErrors(details.id); | ||
this._params.push(paramFactory.fromSearch(details.id, details.type, config.state)); | ||
last = placeholder.lastIndex; | ||
@@ -191,0 +191,0 @@ // check if ?& |
import { UrlMatcher } from './urlMatcher'; | ||
import { Param } from '../params/param'; | ||
import { ParamTypes } from '../params/paramTypes'; | ||
import { ParamTypeDefinition } from '../params/interface'; | ||
import { Disposable } from '../interface'; | ||
import { ParamFactory, UrlMatcherConfig } from './interface'; | ||
import { ParamType } from '../params/paramType'; | ||
import { UrlMatcherCompileConfig, UrlMatcherConfig } from './interface'; | ||
import { StateDeclaration } from '../state'; | ||
/** @internalapi */ | ||
export declare class ParamFactory { | ||
private umf; | ||
fromConfig(id: string, type: ParamType, state: StateDeclaration): Param; | ||
fromPath(id: string, type: ParamType, state: StateDeclaration): Param; | ||
fromSearch(id: string, type: ParamType, state: StateDeclaration): Param; | ||
constructor(umf: UrlMatcherFactory); | ||
} | ||
/** | ||
@@ -26,4 +37,2 @@ * Factory for [[UrlMatcher]] instances. | ||
defaultSquashPolicy(value?: boolean | string): string | boolean; | ||
/** @hidden */ | ||
private _getConfig; | ||
/** | ||
@@ -36,5 +45,3 @@ * Creates a [[UrlMatcher]] for the specified pattern. | ||
*/ | ||
compile(pattern: string, config?: { | ||
[key: string]: any; | ||
}): UrlMatcher; | ||
compile(pattern: string, config?: UrlMatcherCompileConfig): UrlMatcher; | ||
/** | ||
@@ -41,0 +48,0 @@ * Returns true if the specified object is a [[UrlMatcher]], or false otherwise. |
"use strict"; | ||
var __assign = (this && this.__assign) || Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -12,2 +20,19 @@ /** | ||
var paramTypes_1 = require("../params/paramTypes"); | ||
/** @internalapi */ | ||
var ParamFactory = /** @class */ (function () { | ||
function ParamFactory(umf) { | ||
this.umf = umf; | ||
} | ||
ParamFactory.prototype.fromConfig = function (id, type, state) { | ||
return new param_1.Param(id, type, param_1.DefType.CONFIG, this.umf, state); | ||
}; | ||
ParamFactory.prototype.fromPath = function (id, type, state) { | ||
return new param_1.Param(id, type, param_1.DefType.PATH, this.umf, state); | ||
}; | ||
ParamFactory.prototype.fromSearch = function (id, type, state) { | ||
return new param_1.Param(id, type, param_1.DefType.SEARCH, this.umf, state); | ||
}; | ||
return ParamFactory; | ||
}()); | ||
exports.ParamFactory = ParamFactory; | ||
/** | ||
@@ -21,3 +46,2 @@ * Factory for [[UrlMatcher]] instances. | ||
function UrlMatcherFactory() { | ||
var _this = this; | ||
/** @hidden */ this.paramTypes = new paramTypes_1.ParamTypes(); | ||
@@ -28,14 +52,3 @@ /** @hidden */ this._isCaseInsensitive = false; | ||
/** @internalapi Creates a new [[Param]] for a given location (DefType) */ | ||
this.paramFactory = { | ||
/** Creates a new [[Param]] from a CONFIG block */ | ||
fromConfig: function (id, type, config) { return new param_1.Param(id, type, config, param_1.DefType.CONFIG, _this); }, | ||
/** Creates a new [[Param]] from a url PATH */ | ||
fromPath: function (id, type, config) { return new param_1.Param(id, type, config, param_1.DefType.PATH, _this); }, | ||
/** Creates a new [[Param]] from a url SEARCH */ | ||
fromSearch: function (id, type, config) { return new param_1.Param(id, type, config, param_1.DefType.SEARCH, _this); }, | ||
}; | ||
/** @hidden */ | ||
this._getConfig = function (config) { | ||
return common_1.extend({ strict: _this._isStrictMode, caseInsensitive: _this._isCaseInsensitive }, config); | ||
}; | ||
this.paramFactory = new ParamFactory(this); | ||
common_1.extend(this, { UrlMatcher: urlMatcher_1.UrlMatcher, Param: param_1.Param }); | ||
@@ -65,3 +78,7 @@ } | ||
UrlMatcherFactory.prototype.compile = function (pattern, config) { | ||
return new urlMatcher_1.UrlMatcher(pattern, this.paramTypes, this.paramFactory, this._getConfig(config)); | ||
// backward-compatible support for config.params -> config.state.params | ||
var params = config && !config.state && config.params; | ||
config = params ? __assign({ state: { params: params } }, config) : config; | ||
var globalConfig = { strict: this._isStrictMode, caseInsensitive: this._isCaseInsensitive }; | ||
return new urlMatcher_1.UrlMatcher(pattern, this.paramTypes, this.paramFactory, common_1.extend(globalConfig, config)); | ||
}; | ||
@@ -68,0 +85,0 @@ /** |
@@ -38,4 +38,4 @@ import { UrlMatcher } from './urlMatcher'; | ||
sort(compareFn?: (a: UrlRule, b: UrlRule) => number): void; | ||
private ensureSorted(); | ||
private stableSort(arr, compareFn); | ||
private ensureSorted; | ||
private stableSort; | ||
/** | ||
@@ -42,0 +42,0 @@ * Given a URL, check all rules and return the best [[MatchResult]] |
@@ -11,2 +11,3 @@ "use strict"; | ||
var hof_1 = require("../common/hof"); | ||
var stateObject_1 = require("../state/stateObject"); | ||
/** | ||
@@ -32,6 +33,7 @@ * Creates a [[UrlRule]] | ||
var _this = this; | ||
var isState = stateObject_1.StateObject.isState; | ||
var makeRule = hof_1.pattern([ | ||
[predicates_1.isString, function (_what) { return makeRule(_this.compile(_what)); }], | ||
[hof_1.is(urlMatcher_1.UrlMatcher), function (_what) { return _this.fromUrlMatcher(_what, handler); }], | ||
[predicates_1.isState, function (_what) { return _this.fromState(_what, _this.router); }], | ||
[isState, function (_what) { return _this.fromState(_what, _this.router); }], | ||
[hof_1.is(RegExp), function (_what) { return _this.fromRegExp(_what, handler); }], | ||
@@ -38,0 +40,0 @@ [predicates_1.isFunction, function (_what) { return new BaseUrlRule(_what, handler); }], |
@@ -14,4 +14,4 @@ import { LocationConfig } from '../common/coreservices'; | ||
baseHref(href?: string): string; | ||
applyDocumentBaseHref(): string; | ||
private getBaseHref; | ||
dispose(): void; | ||
} |
@@ -36,9 +36,13 @@ "use strict"; | ||
BrowserLocationConfig.prototype.baseHref = function (href) { | ||
return predicates_1.isDefined(href) | ||
? (this._baseHref = href) | ||
: predicates_1.isDefined(this._baseHref) ? this._baseHref : this.applyDocumentBaseHref(); | ||
if (predicates_1.isDefined(href)) | ||
this._baseHref = href; | ||
if (predicates_1.isUndefined(this._baseHref)) | ||
this._baseHref = this.getBaseHref(); | ||
return this._baseHref; | ||
}; | ||
BrowserLocationConfig.prototype.applyDocumentBaseHref = function () { | ||
BrowserLocationConfig.prototype.getBaseHref = function () { | ||
var baseTag = document.getElementsByTagName('base')[0]; | ||
return (this._baseHref = baseTag ? baseTag.href.substr(location.origin.length) : location.pathname || '/'); | ||
if (!baseTag || !baseTag.href) | ||
return location.pathname || '/'; | ||
return baseTag.href.replace(/^(https?:)?\/\/[^/]*/, ''); | ||
}; | ||
@@ -45,0 +49,0 @@ BrowserLocationConfig.prototype.dispose = function () { }; |
@@ -33,3 +33,3 @@ /** | ||
*/ | ||
private _getBasePrefix(); | ||
private _getBasePrefix; | ||
protected _get(): string; | ||
@@ -36,0 +36,0 @@ protected _set(state: any, title: string, url: string, replace: boolean): void; |
@@ -9,2 +9,3 @@ /** | ||
import { _ViewDeclaration } from '../state/interface'; | ||
import { UIRouter } from '../router'; | ||
export declare type ViewConfigFactory = (path: PathNode[], decl: _ViewDeclaration) => ViewConfig | ViewConfig[]; | ||
@@ -14,2 +15,4 @@ export interface ViewServicePluginAPI { | ||
_viewConfigFactory(viewType: string, factory: ViewConfigFactory): any; | ||
/** @param id router.$id + "." + uiView.id */ | ||
_registeredUIView(id: string): ActiveUIView; | ||
_registeredUIViews(): ActiveUIView[]; | ||
@@ -43,2 +46,3 @@ _activeViewConfigs(): ViewConfig[]; | ||
export declare class ViewService { | ||
private router; | ||
private _uiViews; | ||
@@ -123,5 +127,5 @@ private _viewConfigs; | ||
}; | ||
constructor(); | ||
private _rootViewContext(context?); | ||
private _viewConfigFactory(viewType, factory); | ||
constructor(router: UIRouter); | ||
private _rootViewContext; | ||
private _viewConfigFactory; | ||
createViewConfig(path: PathNode[], decl: _ViewDeclaration): ViewConfig[]; | ||
@@ -128,0 +132,0 @@ /** |
@@ -28,4 +28,5 @@ "use strict"; | ||
var ViewService = /** @class */ (function () { | ||
function ViewService() { | ||
function ViewService(router) { | ||
var _this = this; | ||
this.router = router; | ||
this._uiViews = []; | ||
@@ -38,2 +39,3 @@ this._viewConfigs = []; | ||
_viewConfigFactory: this._viewConfigFactory.bind(this), | ||
_registeredUIView: function (id) { return common_1.find(_this._uiViews, function (view) { return _this.router.$id + "." + view.id === id; }); }, | ||
_registeredUIViews: function () { return _this._uiViews; }, | ||
@@ -40,0 +42,0 @@ _activeViewConfigs: function () { return _this._viewConfigs; }, |
{ | ||
"name": "@uirouter/core", | ||
"description": "UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps", | ||
"version": "5.0.19", | ||
"version": "5.0.20", | ||
"scripts": { | ||
@@ -67,10 +67,10 @@ "clean": "shx rm -rf lib lib-esm _bundles .cache _doc", | ||
"jsnext:main": "lib-esm/index.js", | ||
"module": "lib-esm/index.js", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/jasmine": "^2.8.6", | ||
"@types/jquery": "^3.3.1", | ||
"@uirouter/publish-scripts": "^2.3.3", | ||
"@types/jasmine": "^2.8.8", | ||
"@types/jquery": "^3.3.2", | ||
"@uirouter/publish-scripts": "^2.3.18", | ||
"dts-downlevel": "^0.3.0", | ||
"fork-ts-checker-webpack-plugin": "^0.4.1", | ||
"glob": "^7.1.2", | ||
"fork-ts-checker-webpack-plugin": "^0.4.2", | ||
"husky": "^0.14.3", | ||
@@ -81,21 +81,18 @@ "jasmine-core": "^3.1.0", | ||
"karma-firefox-launcher": "^1.1.0", | ||
"karma-jasmine": "^1.1.1", | ||
"karma-jasmine": "^1.1.2", | ||
"karma-script-launcher": "^1.0.0", | ||
"karma-sourcemap-loader": "^0.3.7", | ||
"karma-webpack": "^3.0.0", | ||
"npm-run-all": "^4.1.2", | ||
"prettier": "^1.11.1", | ||
"pretty-quick": "^1.4.1", | ||
"rollup": "^0.58.0", | ||
"prettier": "^1.13.5", | ||
"pretty-quick": "^1.6.0", | ||
"rollup": "^0.62.0", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"rollup-plugin-uglify": "^3.0.0", | ||
"shelljs": "^0.8.1", | ||
"shx": "^0.2.2", | ||
"ts-loader": "^4.1.0", | ||
"tslint": "^5.9.1", | ||
"tslint-eslint-rules": "^5.1.0", | ||
"typescript": "^2.8.3", | ||
"webpack": "^4.2.0" | ||
"rollup-plugin-uglify": "^4.0.0", | ||
"ts-loader": "^4.4.1", | ||
"tslint": "^5.10.0", | ||
"tslint-eslint-rules": "^5.3.1", | ||
"typescript": "^2.9.1", | ||
"webpack": "^4.12.0" | ||
} | ||
} |
# UI-Router Core [![Build Status](https://travis-ci.org/ui-router/core.svg?branch=master)](https://travis-ci.org/ui-router/core) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/ui-router/core.svg)](https://greenkeeper.io/) | ||
UI-Router core provides client-side [Single Page Application](https://en.wikipedia.org/wiki/Single-page_application) | ||
@@ -6,0 +4,0 @@ routing for JavaScript. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
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
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
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
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
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
4428894
25
40969
81