Skip to content

Commit 9fef214

Browse files
feat(*): switch to UMD bundle (from SystemJS)
chore(*): Added types chore(*): Update to angular2 rc.4
1 parent e4e035d commit 9fef214

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<a name="1.0.7"></a>
2-
# 1.0.7 (2016-06-30)
2+
# 1.0.7 (2016-07-09)
33

4-
update for ng2 rc.3 and ui-router 1.0.0-beta.1
4+
update for ng2 rc.4 and ui-router 1.0.0-beta.1
55

66
<a name="1.0.6"></a>
77
# 1.0.6 (2016-05-12)

ng1-to-ng2.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import * as angular from "angular";
22
import {provide, ElementRef, Component, Inject, ComponentMetadata} from "@angular/core";
33
import {UpgradeAdapter} from "@angular/upgrade";
4+
5+
import { Ng1ViewConfig, StateProvider, State } from "angular-ui-router";
6+
47
import {
5-
UIView, UIRouter, TransitionService, StateService, Globals, UIROUTER_DIRECTIVES, forEach, extend,
6-
UrlRouter, ViewService, StateRegistry, UrlMatcherFactory, Ng2ViewDeclaration, Ng2ViewConfig, PathNode
8+
UIView, UIRouter, TransitionService, StateService, Globals, UIROUTER_DIRECTIVES, forEach,
9+
UrlRouter, ViewService, StateRegistry, UrlMatcherFactory, Ng2ViewDeclaration, Ng2ViewConfig, PathNode,
10+
ParentUIViewInject, ViewConfig
711
} from "ui-router-ng2";
8-
import {Ng1ViewConfig} from "angular-ui-router";
912

1013
export let upgradeModule = angular.module('ui.router.upgrade', ['ui.router']);
1114

