Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ui-router/core
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5.0.6
Choose a base ref
...
head repository: ui-router/core
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 5.0.8
Choose a head ref
  • 17 commits
  • 36 files changed
  • 2 contributors

Commits on Aug 13, 2017

  1. Copy the full SHA
    215cafc View commit details

Commits on Sep 2, 2017

  1. Copy the full SHA
    6f7d4b8 View commit details

Commits on Sep 13, 2017

  1. Copy the full SHA
    87943c6 View commit details

Commits on Sep 14, 2017

  1. Copy the full SHA
    c8110fc View commit details

Commits on Sep 16, 2017

  1. Copy the full SHA
    a50db21 View commit details
  2. fix(Injector): When getting tokens from native injector, only throw o…

    …n undefined (not on falsey values)
    
    Closes #76
    christopherthielen committed Sep 16, 2017
    Copy the full SHA
    ada9ca2 View commit details
  3. Copy the full SHA
    2f1ae9a View commit details

Commits on Sep 21, 2017

  1. fix(globals): Use shallow copy to update the globals.params / $state.…

    …params object
    
    Previously, the `globals.params` object was updated using a deep copy.
    This causes problems when object-type parameter values aren't cloneable.
    
    Now, the parameter values are copied to the `globals.params` object using a shallow copy, i.e., `Object.assign`.
    This is consistent with parameter handling in the `PathNode` code also.
    
    If this commit is causing problems, it is likely that app code is mutating
    the existing object parameters and then calling `state.go` with the mutated
    parameters.  Recommend making a clone of the params before calling `state.go`.
    
    Closes #74
    christopherthielen committed Sep 21, 2017
    Copy the full SHA
    e883afc View commit details
  2. Copy the full SHA
    a4629ee View commit details

Commits on Sep 23, 2017

  1. fix(vanilla): fix base path handling for vanilla push state

    This fixes the vanilla PushState location service handling of `base` tags.
    This change attempts to match the behavior of https://html.spec.whatwg.org/dev/semantics.html#the-base-element
    If a base tag is '/base/index.html' and a state with a URL of '/foo' is activated, the URL will be '/base/foo'.
    If the url exactly matches the base tag, it will route to the state matching '/'.
    
    This also addresses a longstanding bug where base tags which didn't end in a slash (such as '/base')
    had their last character stripped (i.e., '/bas'), and therefore didn't work.
    Now base tags like that should work as described above.
    
    Closes #54
    Closes angular-ui/ui-router#2357
    christopherthielen committed Sep 23, 2017
    Copy the full SHA
    ad61d74 View commit details
  2. 5.0.7

    christopherthielen committed Sep 23, 2017
    Copy the full SHA
    c028447 View commit details

