From 9fef214b2c2f708e7cb205df1a09aca02e95d016 Mon Sep 17 00:00:00 2001 From: christopherthielen Date: Sat, 9 Jul 2016 17:55:18 -0500 Subject: [PATCH] feat(*): switch to UMD bundle (from SystemJS) chore(*): Added types chore(*): Update to angular2 rc.4 --- CHANGELOG.md | 4 ++-- ng1-to-ng2.ts | 31 ++++++++++++++++++------------- package.json | 17 +++++++++-------- tsconfig.json | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 168650e7..cc3c8d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ -# 1.0.7 (2016-06-30) +# 1.0.7 (2016-07-09) -update for ng2 rc.3 and ui-router 1.0.0-beta.1 +update for ng2 rc.4 and ui-router 1.0.0-beta.1 # 1.0.6 (2016-05-12) diff --git a/ng1-to-ng2.ts b/ng1-to-ng2.ts index 9816d0b1..f10c63ee 100644 --- a/ng1-to-ng2.ts +++ b/ng1-to-ng2.ts @@ -1,14 +1,19 @@ import * as angular from "angular"; import {provide, ElementRef, Component, Inject, ComponentMetadata} from "@angular/core"; import {UpgradeAdapter} from "@angular/upgrade"; + +import { Ng1ViewConfig, StateProvider, State } from "angular-ui-router"; + import { - UIView, UIRouter, TransitionService, StateService, Globals, UIROUTER_DIRECTIVES, forEach, extend, - UrlRouter, ViewService, StateRegistry, UrlMatcherFactory, Ng2ViewDeclaration, Ng2ViewConfig, PathNode + UIView, UIRouter, TransitionService, StateService, Globals, UIROUTER_DIRECTIVES, forEach, + UrlRouter, ViewService, StateRegistry, UrlMatcherFactory, Ng2ViewDeclaration, Ng2ViewConfig, PathNode, + ParentUIViewInject, ViewConfig } from "ui-router-ng2"; -import {Ng1ViewConfig} from "angular-ui-router"; export let upgradeModule = angular.module('ui.router.upgrade', ['ui.router']); +declare var Reflect: any; + @Component({ selector: 'ui-view-ng-upgrade', template: ``, @@ -22,7 +27,7 @@ export let upgradeModule = angular.module('ui.router.upgrade', ['ui.router']); * up the DOM and grabbing the .data('$uiView') that the ng1 ui-view directive provided. */ class UIViewNgUpgrade { - constructor(ref: ElementRef, @Inject(UIView.PARENT_INJECT) parent, registry: StateRegistry) { + constructor(ref: ElementRef, @Inject(UIView.PARENT_INJECT) parent: ParentUIViewInject, registry: StateRegistry) { // From the ui-view-ng-upgrade component's element ref, walk up the DOM two elements... // There will first be one ng1 ui-view which hosts this element, and then that ui-view's // parent element. This element has access to the proper "parent viewcontext" @@ -73,14 +78,14 @@ export let uiRouterNgUpgrade = { /** * Predicate that returns true if an object is a NG2 Component Class */ -export function isNg2ComponentClass(def) { +export function isNg2ComponentClass(def: any) { if (typeof def !== 'function') return false; if (!Reflect || typeof Reflect['metadata'] !== 'function') throw new Error("Missing runtime dependency: 'reflect-metadata'"); return Reflect['getMetadata']('annotations', def) - .find(x => x instanceof ComponentMetadata); + .find((x: any) => x instanceof ComponentMetadata); } /** @@ -90,11 +95,11 @@ export function isNg2ComponentClass(def) { * In place of the template provider, it simply puts a component, which is the * downgraded Ng2 Component that provides a ng1-to-ng2 boundary in the DOM. */ -upgradeModule.config([ '$stateProvider', $stateProvider => { - $stateProvider.decorator('views', function(state /*: Ng1StateDeclaration */, parentFn: Function) { +upgradeModule.config([ '$stateProvider', ($stateProvider: StateProvider) => { + $stateProvider.decorator('views', function(state: State, parentFn: Function) { let views = parentFn(state); - forEach(views, (viewDecl /*: Ng1ViewDeclaration */, viewName: string) => { + forEach(views, (viewDecl: any, viewName: string) => { if (isNg2ComponentClass(viewDecl.component)) { // Update the view config. // Override default ng1 `component:` behavior (of defining a templateProvider) @@ -108,12 +113,12 @@ upgradeModule.config([ '$stateProvider', $stateProvider => { }) }]); -upgradeModule.run([ '$view', $view => { +upgradeModule.run([ '$view', ($view: ViewService) => { $view.viewConfigFactory('ng2', (path: PathNode[], config: Ng2ViewDeclaration) => new Ng2ViewConfig(path, config)); - $view.viewConfigFactory('ng1-to-ng2', (node: PathNode, config: Ng2ViewDeclaration) => { - var ng1ViewConfig = new Ng1ViewConfig( node, Object.assign({}, config, { $type: 'ng1'})); - var ng2ViewConfig = new Ng2ViewConfig( node, Object.assign({}, config, { $type: 'ng2'})); + $view.viewConfigFactory('ng1-to-ng2', (path: PathNode[], config: Ng2ViewDeclaration) => { + var ng1ViewConfig: ViewConfig = new Ng1ViewConfig( path, Object.assign({}, config, { $type: 'ng1'})); + var ng2ViewConfig: ViewConfig = new Ng2ViewConfig( path, Object.assign({}, config, { $type: 'ng2'})); return [ ng2ViewConfig, ng1ViewConfig ]; }); diff --git a/package.json b/package.json index 032cb68c..e6fa2990 100644 --- a/package.json +++ b/package.json @@ -10,24 +10,25 @@ "license": "MIT", "peerDependencies": { "angular": "^1.5.0", - "@angular/core": "^2.0.0-rc.3", - "@angular/upgrade": "^2.0.0-rc.3", + "@angular/core": "^2.0.0-rc.4", + "@angular/upgrade": "^2.0.0-rc.4", + "rxjs": "=5.0.0-beta.6", "angular-ui-router": "^1.0.0-beta.1", "ui-router-ng2": "^1.0.0-beta.1" }, "devDependencies": { - "@angular/common": "^2.0.0-rc.3", - "@angular/compiler": ">=2.0.0-rc.3", - "@angular/core": ">=2.0.0-rc.3", - "@angular/platform-browser": ">=2.0.0-rc.3", - "@angular/upgrade": ">=2.0.0-rc.3", + "@angular/common": "^2.0.0-rc.4", + "@angular/compiler": ">=2.0.0-rc.4", + "@angular/core": ">=2.0.0-rc.4", + "@angular/platform-browser": ">=2.0.0-rc.4", + "@angular/upgrade": ">=2.0.0-rc.4", "angular": "1.5.3", "angular-ui-router": ">=1.0.0-beta.1", "concurrently": "^2.0.0", "es6-shim": "^0.35.0", "lite-server": "^2.1.0", "reflect-metadata": "0.1.2", - "rxjs": "^5.0.0-beta.6", + "rxjs": "=5.0.0-beta.6", "systemjs": "0.19.25", "typescript": "^1.8.9", "typings": "^0.7.11", diff --git a/tsconfig.json b/tsconfig.json index 1f0c0046..46beda63 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es5", - "module": "system", + "module": "umd", "moduleResolution": "node", "sourceMap": true, "declaration": true,