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.11
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.13
Choose a head ref
Loading
35 changes: 22 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
language: node_js
node_js:
- "7.9"
- '7.9'

cache:
yarn: true
bundler: true
directories:
- $HOME/.yarn-cache
- $HOME/.cache/yarn
- node_modules
- "$HOME/.yarn-cache"
- "$HOME/.cache/yarn"
- node_modules

before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- curl -o- -L https://yarnpkg.com/install.sh | bash
- export PATH="$HOME/.yarn/bin:$PATH"
- yarn global add greenkeeper-lockfile@1


install:
- yarn
- yarn

before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- ./nodeserver.sh > /dev/null &
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- "./nodeserver.sh > /dev/null &"
- greenkeeper-lockfile-update

script:
- tsc
- yarn test
- tsc
- yarn test

after_script: greenkeeper-lockfile-upload

sudo: false

git:
depth: 3

notifications:
slack: angularbuddies:b6leQM9gkBCW0S7MNDsELpqU
slack:
secure: VlSFXHFYU4jlc5OSX0JZcZfXY73uIELlQJ7sYadyW7Cu3SqeTGSTxhGxDBir5aLVgONXFXXW2JJTKIXK3Sdl7+IpCetR5cgqoYNaINMgOU9uw4XVwZ4BEQoQlYeP6YaR5GJNaF1tz5H/8aon/RlNqiaRzaUUHsmmI7tTvGuceT0d77IxwmWZbSQKK3cxRK0LtlOzD0yAlVE+3omei94DXlDMcUi3wy83UjOhc+SJHp9w5Z0CsAjRe8pD1nMDf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ClDWhzBii21JsdMyUS3TUFGyVIfok2M+uaM2NZn7GLNRSOGarBpLhF/5lci/9kY=
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,32 @@
## 5.0.13 (2017-12-22)
[Compare `@uirouter/core` versions 5.0.12 and 5.0.13](https://github.com/ui-router/core/compare/5.0.12...5.0.13)

### Bug Fixes

* **browserLocation:** Use location.pathname (not href) or '/' when no base tag found ([db461d6](https://github.com/ui-router/core/commit/db461d6))
* **browserLocationConfig:** If no base href found, use location.href (not empty string) ([0251424](https://github.com/ui-router/core/commit/0251424))
* **pushStateLocation:** Fix URLs: add slash between base and path when necessary ([bfa5755](https://github.com/ui-router/core/commit/bfa5755))
* **pushStateLocation:** When url is "" or "/", use baseHref for pushState ([042a950](https://github.com/ui-router/core/commit/042a950))
* **resolve:** Add onFinish hook to resolve any dynamicly added resolvables ([7d1ca54](https://github.com/ui-router/core/commit/7d1ca54))


### Features

* **view:** Add onSync callback API to plugin API ([9544ae5](https://github.com/ui-router/core/commit/9544ae5))




## 5.0.12 (2017-12-18)
[Compare `@uirouter/core` versions 5.0.11 and 5.0.12](https://github.com/ui-router/core/compare/5.0.11...5.0.12)

### Bug Fixes

* **urlRouter:** Update query params when resetting url via .update() ([7664cd0](https://github.com/ui-router/core/commit/7664cd0))




## 5.0.11 (2017-10-14)
[Compare `@uirouter/core` versions 5.0.10 and 5.0.11](https://github.com/ui-router/core/compare/5.0.10...5.0.11)

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 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)
routing for JavaScript.
This core is framework agnostic.
18 changes: 14 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Karma configuration file
var karma = require('karma');
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');

module.exports = function (karma) {
var config = {
@@ -38,16 +39,25 @@ module.exports = function (karma) {
devtool: 'inline-source-map',

resolve: {
modulesDirectories: ['node_modules'],
extensions: ['', '.js', '.ts']
extensions: ['.js', '.ts']
},

module: {
loaders: [
{ test: /\.ts$/, loader: "awesome-typescript-loader?noEmit=true&configFileName=test/tsconfig.json" }
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
options: {
configFile: 'test/tsconfig.json',
transpileOnly: true,
},
}
]
},

plugins: [
new ForkTsCheckerWebpackPlugin()
],
},

webpackMiddleware: {
38 changes: 18 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@uirouter/core",
"description": "UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps",
"version": "5.0.11",
"version": "5.0.13",
"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",
"compile": "npm run clean && tsc && tsc -m es6 --outDir lib-esm",
"build": "run-s compile fixdts bundle fixmaps:*",
"bundle": "rollup -c && rollup -c --environment MINIFY",
"fixdts": "dts-downlevel 'lib/**/*.d.ts' 'lib-esm/**/*.d.ts'",
"fixmaps": "run-s fixmaps:*",
"fixmaps:lib": "tweak_sourcemap_paths -a --include 'lib/**/*.js.map' 'lib-esm/**/*.js.map'",
"fixmaps:bundle": "tweak_sourcemap_paths -a --include '_bundles/**/*.js.map'",
"install": "node migrate/migratewarn.js",
@@ -64,36 +64,34 @@
"license": "MIT",
"devDependencies": {
"@types/jasmine": "^2.5.47",
"@types/jquery": "^1.10.31",
"@uirouter/publish-scripts": "1.1.1",
"awesome-typescript-loader": "3.0.0-beta.10",
"@types/jquery": "3.2.17",
"@uirouter/publish-scripts": "2.0.8",
"conventional-changelog": "^1.1.0",
"conventional-changelog-cli": "^1.1.1",
"core-js": "^2.4.1",
"dts-downlevel": "^0.3.0",
"fork-ts-checker-webpack-plugin": "^0.2.9",
"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": "2.0.0",
"karma-chrome-launcher": "2.2.0",
"karma-firefox-launcher": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.4",
"karma-script-launcher": "~0.1.0",
"karma-script-launcher": "~1.0.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"npm-run-all": "^3.1.1",
"karma-webpack": "^2.0.9",
"npm-run-all": "^4.1.2",
"readline-sync": "^1.4.4",
"rollup": "^0.41.6",
"rollup": "^0.52.3",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-progress": "^0.2.1",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-uglify": "^1.0.2",
"rollup-plugin-visualizer": "^0.2.1",
"rollup-plugin-uglify": "^2.0.1",
"shelljs": "^0.7.0",
"shx": "^0.1.4",
"tslint": "^4.5.1",
"typescript": "2.5.3",
"webpack": "^1.13.3"
"shx": "^0.2.2",
"ts-loader": "^3.2.0",
"tslint": "^5.8.0",
"typescript": "2.6.2",
"webpack": "^3.10.0"
}
}
16 changes: 7 additions & 9 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import nodeResolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';
import progress from 'rollup-plugin-progress';
import sourcemaps from 'rollup-plugin-sourcemaps';
import visualizer from 'rollup-plugin-visualizer';

const MINIFY = process.env.MINIFY;

@@ -30,22 +28,22 @@ const onwarn = (warning) => {

const plugins = [
nodeResolve({jsnext: true}),
progress({ clearLine: false }),
sourcemaps(),
visualizer({ sourcemap: true }),
];

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

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

const CONFIG = {
moduleName: '@uirouter/core',
entry: 'lib-esm/index.js',
dest: '_bundles/ui-router-core' + extension,
input: 'lib-esm/index.js',
output: {
name: '@uirouter/core',
file: '_bundles/ui-router-core' + extension,
sourcemap: true,
format: 'umd',
},

sourceMap: true,
format: 'umd',
exports: 'named',
plugins: plugins,
banner: banner,
2 changes: 1 addition & 1 deletion src/common/strings.ts
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ export const beforeAfterSubstr = (char: string) => (str: string): string[] => {
};

export const hostRegex = new RegExp('^(?:[a-z]+:)?//[^/]+/');
export const stripFile = (str: string) => str.replace(/\/[^/]*$/, '');
export const stripLastPathElement = (str: string) => str.replace(/\/[^/]*$/, '');
export const splitHash = beforeAfterSubstr("#");
export const splitQuery = beforeAfterSubstr("?");
export const splitEqual = beforeAfterSubstr("=");
33 changes: 17 additions & 16 deletions src/common/trace.ts
Original file line number Diff line number Diff line change
@@ -33,17 +33,18 @@
* @coreapi
* @module trace
*/ /** for typedoc */
import {parse} from "../common/hof";
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";
import {Resolvable} from "../resolve/resolvable";
import {PathNode} from "../path/pathNode";
import {PolicyWhen} from "../resolve/interface";
import {TransitionHook} from "../transition/transitionHook";
import {HookResult} from "../transition/interface";
import {StateObject} from "../state/stateObject";
import { parse } from "../common/hof";
import { isFunction, isNumber } from "../common/predicates";
import { Transition } from "../transition/transition";
import { ViewTuple } from '../view';
import { ActiveUIView, ViewConfig, ViewContext } from "../view/interface";
import { stringify, functionToString, maxLength, padString } from "./strings";
import { Resolvable } from "../resolve/resolvable";
import { PathNode } from "../path/pathNode";
import { PolicyWhen } from "../resolve/interface";
import { TransitionHook } from "../transition/transitionHook";
import { HookResult } from "../transition/interface";
import { StateObject } from "../state/stateObject";

/** @hidden */
function uiViewString (uiview: ActiveUIView) {
@@ -226,13 +227,13 @@ export class Trace {
}

/** @internalapi called by ui-router code */
traceViewSync(pairs: any[]) {
traceViewSync(pairs: ViewTuple[]) {
if (!this.enabled(Category.VIEWCONFIG)) return;
const mapping = pairs.map(([ uiViewData, config ]) => {
const uiView = `${uiViewData.$type}:${uiViewData.fqn}`;
const view = config && `${config.viewDecl.$context.name}: ${config.viewDecl.$name} (${config.viewDecl.$type})`;
const mapping = pairs.map(({ uiView, viewConfig }) => {
const uiv = uiView && uiView.fqn;
const cfg = viewConfig && `${viewConfig.viewDecl.$context.name}: ${viewConfig.viewDecl.$name}`;

return { 'ui-view fqn': uiView, 'state: view name': view };
return { 'ui-view fqn': uiv, 'state: view name': cfg };
}).sort((a, b) => a['ui-view fqn'].localeCompare(b['ui-view fqn']));

consoletable(mapping);
28 changes: 24 additions & 4 deletions src/hooks/resolve.ts
Original file line number Diff line number Diff line change
@@ -8,10 +8,12 @@ import { TransitionService } from '../transition/transitionService';
import { val } from '../common/hof';
import { StateDeclaration } from '../state/interface';

export const RESOLVE_HOOK_PRIORITY = 1000;

/**
* A [[TransitionHookFn]] which resolves all EAGER Resolvables in the To Path
*
* Registered using `transitionService.onStart({}, eagerResolvePath);`
* Registered using `transitionService.onStart({}, eagerResolvePath, { priority: 1000 });`
*
* When a Transition starts, this hook resolves all the EAGER Resolvables, which the transition then waits for.
*
@@ -23,12 +25,12 @@ const eagerResolvePath: TransitionHookFn = (trans: Transition) =>
.then(noop);

export const registerEagerResolvePath = (transitionService: TransitionService) =>
transitionService.onStart({}, eagerResolvePath, {priority: 1000});
transitionService.onStart({}, eagerResolvePath, {priority: RESOLVE_HOOK_PRIORITY});

/**
* A [[TransitionHookFn]] which resolves all LAZY Resolvables for the state (and all its ancestors) in the To Path
*
* Registered using `transitionService.onEnter({ entering: () => true }, lazyResolveState);`
* Registered using `transitionService.onEnter({ entering: () => true }, lazyResolveState, { priority: 1000 });`
*
* When a State is being entered, this hook resolves all the Resolvables for this state, which the transition then waits for.
*
@@ -41,5 +43,23 @@ const lazyResolveState: TransitionStateHookFn = (trans: Transition, state: State
.then(noop);

export const registerLazyResolveState = (transitionService: TransitionService) =>
transitionService.onEnter({ entering: val(true) }, lazyResolveState, {priority: 1000});
transitionService.onEnter({ entering: val(true) }, lazyResolveState, {priority: RESOLVE_HOOK_PRIORITY});


/**
* A [[TransitionHookFn]] which resolves any dynamically added (LAZY or EAGER) Resolvables.
*
* Registered using `transitionService.onFinish({}, eagerResolvePath, { priority: 1000 });`
*
* After all entering states have been entered, this hook resolves any remaining Resolvables.
* These are typically dynamic resolves which were added by some Transition Hook using [[Transition.addResolvable]].
*
* See [[StateDeclaration.resolve]]
*/
const resolveRemaining: TransitionHookFn = (trans: Transition) =>
new ResolveContext(trans.treeChanges().to)
.resolvePath("LAZY", trans)
.then(noop);

export const registerResolveRemaining = (transitionService: TransitionService) =>
transitionService.onFinish({}, resolveRemaining, {priority: RESOLVE_HOOK_PRIORITY});
22 changes: 17 additions & 5 deletions src/transition/transition.ts
Original file line number Diff line number Diff line change
@@ -297,9 +297,9 @@ export class Transition implements IHookRegistry {
* #### Example:
* ```js
* .onEnter({ to: 'foo.bar' }, trans => {
* // returns result of `foo` state's `data` resolve
* // even though `foo.bar` also has a `data` resolve
* var fooData = trans.injector('foo').get('data');
* // returns result of `foo` state's `myResolve` resolve
* // even though `foo.bar` also has a `myResolve` resolve
* var fooData = trans.injector('foo').get('myResolve');
* });
* ```
*
@@ -308,8 +308,8 @@ export class Transition implements IHookRegistry {
* #### Example:
* ```js
* .onExit({ exiting: 'foo.bar' }, trans => {
* // Gets the resolve value of `data` from the exiting state.
* var fooData = trans.injector(null, 'foo.bar').get('data');
* // Gets the resolve value of `myResolve` from the state being exited
* var fooData = trans.injector(null, 'from').get('myResolve');
* });
* ```
*
@@ -364,6 +364,18 @@ export class Transition implements IHookRegistry {
/**
* Dynamically adds a new [[Resolvable]] (i.e., [[StateDeclaration.resolve]]) to this transition.
*
* Allows a transition hook to dynamically add a Resolvable to this Transition.
*
* Use the [[Transition.injector]] to retrieve the resolved data in subsequent hooks ([[UIInjector.get]]).
*
* If a `state` argument is provided, the Resolvable is processed when that state is being entered.
* If no `state` is provided then the root state is used.
* If the given `state` has already been entered, the Resolvable is processed when any child state is entered.
* If no child states will be entered, the Resolvable is processed during the `onFinish` phase of the Transition.
*
* The `state` argument also scopes the resolved data.
* The resolved data is available from the injector for that `state` and any children states.
*
* #### Example:
* ```js
* transitionService.onBefore({}, transition => {
Loading