Skip to content

Commit 3d3c46f

Browse files
Merge feature-1.0 into master
2 parents 5ba793a + e7a3481 commit 3d3c46f

File tree

175 files changed

+32903
-144293
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

175 files changed

+32903
-144293
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ node_modules
77
bower_components
88
.DS_Store
99
*~
10+
.tscache
11+
.baseDir.ts
1012

1113
# webstorm files
1214
.idea
15+
idea-out
1316
*.iml
1417
*.ipr
1518
*.iws
19+
20+
# generate doc to _doc; copy to proper gh-pages dir
21+
_doc

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ before_script:
77
- sh -e /etc/init.d/xvfb start
88
- npm install -g karma
99
- npm install -g grunt-cli
10+
- npm install -g bower
11+
- bower install
1012
- ./nodeserver.sh > /dev/null &
1113

1214
script:
@@ -16,3 +18,6 @@ sudo: false
1618

1719
git:
1820
depth: 10
21+
22+
notifications:
23+
slack: angularbuddies:b6leQM9gkBCW0S7MNDsELpqU

Gruntfile.js

Lines changed: 96 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module.exports = function (grunt) {
33

44
require('load-grunt-tasks')(grunt);
55
var files = require('./files').files;
6+
var systemjs = require('systemjs');
7+
//var jspm = require('jspm');
68

79
// Project configuration.
810
grunt.initConfig({
@@ -18,28 +20,63 @@ module.exports = function (grunt) {
1820
' */'
1921
},
2022
clean: [ '<%= builddir %>' ],
21-
concat: {
22-
options: {
23-
banner: '<%= meta.banner %>\n\n'+
24-
'/* commonjs package manager support (eg componentjs) */\n'+
25-
'if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){\n'+
26-
' module.exports = \'ui.router\';\n'+
27-
'}\n\n'+
28-
'(function (window, angular, undefined) {\n',
29-
footer: '})(window, window.angular);'
23+
ts: {
24+
es5: {
25+
src: files.src,
26+
outDir: '<%= builddir %>/es5',
27+
options: { module: 'commonjs'}
3028
},
31-
build: {
29+
es6: {
3230
src: files.src,
33-
dest: '<%= builddir %>/<%= pkg.name %>.js'
31+
outDir: '<%= builddir %>/es6',
32+
options: { target: "es6"}
3433
}
3534
},
3635
uglify: {
3736
options: {
38-
banner: '<%= meta.banner %>\n'
37+
banner: '<%= meta.banner %>\n',
38+
mangle: true
3939
},
4040
build: {
4141
files: {
42-
'<%= builddir %>/<%= pkg.name %>.min.js': ['<banner:meta.banner>', '<%= concat.build.dest %>']
42+
'<%= builddir %>/ui-router.min.js': ['<banner:meta.banner>', '<%= builddir %>/ui-router.js'],
43+
'<%= builddir %>/<%= pkg.name %>.min.js': ['<banner:meta.banner>', '<%= builddir %>/<%= pkg.name %>.js'],
44+
'<%= builddir %>/ng1/stateEvents.min.js': ['<banner:meta.banner>', '<%= builddir %>/ng1/stateEvents.js']
45+
}
46+
}
47+
},
48+
webpack: {
49+
build: {
50+
entry: files.ng1CommonJsEntrypoint,
51+
output: {
52+
path: '<%= builddir %>',
53+
filename: '<%= pkg.name %>.js',
54+
library: 'ui.router',
55+
libraryTarget: 'umd'
56+
},
57+
module: {
58+
loaders: []
59+
},
60+
externals: [
61+
{
62+
angular: {
63+
root: 'angular',
64+
commonjs2: 'angular',
65+
commonjs: 'angular'
66+
}
67+
}
68+
]
69+
},
70+
core: {
71+
entry: files.justjsCommonJsEntrypoint,
72+
output: {
73+
path: '<%= builddir %>',
74+
filename: 'ui-router-justjs.js',
75+
library: 'uiRouter',
76+
libraryTarget: 'umd'
77+
},
78+
module: {
79+
loaders: []
4380
}
4481
}
4582
},
@@ -48,15 +85,9 @@ module.exports = function (grunt) {
4885
src: '<%= builddir %>',
4986
dest: 'release'
5087
},
51-
jshint: {
52-
all: ['Gruntfile.js', 'src/*.js', '<%= builddir %>/<%= pkg.name %>.js'],
53-
options: {
54-
eqnull: true
55-
}
56-
},
5788
watch: {
58-
files: ['src/*.js', 'test/**/*.js'],
59-
tasks: ['build', 'karma:background:run']
89+
files: ['src/**/*.ts', 'src/**/*.js', 'test/**/*.js'],
90+
tasks: ['ts:es5', 'webpack', 'karma:ng14']
6091
},
6192
connect: {
6293
server: {},
@@ -69,35 +100,41 @@ module.exports = function (grunt) {
69100
},
70101
karma: {
71102
options: {
72-
configFile: 'config/karma-1.4.9.js',
73-
singleRun: true,
74-
exclude: [],
75-
frameworks: ['jasmine'],
76-
reporters: 'dots', // 'dots' || 'progress'
77-
port: 8080,
78-
colors: true,
79-
autoWatch: false,
80-
autoWatchInterval: 0,
103+
configFile: 'config/karma.js',
104+
// Serve and load angular files using regular Karma mode
81105
browsers: [ grunt.option('browser') || 'PhantomJS' ]
82106
},
107+
// Same as karma:base
83108
unit: {
84-
browsers: [ grunt.option('browser') || 'PhantomJS' ]
85109
},
110+
// Launch Karma in Chrome, click debug button, debug tests
86111
debug: {
87112
singleRun: false,
88113
background: false,
114+
autoWatch: true,
115+
autoWatchInterval: 1,
89116
browsers: [ grunt.option('browser') || 'Chrome' ]
90117
},
91-
ng108: { configFile: 'config/karma-1.0.8.js' },
92-
ng115: { configFile: 'config/karma-1.1.5.js' },
93-
ng1214: { configFile: 'config/karma-1.2.14.js' },
94-
ng130: { configFile: 'config/karma-1.3.0.js' },
95-
ng149: { configFile: 'config/karma-1.4.9.js' },
96-
ng150: { configFile: 'config/karma-1.5.0.js' },
118+
// Test with angular 1.2
119+
ng12: {
120+
options: { files: files.karmaServedFiles('1.2.28') }
121+
},
122+
// Test with angular 1.3
123+
ng13: {
124+
options: { files: files.karmaServedFiles('1.3.16') }
125+
},
126+
// Test with angular 1.4
127+
ng14: {
128+
options: { files: files.karmaServedFiles('1.4.9') }
129+
},
130+
// Test with angular 1.5
131+
ng15: {
132+
options: { files: files.karmaServedFiles('1.5.0') }
133+
},
97134
background: {
98-
background: true,
99-
browsers: [ grunt.option('browser') || 'PhantomJS' ]
135+
background: true
100136
},
137+
// PhantomJS in the console; watch for changes to tests/src
101138
watch: {
102139
singleRun: false,
103140
autoWatch: true,
@@ -125,25 +162,29 @@ module.exports = function (grunt) {
125162
}
126163
});
127164

128-
grunt.registerTask('integrate', ['build', 'jshint', 'karma:ng108', 'karma:ng115', 'karma:ng1214', 'karma:ng130', 'karma:ng149', 'karma:ng150']);
129-
grunt.registerTask('default', ['build', 'jshint', 'karma:unit']);
130-
grunt.registerTask('build', 'Perform a normal build', ['concat', 'uglify']);
131-
grunt.registerTask('dist', 'Perform a clean build', ['clean', 'build']);
132-
grunt.registerTask('dist-docs', 'Perform a clean build and generate documentation', ['dist', 'ngdocs', 'widedocs']);
133-
grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'dist', 'perform-release']);
165+
grunt.registerTask('integrate', ['clean', 'build', 'karma:ng12', 'karma:ng13', 'karma:ng14', 'karma:ng15']);
166+
grunt.registerTask('default', ['build', 'karma:unit', 'docs']);
167+
grunt.registerTask('build', 'Perform a normal build', ['clean', 'ts', 'webpack', 'bundles', 'uglify']);
168+
grunt.registerTask('dist-docs', 'Perform a clean build and generate documentation', ['build', 'ngdocs']);
169+
grunt.registerTask('release', 'Tag and perform a release', ['prepare-release', 'build', 'perform-release']);
134170
grunt.registerTask('dev', 'Run dev server and watch for changes', ['build', 'connect:server', 'karma:background', 'watch']);
135171
grunt.registerTask('sample', 'Run connect server with keepalive:true for sample app development', ['connect:sample']);
136172

137-
grunt.registerTask('widedocs', 'Convert to bootstrap container-fluid', function () {
138-
promising(this,
139-
system(
140-
'sed -i.bak ' +
141-
'-e \'s/class="row"/class="row-fluid"/\' ' +
142-
'-e \'s/icon-cog"><\\/i>/icon-cog"><\\/i>Provider/\' ' +
143-
'-e \'s/role="main" class="container"/role="main" class="container-fluid"/\' site/index.html')
173+
grunt.registerTask('docs', 'Generate documentation to _doc', function() {
174+
promising(this,
175+
system('./node_modules/typedoc/bin/typedoc --readme ./README.md --name "UI-Router" --theme ./typedoctheme --mode modules --module commonjs --target es5 --out _doc src/params src/path src/resolve src/state src/transition src/url src/view src/ng1')
144176
);
145177
});
146178

179+
grunt.registerTask('bundles', 'Create the bundles and reorganize any additional dist files (addons, etc)', function() {
180+
var builddir = grunt.config('builddir');
181+
grunt.task.requires([ 'clean', 'ts' ]);
182+
grunt.task.run(['webpack']);
183+
184+
['stateEvents.js', 'stateEvents.js.map'].forEach(function(file) {
185+
grunt.file.copy(builddir + "/es5/ng1/" + file, builddir + "/ng1/" + file);
186+
})
187+
});
147188

148189
grunt.registerTask('publish-pages', 'Publish a clean build, docs, and sample to github.io', function () {
149190
promising(this,
@@ -194,9 +235,10 @@ module.exports = function (grunt) {
194235
});
195236

196237
grunt.registerTask('perform-release', function () {
197-
grunt.task.requires([ 'prepare-release', 'dist' ]);
198-
199238
var version = grunt.config('pkg.version'), releasedir = grunt.config('builddir');
239+
grunt.task.requires([ 'prepare-release', 'build' ]);
240+
grunt.file.delete(releasedir + "/es5");
241+
grunt.file.delete(releasedir + "/es6");
200242
promising(this,
201243
system('git add \'' + releasedir + '\'').then(function () {
202244
return system('git commit -m \'release ' + version + '\'');

README.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,100 @@
1+
# feature-1.0 branch
2+
## Note: this is an alpha version of UI-Router 1.0
3+
4+
We've totally redesigned UI-Router under the covers (rewrote about 60% of the codebase!), separating concerns and detangling the spaghetti. We have taken some new approaches which we hope will provide unprecedented flexibility and control to your UI-Router app.
5+
6+
We're working on a new [sample app](http://ui-router.github.io/sample-app/#/mymessages/inbox/5648b50cc586cac4aed6836f) ([Source](https://github.com/ui-router/sample-app)), as well as a [state and transition visualizer](https://github.com/ui-router/visualizer). Check them out, and give us some feedback.
7+
8+
9+
#### What's changed?
10+
11+
##### Resolves
12+
The Resolve API has been rewritten from scratch. We've introduced the concept of a resolve policy, which can be one of:
13+
14+
* EAGER: All eager resolves for a transition are resolved at the beginning, before any states are entered (this is way UI-Router 0.2.x handles resolves)
15+
* LAZY: Lazy resolves are resolved when the state they are declared on is entered.
16+
* JIT: Just-In-Time resolves do not resolve until just before they are injected into some other function. (extremely lazy)
17+
18+
In 1.0, by default, resolves on your states are "JIT"
19+
20+
##### Transition
21+
22+
We've created a Transition Service to manage transitioning from one state to another. The transition service provides hooks, which you can register a callback on. The transition hooks allow you to run code at various stages of a transition, altering it as your app requires.
23+
24+
The transition lifecycle hooks are currently:
25+
26+
* onBefore
27+
* onStart/onInvalid
28+
* onEnter (for individual states)
29+
* onSuccess
30+
* onError
31+
32+
When registering a hook, you can provide criteria (a state name, a glob, or a function), and you can modify the transition by returning something from the hook (an abort, a redirect, a promise, or some new resolves to add to the transition).
33+
34+
This enables lots of fun stuff! Here are a couple of possibilities to get your imagination started:
35+
```javascript
36+
// Perform some async thing before running the transition
37+
$transitionsProvider.onBefore({ to: 'my.state', from: '*' }, function(AsyncService) {
38+
return AsyncService.doSomeAsyncThing();
39+
});
40+
41+
// Add resolves to a transitoin on-the-fly
42+
$transitionsProvider.onBefore({ to: 'other.state', from: '*' }, function($transition$, AsyncService) {
43+
// someAsyncResult added as resolve to transition. It is injectable into other resolves or controllers.
44+
$transition$.addResolves({ someAsyncResult: AsyncService.doSomeAsyncThing });
45+
});
46+
47+
// Declaratively protect states which require authentication; redirect to 'login' if the user is unauthenticated.
48+
$transitionsProvider.onStart({ to: function(state) { return state.requiresAuth; } }, function($transition$, $state, AuthService) {
49+
return AuthService.ensureAuthenticated().catch(function() { return $state.target("login"); });
50+
});
51+
52+
// Declaratively set up default substates or other redirects; Redirect to a different target state
53+
// as declared on the original state, i.e., redirectTo: 'someotherstate'
54+
$transitionsProvider.onStart({ to: function(state) { return state.redirectTo; } }, function($transition$, $state) {
55+
return $state.target($transition$.to.redirectTo); });
56+
});
57+
```
58+
59+
##### State
60+
61+
The $state service has been heavily refactored, and is now the primary client of the $transition service. This doesn't offer the end user much *now*, but this separation should eventually enable us to provide things like multiple simultanesouly active states and parallel transitions (think UI-Router Extras "Sticky States").
62+
63+
State events will soon be deprecated, but can be easily re-enabled by including the stateEvents.js file. The state events have all been refactored as callbacks to the transition hooks.
64+
65+
##### Views
66+
67+
The way UI-Router manages views has been heavily refactored into a view service. This should allow us to plug in alternate rendering schemes (react?), and should help ease the transition to angular 2.
68+
69+
##### Parameters
70+
71+
This one has been a long time coming. Finally, UI-Router supports dynamic parameters in both the URL path and query string. We've included a decorator which enables reloadOnSearch behavior using dynamic params automatically.
72+
73+
### What's next?
74+
75+
We're not done making sure every use case that you've been using in UI-Router 0.2.x works just as well in 1.0. In fact, we just got the new code routing again on June 25 and have no idea what gaps are out there. We'd like to get some other eyes on this new codebase. We've moved in most of the unit tests from 0.2.x, but there are certain to be some things missing.
76+
77+
Build it. Try it. Let us know what's horribly broken.
78+
79+
#### ES6/TypeScript
80+
81+
We have migrated our codebase to ES6 and Typescript.
82+
83+
#### Angular 2
84+
85+
We'd are going to support Angular 2. We plan to release a ui-router-ng2 around the same time ng2 final is released.
86+
87+
#### Lazy Loading
88+
89+
We'd like to have out-of-the-box support for lazy loading states (like UI-Router Extras "Future States")
90+
91+
---------------------------------------------
92+
93+
94+
The rest of this README is from an old release.
95+
96+
97+
198
# AngularUI Router &nbsp;[![Build Status](https://travis-ci.org/angular-ui/ui-router.svg?branch=master)](https://travis-ci.org/angular-ui/ui-router)
299

3100
#### The de-facto solution to flexible routing with nested views

bower.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "angular-ui-router",
3-
"version": "0.2.18",
3+
"version": "1.0.0alpha0",
44
"license" : "MIT",
55
"main": "./release/angular-ui-router.js",
66
"dependencies": {
7-
"angular": "^1.0.8"
7+
"angular": ">= 1.3.0"
88
},
99
"ignore": [
1010
"**/.*",

component.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-router",
3-
"version": "0.2.18",
3+
"version": "1.0.0alpha0",
44
"description": "State-based routing for AngularJS",
55
"keywords": [
66
"angular",

0 commit comments

Comments
 (0)