Commits on Sep 30, 2017

  1. Copy the full SHA
    a4581b1 View commit details
  2. Copy the full SHA
    bf97873 View commit details
  3. fix(redirectTo): Fix typings for redirectTo. Allow a function that re…

    …turns a target state or a promise for one.
    christopherthielen committed Sep 30, 2017
    Copy the full SHA
    3904487 View commit details
  4. feat(TargetState): Add builder methods .withState, .withParams, and .…

    …withOptions
    
    Remove ParamsOrArray type which was not really used.
    christopherthielen committed Sep 30, 2017
    Copy the full SHA
    6b93142 View commit details
  5. Fix documentation typo

    kylekatarnls authored and christopherthielen committed Sep 30, 2017
    Copy the full SHA
    104a443 View commit details
  6. 5.0.8

    christopherthielen committed Sep 30, 2017
    Copy the full SHA
    13d3177 View commit details
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,33 @@
## 5.0.8 (2017-09-30)
[Compare `@uirouter/core` versions 5.0.7 and 5.0.8](https://github.com/ui-router/core/compare/5.0.7...5.0.8)

### Bug Fixes

* **bundle:** Rollup: Do not warn on THIS_IS_UNDEFINED ([a4581b1](https://github.com/ui-router/core/commit/a4581b1))
* **redirectTo:** Fix typings for redirectTo. Allow a function that returns a target state or a promise for one. ([3904487](https://github.com/ui-router/core/commit/3904487))


### Features

* **TargetState:** Add builder methods .withState, .withParams, and .withOptions ([6b93142](https://github.com/ui-router/core/commit/6b93142))



## 5.0.7 (2017-09-23)
[Compare `@uirouter/core` versions 5.0.6 and 5.0.7](https://github.com/ui-router/core/compare/5.0.6...5.0.7)

### Bug Fixes

* **globals:** Use shallow copy to update the globals.params / $state.params object ([e883afc](https://github.com/ui-router/core/commit/e883afc))
* **Injector:** When getting tokens from native injector, only throw on undefined (not on falsey values) ([ada9ca2](https://github.com/ui-router/core/commit/ada9ca2))
* **trace:** Fall back to console.log if .table is unavailable (IE) ([c8110fc](https://github.com/ui-router/core/commit/c8110fc))
* **trace:** Support tracing of object-parameters with circular references ([2f1ae9a](https://github.com/ui-router/core/commit/2f1ae9a))
* **url:** Add CustomEvent polyfill for IE ([a50db21](https://github.com/ui-router/core/commit/a50db21))
* **vanilla:** fix base path handling for vanilla push state ([ad61d74](https://github.com/ui-router/core/commit/ad61d74))
* **vanilla:** Use `self` instead of `window` for webworker compat ([a4629ee](https://github.com/ui-router/core/commit/a4629ee))



## Changes in `@uirouter/core` between versions [5.0.5 and 5.0.6](https://github.com/ui-router/core/compare/5.0.5...5.0.6) (2017-08-12)


7 changes: 4 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -26,11 +26,12 @@ module.exports = function (karma) {
frameworks: ['jasmine'],

plugins: [
require('karma-webpack'),
require('karma-sourcemap-loader'),
require('karma-chrome-launcher'),
require('karma-firefox-launcher'),
require('karma-jasmine'),
require('karma-phantomjs-launcher'),
require('karma-chrome-launcher')
require('karma-sourcemap-loader'),
require('karma-webpack'),
],

webpack: {
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@uirouter/core",
"description": "UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps",
"version": "5.0.6",
"version": "5.0.8",
"scripts": {
"clean": "shx rm -rf lib lib-esm _bundles",
"build": "npm run clean && tsc && tsc -m es6 --outDir lib-esm && npm run fixdts && npm run bundle && npm run fixmaps",
@@ -63,18 +63,18 @@
"devDependencies": {
"@types/jasmine": "^2.5.47",
"@types/jquery": "^1.10.31",
"@uirouter/publish-scripts": "^1.0.0",
"@uirouter/publish-scripts": "^1.0.7",
"awesome-typescript-loader": "3.0.0-beta.10",
"conventional-changelog": "^1.1.0",
"conventional-changelog-cli": "^1.1.1",
"conventional-changelog-ui-router-core": "^1.4.1",
"core-js": "^2.4.1",
"dts-downlevel": "^0.3.0",
"glob": "^7.1.2",
"jasmine-core": "^2.4.1",
"karma": "^1.2.0",
"karma-chrome-launcher": "~0.1.0",
"karma-coverage": "^0.5.3",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-script-launcher": "~0.1.0",
@@ -91,7 +91,7 @@
"shelljs": "^0.7.0",
"shx": "^0.1.4",
"tslint": "^4.5.1",
"typescript": "~2.4.0",
"typescript": "2.5.3",
"webpack": "^1.13.3"
}
}
21 changes: 15 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -4,23 +4,31 @@ import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';
import visualizer from 'rollup-plugin-visualizer';

var MINIFY = process.env.MINIFY;
const MINIFY = process.env.MINIFY;

var pkg = require('./package.json');
var banner =
const pkg = require('./package.json');
const banner =
`/**
* ${pkg.description}
* @version v${pkg.version}
* @link ${pkg.homepage}
* @license MIT License, http://www.opensource.org/licenses/MIT
*/`;

var uglifyOpts = { output: {} };
const uglifyOpts = { output: {} };
// retain multiline comment with @license
uglifyOpts.output.comments = (node, comment) =>
comment.type === 'comment2' && /@license/i.test(comment.value);

var plugins = [
const onwarn = (warning) => {
// Suppress this error message... https://github.com/rollup/rollup/wiki/Troubleshooting#this-is-undefined
const ignores = ['THIS_IS_UNDEFINED'];
if (!ignores.some(code => code === warning.code)) {
console.error(warning.message);
}
};

const plugins = [
nodeResolve({jsnext: true}),
progress({ clearLine: false }),
sourcemaps(),
@@ -29,7 +37,7 @@ var plugins = [

if (MINIFY) plugins.push(uglify(uglifyOpts));

var extension = MINIFY ? ".min.js" : ".js";
const extension = MINIFY ? ".min.js" : ".js";

const CONFIG = {
moduleName: '@uirouter/core',
@@ -41,6 +49,7 @@ const CONFIG = {
exports: 'named',
plugins: plugins,
banner: banner,
onwarn: onwarn,
};

export default CONFIG;
6 changes: 1 addition & 5 deletions src/common/common.ts
Original file line number Diff line number Diff line change
@@ -16,7 +16,6 @@ let w: any = typeof window === 'undefined' ? {} : window;
let angular = w.angular || {};
export const fromJson = angular.fromJson || JSON.parse.bind(JSON);
export const toJson = angular.toJson || JSON.stringify.bind(JSON);
export const copy = angular.copy || _copy;
export const forEach = angular.forEach || _forEach;
export const extend = Object.assign || _extend;
export const equals = angular.equals || _equals;
@@ -528,11 +527,8 @@ export function tail<T>(arr: T[]): T {

/**
* shallow copy from src to dest
*
* note: This is a shallow copy, while angular.copy is a deep copy.
* ui-router uses `copy` only to make copies of state parameters.
*/
function _copy(src: Obj, dest: Obj) {
export function copy(src: Obj, dest?: Obj) {
if (dest) Object.keys(dest).forEach(key => delete dest[key]);
if (!dest) dest = {};
return extend(dest, src);
9 changes: 8 additions & 1 deletion src/common/strings.ts
Original file line number Diff line number Diff line change
@@ -111,13 +111,20 @@ export function stringify(o: any) {
}

/** Returns a function that splits a string on a character or substring */
export const beforeAfterSubstr = (char: string) => (str: string) => {
export const beforeAfterSubstr = (char: string) => (str: string): string[] => {
if (!str) return ["", ""];
let idx = str.indexOf(char);
if (idx === -1) return [str, ""];
return [str.substr(0, idx), str.substr(idx + 1)];
};

export const hostRegex = new RegExp('^(?:[a-z]+:)?//[^/]+/');
export const stripFile = (str: string) => str.replace(/\/[^/]*$/, '');
export const splitHash = beforeAfterSubstr("#");
export const splitQuery = beforeAfterSubstr("?");
export const splitEqual = beforeAfterSubstr("=");
export const trimHashVal = (str: string) => str ? str.replace(/^#/, "") : "";

/**
* Splits on a delimiter, but returns the delimiters in the array
*
6 changes: 4 additions & 2 deletions src/common/trace.ts
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
* @module trace
*/ /** for typedoc */
import {parse} from "../common/hof";
import {isNumber} from "../common/predicates";
import {isFunction, isNumber} from "../common/predicates";
import {Transition} from "../transition/transition";
import {ActiveUIView, ViewConfig, ViewContext} from "../view/interface";
import {stringify, functionToString, maxLength, padString} from "./strings";
@@ -64,6 +64,8 @@ function normalizedCat(input: Category|string): string {
return isNumber(input) ? Category[input] : Category[Category[input]];
}

/** @hidden */
const consoletable = isFunction(console.table) ? console.table.bind(console) : console.log.bind(console);

/**
* Trace categories Enum
@@ -229,7 +231,7 @@ export class Trace {
return { 'ui-view fqn': uiView, 'state: view name': view };
}).sort((a, b) => a['ui-view fqn'].localeCompare(b['ui-view fqn']));

console.table(mapping);
consoletable(mapping);
}

/** @internalapi called by ui-router code */
2 changes: 0 additions & 2 deletions src/globals.ts
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ import {StateDeclaration} from "./state/interface";
import {StateObject} from "./state/stateObject";
import {Transition} from "./transition/transition";
import {Queue} from "./common/queue";
import {TransitionService} from "./transition/transitionService";
import {copy} from "./common/common";
import { Disposable } from './interface';

/**
9 changes: 3 additions & 6 deletions src/params/interface.ts
Original file line number Diff line number Diff line change
@@ -24,9 +24,6 @@ export interface RawParams {
[key: string]: any;
}

/** @internalapi */
export type ParamsOrArray = (RawParams|RawParams[]);

/**
* Configuration for a single Parameter
*
@@ -465,15 +462,15 @@ export interface Replace {
* // Changes URL to '/list/3', logs "Ringo" to the console
* $state.go('list', { item: "Ringo" });
* ```
*
*
* See: [[UrlConfigApi.type]]
* @coreapi
*/
export interface ParamTypeDefinition {
/**
* Tests if some object type is compatible with this parameter type
*
* Detects whether some value is of this particular type.
*
* Detects whether some value is of this particular type.
* Accepts a decoded value and determines whether it matches this `ParamType` object.
*
* If your custom type encodes the parameter to a specific type, check for that type here.
13 changes: 6 additions & 7 deletions src/params/paramTypes.ts
Original file line number Diff line number Diff line change
@@ -286,15 +286,15 @@ function initDefaultTypes() {
encode: (val: any) => val && 1 || 0,
decode: (val: string) => parseInt(val, 10) !== 0,
is: is(Boolean),
pattern: /0|1/
pattern: /0|1/,
}),

date: makeDefaultType({
encode: function(val: any) {
return !this.is(val) ? undefined : [
val.getFullYear(),
('0' + (val.getMonth() + 1)).slice(-2),
('0' + val.getDate()).slice(-2)
('0' + val.getDate()).slice(-2),
].join("-");
},
decode: function(val: string) {
@@ -305,18 +305,18 @@ function initDefaultTypes() {
is: (val: any) => val instanceof Date && !isNaN(val.valueOf()),
equals(l: any, r: any) {
return ['getFullYear', 'getMonth', 'getDate']
.reduce((acc, fn) => acc && l[fn]() === r[fn](), true)
.reduce((acc, fn) => acc && l[fn]() === r[fn](), true);
},
pattern: /[0-9]{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[1-2][0-9]|3[0-1])/,
capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/
capture: /([0-9]{4})-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])/,
}),

json: makeDefaultType({
encode: toJson,
decode: fromJson,
is: is(Object),
equals: equals,
pattern: /[^/]*/
pattern: /[^/]*/,
}),

// does not encode/decode
@@ -326,8 +326,7 @@ function initDefaultTypes() {
is: () => true,
equals: equals,
}),
})

});
}

initDefaultTypes();
5 changes: 3 additions & 2 deletions src/path/pathFactory.ts
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ import {TargetState} from "../state/targetState";
import {GetParamsFn, PathNode} from "./pathNode";
import {ViewService} from "../view/view";
import { Param } from '../params/param';
import { StateRegistry } from '../state';

/**
* This class contains functions which convert TargetStates, Nodes and paths from one type to another.
@@ -24,9 +25,9 @@ export class PathUtils {
constructor() { }

/** Given a PathNode[], create an TargetState */
static makeTargetState(path: PathNode[]): TargetState {
static makeTargetState(registry: StateRegistry, path: PathNode[]): TargetState {
let state = tail(path).state;
return new TargetState(state, state, path.map(prop("paramValues")).reduce(mergeR, {}));
return new TargetState(registry, state, path.map(prop("paramValues")).reduce(mergeR, {}), {});
}

static buildPath(targetState: TargetState) {
20 changes: 11 additions & 9 deletions src/resolve/resolveContext.ts
Original file line number Diff line number Diff line change
@@ -12,10 +12,11 @@ import { PathUtils } from "../path/pathFactory";
import { stringify } from "../common/strings";
import { Transition } from "../transition/transition";
import { UIInjector } from "../interface";
import { isUndefined } from '../common';

const when = resolvePolicies.when;
const ALL_WHENS = [when.EAGER, when.LAZY];
const EAGER_WHENS = [when.EAGER];
const whens = resolvePolicies.when;
const ALL_WHENS = [whens.EAGER, whens.LAZY];
const EAGER_WHENS = [whens.EAGER];

export const NATIVE_INJECTOR_TOKEN: string = "Native Injector";

@@ -105,7 +106,7 @@ export class ResolveContext {
let keys = newResolvables.map(r => r.token);
node.resolvables = node.resolvables.filter(r => keys.indexOf(r.token) === -1).concat(newResolvables);
}

/**
* Returns a promise for an array of resolved path Element promises
*
@@ -119,7 +120,7 @@ export class ResolveContext {
// If the caller specified EAGER, only the EAGER Resolvables are fetched.
// if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
let matchedWhens = whenOption === resolvePolicies.when.EAGER ? EAGER_WHENS : ALL_WHENS;

// get the subpath to the state argument, if provided
trace.traceResolvePath(this._path, when, trans);

@@ -166,15 +167,15 @@ export class ResolveContext {
// subpath stopping at resolvable's node, or the whole path (if the resolvable isn't in the path)
let subPath: PathNode[] = PathUtils.subPath(this._path, x => x === node) || this._path;
let availableResolvables: Resolvable[] = subPath
.reduce((acc, node) => acc.concat(node.resolvables), []) //all of subpath's resolvables
.reduce((acc, _node) => acc.concat(_node.resolvables), []) //all of subpath's resolvables
.filter(res => res !== resolvable); // filter out the `resolvable` argument

const getDependency = (token: any) => {
let matching = availableResolvables.filter(r => r.token === token);
if (matching.length) return tail(matching);

let fromInjector = this.injector().getNative(token);
if (!fromInjector) {
if (isUndefined(fromInjector)) {
throw new Error("Could not find Dependency Injection token: " + stringify(token));
}

@@ -204,7 +205,8 @@ class UIInjectorImpl implements UIInjector {
}
return resolvable.data;
}
return this.native && this.native.get(token);

return this.getNative(token);
}

getAsync(token: any) {
@@ -216,4 +218,4 @@ class UIInjectorImpl implements UIInjector {
getNative(token: any) {
return this.native && this.native.get(token);
}
}
}
Loading