15+
declare var Reflect: any;
16+
1217
@Component({
1318
selector: 'ui-view-ng-upgrade',
1419
template: `<ui-view></ui-view>`,
@@ -22,7 +27,7 @@ export let upgradeModule = angular.module('ui.router.upgrade', ['ui.router']);
2227
* up the DOM and grabbing the .data('$uiView') that the ng1 ui-view directive provided.
2328
*/
2429
class UIViewNgUpgrade {
25-
constructor(ref: ElementRef, @Inject(UIView.PARENT_INJECT) parent, registry: StateRegistry) {
30+
constructor(ref: ElementRef, @Inject(UIView.PARENT_INJECT) parent: ParentUIViewInject, registry: StateRegistry) {
2631
// From the ui-view-ng-upgrade component's element ref, walk up the DOM two elements...
2732
// There will first be one ng1 ui-view which hosts this element, and then that ui-view's
2833
// parent element. This element has access to the proper "parent viewcontext"
@@ -73,14 +78,14 @@ export let uiRouterNgUpgrade = {
7378
/**
7479
* Predicate that returns true if an object is a NG2 Component Class
7580
*/
76-
export function isNg2ComponentClass(def) {
81+
export function isNg2ComponentClass(def: any) {
7782
if (typeof def !== 'function') return false;
7883

7984
if (!Reflect || typeof Reflect['metadata'] !== 'function')
8085
throw new Error("Missing runtime dependency: 'reflect-metadata'");
8186

8287
return Reflect['getMetadata']('annotations', def)
83-
.find(x => x instanceof ComponentMetadata);
88+
.find((x: any) => x instanceof ComponentMetadata);
8489
}
8590

8691
/**
@@ -90,11 +95,11 @@ export function isNg2ComponentClass(def) {
9095
* In place of the template provider, it simply puts a <ui-view-ng-upgrade/> component, which is the
9196
* downgraded Ng2 Component that provides a ng1-to-ng2 boundary in the DOM.
9297
*/
93-
upgradeModule.config([ '$stateProvider', $stateProvider => {
94-
$stateProvider.decorator('views', function(state /*: Ng1StateDeclaration */, parentFn: Function) {
98+
upgradeModule.config([ '$stateProvider', ($stateProvider: StateProvider) => {
99+
$stateProvider.decorator('views', function(state: State, parentFn: Function) {
95100
let views = parentFn(state);
96101

97-
forEach(views, (viewDecl /*: Ng1ViewDeclaration */, viewName: string) => {
102+
forEach(views, (viewDecl: any, viewName: string) => {
98103
if (isNg2ComponentClass(viewDecl.component)) {
99104
// Update the view config.
100105
// Override default ng1 `component:` behavior (of defining a templateProvider)
@@ -108,12 +113,12 @@ upgradeModule.config([ '$stateProvider', $stateProvider => {
108113
})
109114
}]);
110115

111-
upgradeModule.run([ '$view', $view => {
116+
upgradeModule.run([ '$view', ($view: ViewService) => {
112117
$view.viewConfigFactory('ng2', (path: PathNode[], config: Ng2ViewDeclaration) => new Ng2ViewConfig(path, config));
113118

114-
$view.viewConfigFactory('ng1-to-ng2', (node: PathNode, config: Ng2ViewDeclaration) => {
115-
var ng1ViewConfig = new Ng1ViewConfig(<any> node, <any> Object.assign({}, config, { $type: 'ng1'}));
116-
var ng2ViewConfig = new Ng2ViewConfig(<any> node, <any> Object.assign({}, config, { $type: 'ng2'}));
119+
$view.viewConfigFactory('ng1-to-ng2', (path: PathNode[], config: Ng2ViewDeclaration) => {
120+
var ng1ViewConfig: ViewConfig = <any> new Ng1ViewConfig(<any> path, <any> Object.assign({}, config, { $type: 'ng1'}));
121+
var ng2ViewConfig: ViewConfig = <any> new Ng2ViewConfig(<any> path, <any> Object.assign({}, config, { $type: 'ng2'}));
117122

118123
return [ ng2ViewConfig, ng1ViewConfig ];
119124
});

package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,25 @@
1010
"license": "MIT",
1111
"peerDependencies": {
1212
"angular": "^1.5.0",
13-
"@angular/core": "^2.0.0-rc.3",
14-
"@angular/upgrade": "^2.0.0-rc.3",
13+
"@angular/core": "^2.0.0-rc.4",
14+
"@angular/upgrade": "^2.0.0-rc.4",
15+
"rxjs": "=5.0.0-beta.6",
1516
"angular-ui-router": "^1.0.0-beta.1",
1617
"ui-router-ng2": "^1.0.0-beta.1"
1718
},
1819
"devDependencies": {
19-
"@angular/common": "^2.0.0-rc.3",
20-
"@angular/compiler": ">=2.0.0-rc.3",
21-
"@angular/core": ">=2.0.0-rc.3",
22-
"@angular/platform-browser": ">=2.0.0-rc.3",
23-
"@angular/upgrade": ">=2.0.0-rc.3",
20+
"@angular/common": "^2.0.0-rc.4",
21+
"@angular/compiler": ">=2.0.0-rc.4",
22+
"@angular/core": ">=2.0.0-rc.4",
23+
"@angular/platform-browser": ">=2.0.0-rc.4",
24+
"@angular/upgrade": ">=2.0.0-rc.4",
2425
"angular": "1.5.3",
2526
"angular-ui-router": ">=1.0.0-beta.1",
2627
"concurrently": "^2.0.0",
2728
"es6-shim": "^0.35.0",
2829
"lite-server": "^2.1.0",
2930
"reflect-metadata": "0.1.2",
30-
"rxjs": "^5.0.0-beta.6",
31+
"rxjs": "=5.0.0-beta.6",
3132
"systemjs": "0.19.25",
3233
"typescript": "^1.8.9",
3334
"typings": "^0.7.11",

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"module": "system",
4+
"module": "umd",
55
"moduleResolution": "node",
66
"sourceMap": true,
77
"declaration": true,

0 commit comments

Comments
 (0)