diff --git a/gulp/bundle.js b/gulp/bundle.js index e249083a3..837af4e9c 100644 --- a/gulp/bundle.js +++ b/gulp/bundle.js @@ -9,9 +9,17 @@ const bundleConfig = { defaultJSExtensions: true, paths: { 'angular2-google-maps/*': '*', - 'angular2/*': './node_modules/angular2/*', + '@angular/*': './node_modules/@angular/*', 'rxjs/*': './node_modules/rxjs/*', }, + packages: { + '@angular/core': { main: 'index.js', defaultExtension: 'js' }, + '@angular/common': { main: 'index.js', defaultExtension: 'js' }, + '@angular/compiler': { main: 'index.js', defaultExtension: 'js' }, + }, + map: { + '@angular': '@angular', + }, }; function bundle(moduleName, moduleBundleName, minify, done) { @@ -23,7 +31,7 @@ function bundle(moduleName, moduleBundleName, minify, done) { builder.config(bundleConfig); const outputFile = path.join(config.PATHS.dist.bundles, moduleBundleName + (minify ? '.min' : '') + '.js'); // todo: newest systemjs-builder version requires to explicitly exclude .d.ts files - probably a systemjs-builder bug. - const bundlePromise = builder.bundle(moduleName + ' - angular2/*.ts - angular2/*.js - rxjs/*.ts - rxjs/*.js', outputFile, outputConfig); + const bundlePromise = builder.bundle(moduleName + ' - @angular/core/*.ts - @angular/core/*.js - rxjs/*.ts - rxjs/*.js', outputFile, outputConfig); if (!minify) { bundlePromise.then(() => { diff --git a/karma-systemjs-config.js b/karma-systemjs-config.js new file mode 100644 index 000000000..c5dbc0a4d --- /dev/null +++ b/karma-systemjs-config.js @@ -0,0 +1,27 @@ +(function (global) { + var map = { + 'rxjs': 'base/node_modules/rxjs', + '@angular': 'base/node_modules/@angular' + }; + var packages = { + 'rxjs': { defaultExtension: 'js' }, + }; + var packageNames = [ + '@angular/common', + '@angular/compiler', + '@angular/core', + '@angular/platform-browser', + '@angular/platform-browser-dynamic' + ]; + packageNames.forEach(function (pkgName) { + packages[pkgName] = { main: 'index.js', defaultExtension: 'js' }; + }); + var config = { + map: map, + packages: packages + }; + if (global.filterSystemConfig) { + global.filterSystemConfig(config); + } + System.config(config); +})(this); diff --git a/karma-test-shim.js b/karma-test-shim.js index 029b21ed9..808724fde 100644 --- a/karma-test-shim.js +++ b/karma-test-shim.js @@ -18,8 +18,18 @@ System.config({ } }); -System.import('angular2/platform/browser').then(function(browser) { - browser.BrowserDomAdapter.makeCurrent(); +//loading systemjs for angular to use in tests +System.import('base/karma-systemjs-config.js').then(function() { + return Promise.all([ + System.import('@angular/core/testing'), + System.import('@angular/platform-browser-dynamic/testing') + ]).then(function (providers) { + var testing = providers[0]; + var testingBrowser = providers[1]; + + testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS, + testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS); + }); }).then(function() { return Promise.all( Object.keys(window.__karma__.files) // All files served by Karma. diff --git a/karma.conf.js b/karma.conf.js index 23c236df1..a3d72adaf 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -14,14 +14,22 @@ module.exports = function(config) { }, files: [ {pattern: 'node_modules/es6-shim/es6-shim.js', included: true, watched: true}, - {pattern: 'node_modules/angular2/bundles/angular2-polyfills.js', included: true, watched: true}, + {pattern: 'node_modules/zone.js/dist/zone.js', included: true, watched: true}, + //Needed for async testsing {https://github.com/angular/angular/issues/8232} + {pattern: 'node_modules/zone.js/dist/async-test.js', included: true, watched: true}, + {pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: true}, + {pattern: 'node_modules/systemjs/dist/system-polyfills.js', included: true, watched: false }, {pattern: 'node_modules/systemjs/dist/system.src.js', included: true, watched: true}, - {pattern: 'node_modules/rxjs/bundles/Rx.js', included: true, watched: true}, - {pattern: 'node_modules/angular2/bundles/angular2.js', included: true, watched: true}, - {pattern: 'node_modules/angular2/bundles/http.dev.js', included: true, watched: true}, - {pattern: 'node_modules/angular2/bundles/router.dev.js', included: true, watched: true}, - {pattern: 'node_modules/angular2/bundles/testing.dev.js', included: true, watched: true}, - + + {pattern: 'karma-systemjs-config.js', included: true, watched: true}, + + {pattern: 'node_modules/rxjs/**/*', included: false, watched: false}, + {pattern: 'node_modules/@angular/common/**/*', included: false, watched: false}, + {pattern: 'node_modules/@angular/core/**/*', included: false, watched: false}, + {pattern: 'node_modules/@angular/platform-browser/**/*', included: false, watched: false}, + {pattern: 'node_modules/@angular/compiler/**/*', included: false, watched: false}, + {pattern: 'node_modules/@angular/platform-browser-dynamic/**/*', included: false, watched: false}, + {pattern: 'karma-test-shim.js', included: true, watched: true}, // paths loaded via module imports @@ -45,7 +53,6 @@ module.exports = function(config) { '/base/src/': '/base/dist/', '/base/test-built/src': '/base/dist' }, - reporters: ['progress'], port: 9876, colors: true, diff --git a/package.json b/package.json index e8efad4b9..8095308e3 100644 --- a/package.json +++ b/package.json @@ -22,12 +22,16 @@ }, "homepage": "https://github.com/SebastianM/angular2-google-maps#readme", "dependencies": { - "angular2": "^2.0.0-beta.11", - "es6-promise": "^3.0.2", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "es6-promise": "^3.1.2", "es6-shim": "^0.35.0", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", - "zone.js": "^0.6.4" + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "^0.6.12" }, "devDependencies": { "babel-eslint": "4.1.8", @@ -56,21 +60,26 @@ "replace": "0.3.0", "require-dir": "0.3.0", "run-sequence": "1.1.5", - "systemjs": "0.19.23", - "systemjs-builder": "0.15.13", + "systemjs": "0.19.27", + "systemjs-builder": "0.15.16", "tslint": "3.6.0", "typescript": "1.8.9", - "typings": "0.7.7" + "typings": "0.7.7", + "watchify": "^3.7.0" }, "jspm": { "jspmNodeConversion": false, "dependencies": { - "angular2": "^2.0.0-beta.11", - "es6-promise": "^3.0.2", + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "es6-promise": "^3.1.2", "es6-shim": "^0.35.0", - "reflect-metadata": "0.1.2", - "rxjs": "5.0.0-beta.2", - "zone.js": "^0.6.4" + "reflect-metadata": "0.1.3", + "rxjs": "5.0.0-beta.6", + "zone.js": "^0.6.12" } } } diff --git a/src/core.ts b/src/core.ts index 6252ed739..5a4be2fbc 100644 --- a/src/core.ts +++ b/src/core.ts @@ -1,4 +1,4 @@ -import {Provider} from 'angular2/core'; +import {Provider} from '@angular/core'; import {MapsAPILoader} from './services/maps-api-loader/maps-api-loader'; import {LazyMapsAPILoader} from './services/maps-api-loader/lazy-maps-api-loader'; diff --git a/src/directives/google-map-info-window.ts b/src/directives/google-map-info-window.ts index e32171b07..f1a6159ce 100644 --- a/src/directives/google-map-info-window.ts +++ b/src/directives/google-map-info-window.ts @@ -1,4 +1,4 @@ -import {Component, SimpleChange, OnDestroy, OnChanges, ElementRef} from 'angular2/core'; +import {Component, SimpleChange, OnDestroy, OnChanges, ElementRef} from '@angular/core'; import {InfoWindowManager} from '../services/info-window-manager'; import {SebmGoogleMapMarker} from './google-map-marker'; @@ -36,8 +36,7 @@ let infoWindowId = 0; @Component({ selector: 'sebm-google-map-info-window', inputs: ['latitude', 'longitude', 'disableAutoPan'], - template: ` -
+ template: `
` diff --git a/src/directives/google-map-marker.ts b/src/directives/google-map-marker.ts index 2214ed72b..4bb342f47 100644 --- a/src/directives/google-map-marker.ts +++ b/src/directives/google-map-marker.ts @@ -1,12 +1,4 @@ -import { - Directive, - SimpleChange, - OnDestroy, - OnChanges, - EventEmitter, - ContentChild, - AfterContentInit -} from 'angular2/core'; +import {Directive, SimpleChange, OnDestroy, OnChanges, EventEmitter, ContentChild, AfterContentInit} from '@angular/core'; import {MarkerManager} from '../services/marker-manager'; import {SebmGoogleMapInfoWindow} from './google-map-info-window'; import {MouseEvent} from '../events'; diff --git a/src/directives/google-map.ts b/src/directives/google-map.ts index 10309cfd8..cd37643a0 100644 --- a/src/directives/google-map.ts +++ b/src/directives/google-map.ts @@ -1,4 +1,4 @@ -import {Component, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChange} from 'angular2/core'; +import {Component, ElementRef, EventEmitter, OnChanges, OnInit, SimpleChange} from '@angular/core'; import {GoogleMapsAPIWrapper} from '../services/google-maps-api-wrapper'; import {MarkerManager} from '../services/marker-manager'; import {InfoWindowManager} from '../services/info-window-manager'; @@ -194,7 +194,7 @@ export class SebmGoogleMap implements OnChanges, /** * Sets the zoom level of the map. The default value is `8`. */ - set zoom(value: number | string) { + set zoom(value: number|string) { this._zoom = this._convertToDecimal(value, 8); if (typeof this._zoom === 'number') { this._mapsWrapper.setZoom(this._zoom); @@ -204,7 +204,7 @@ export class SebmGoogleMap implements OnChanges, /** * The longitude that sets the center of the map. */ - set longitude(value: number | string) { + set longitude(value: number|string) { this._longitude = this._convertToDecimal(value); this._updateCenter(); } @@ -212,12 +212,12 @@ export class SebmGoogleMap implements OnChanges, /** * The latitude that sets the center of the map. */ - set latitude(value: number | string) { + set latitude(value: number|string) { this._latitude = this._convertToDecimal(value); this._updateCenter(); } - private _convertToDecimal(value: string | number, defaultValue: number = null): number { + private _convertToDecimal(value: string|number, defaultValue: number = null): number { if (typeof value === 'string') { return parseFloat(value); } else if (typeof value === 'number') { @@ -259,8 +259,8 @@ export class SebmGoogleMap implements OnChanges, type Event = {name: string, emitter: Emitter}; const events: Event[] = [ - {name: 'click', emitter: this.mapClick}, {name: 'rightclick', emitter: this.mapRightClick}, - {name: 'dblclick', emitter: this.mapDblClick} + {name: 'click', emitter: this.mapClick}, + {name: 'rightclick', emitter: this.mapRightClick}, ]; events.forEach((e: Event) => { diff --git a/src/services.ts b/src/services.ts index a117a5ddc..b761a2a51 100644 --- a/src/services.ts +++ b/src/services.ts @@ -3,8 +3,4 @@ export {NoOpMapsAPILoader} from './services/maps-api-loader/noop-maps-api-loader export {GoogleMapsAPIWrapper} from './services/google-maps-api-wrapper'; export {MarkerManager} from './services/marker-manager'; export {InfoWindowManager} from './services/info-window-manager'; -export { - LazyMapsAPILoader, - LazyMapsAPILoaderConfig, - GoogleMapsScriptProtocol -} from './services/maps-api-loader/lazy-maps-api-loader'; +export {LazyMapsAPILoader, LazyMapsAPILoaderConfig, GoogleMapsScriptProtocol} from './services/maps-api-loader/lazy-maps-api-loader'; diff --git a/src/services/google-maps-api-wrapper.ts b/src/services/google-maps-api-wrapper.ts index 6e54b4d6d..03786cb50 100644 --- a/src/services/google-maps-api-wrapper.ts +++ b/src/services/google-maps-api-wrapper.ts @@ -1,4 +1,4 @@ -import {Injectable, NgZone} from 'angular2/core'; +import {Injectable, NgZone} from '@angular/core'; import {Observer} from 'rxjs/Observer'; import {Observable} from 'rxjs/Observable'; diff --git a/src/services/google-maps-types.ts b/src/services/google-maps-types.ts index d7bcc4574..4c468636e 100644 --- a/src/services/google-maps-types.ts +++ b/src/services/google-maps-types.ts @@ -2,11 +2,11 @@ export var google: any; export interface GoogleMap { constructor(el: HTMLElement, opts?: MapOptions): void; - panTo(latLng: LatLng | LatLngLiteral): void; + panTo(latLng: LatLng|LatLngLiteral): void; setZoom(zoom: number): void; addListener(eventName: string, fn: Function): void; getCenter(): LatLng; - setCenter(latLng: LatLng | LatLngLiteral): void; + setCenter(latLng: LatLng|LatLngLiteral): void; getZoom(): number; setOptions(options: MapOptions): void; } @@ -20,9 +20,9 @@ export interface LatLng { export interface Marker { constructor(options?: MarkerOptions): void; setMap(map: GoogleMap): void; - setPosition(latLng: LatLng | LatLngLiteral): void; + setPosition(latLng: LatLng|LatLngLiteral): void; setTitle(title: string): void; - setLabel(label: string | MarkerLabel): void; + setLabel(label: string|MarkerLabel): void; setDraggable(draggable: boolean): void; setIcon(icon: string): void; getLabel(): MarkerLabel; @@ -30,10 +30,10 @@ export interface Marker { } export interface MarkerOptions { - position: LatLng | LatLngLiteral; + position: LatLng|LatLngLiteral; title?: string; map?: GoogleMap; - label?: string | MarkerLabel; + label?: string|MarkerLabel; draggable?: boolean; icon?: string; } @@ -54,7 +54,7 @@ export interface LatLngLiteral { export interface MouseEvent { latLng: LatLng; } export interface MapOptions { - center?: LatLng | LatLngLiteral; + center?: LatLng|LatLngLiteral; zoom?: number; disableDoubleClickZoom?: boolean; disableDefaultUI?: boolean; @@ -68,13 +68,13 @@ export interface MapOptions { export interface InfoWindow { constructor(opts?: InfoWindowOptions): void; close(): void; - getContent(): string | Node; + getContent(): string|Node; getPosition(): LatLng; getZIndex(): number; open(map?: GoogleMap, anchor?: MVCObject): void; - setContent(content: string | Node): void; + setContent(content: string|Node): void; setOptions(options: InfoWindowOptions): void; - setPosition(position: LatLng | LatLngLiteral): void; + setPosition(position: LatLng|LatLngLiteral): void; setZIndex(zIndex: number): void; } @@ -89,10 +89,10 @@ export interface Size { } export interface InfoWindowOptions { - content?: string | Node; + content?: string|Node; disableAutoPan?: boolean; maxWidth?: number; pixelOffset?: Size; - position?: LatLng | LatLngLiteral; + position?: LatLng|LatLngLiteral; zIndex?: number; } diff --git a/src/services/info-window-manager.ts b/src/services/info-window-manager.ts index 3f6438ae8..007b84f60 100644 --- a/src/services/info-window-manager.ts +++ b/src/services/info-window-manager.ts @@ -1,4 +1,4 @@ -import {Injectable, NgZone} from 'angular2/core'; +import {Injectable, NgZone} from '@angular/core'; import {SebmGoogleMapInfoWindow} from '../directives/google-map-info-window'; import {GoogleMapsAPIWrapper} from './google-maps-api-wrapper'; import {MarkerManager} from './marker-manager'; diff --git a/src/services/maps-api-loader/lazy-maps-api-loader.ts b/src/services/maps-api-loader/lazy-maps-api-loader.ts index 209d0af28..dc442102c 100644 --- a/src/services/maps-api-loader/lazy-maps-api-loader.ts +++ b/src/services/maps-api-loader/lazy-maps-api-loader.ts @@ -1,4 +1,4 @@ -import {Injectable, Optional} from 'angular2/core'; +import {Injectable, Optional} from '@angular/core'; import {MapsAPILoader} from './maps-api-loader'; export enum GoogleMapsScriptProtocol { diff --git a/src/services/maps-api-loader/maps-api-loader.ts b/src/services/maps-api-loader/maps-api-loader.ts index bd20afe3d..2b6e55552 100644 --- a/src/services/maps-api-loader/maps-api-loader.ts +++ b/src/services/maps-api-loader/maps-api-loader.ts @@ -1,4 +1,4 @@ -import {Injectable} from 'angular2/core'; +import {Injectable} from '@angular/core'; @Injectable() export abstract class MapsAPILoader { diff --git a/src/services/marker-manager.ts b/src/services/marker-manager.ts index 6a087e3c0..df568d9c7 100644 --- a/src/services/marker-manager.ts +++ b/src/services/marker-manager.ts @@ -1,4 +1,4 @@ -import {Injectable, NgZone} from 'angular2/core'; +import {Injectable, NgZone} from '@angular/core'; import {Observer} from 'rxjs/Observer'; import {Observable} from 'rxjs/Observable'; import {SebmGoogleMapMarker} from '../directives/google-map-marker'; diff --git a/test/services/marker-manager.spec.ts b/test/services/marker-manager.spec.ts index 41ee13454..eea7b3758 100644 --- a/test/services/marker-manager.spec.ts +++ b/test/services/marker-manager.spec.ts @@ -1,5 +1,5 @@ -import {describe, it, expect, beforeEachProviders, inject, injectAsync} from 'angular2/testing'; -import {provide, NgZone} from 'angular2/core'; +import {describe, it, expect, beforeEachProviders, inject, async} from '@angular/core/testing'; +import {provide, NgZone} from '@angular/core'; import {MarkerManager} from '../../src/services/marker-manager'; import {Marker} from '../../src/services/google-maps-types'; @@ -54,7 +54,7 @@ export function main() { describe('set marker icon', () => { it('should update that marker via setIcon method when the markerUrl changes', - injectAsync( + async(inject( [MarkerManager, GoogleMapsAPIWrapper], (markerManager: MarkerManager, apiWrapper: GoogleMapsAPIWrapper) => { const newMarker = new SebmGoogleMapMarker(markerManager); @@ -73,7 +73,7 @@ export function main() { return markerManager.updateIcon(newMarker).then(() => { expect(markerInstance.setIcon).toHaveBeenCalledWith(iconUrl); }); - })); + }))); }); }); }