Skip to content

Commit

Permalink
feat(*): support angular2.0.0-rc.1
Browse files Browse the repository at this point in the history
closes #339
  • Loading branch information
carl09 authored and sebholstein committed May 12, 2016
1 parent 3cda0ba commit 84bc54a
Show file tree
Hide file tree
Showing 17 changed files with 119 additions and 71 deletions.
12 changes: 10 additions & 2 deletions gulp/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(() => {
Expand Down
27 changes: 27 additions & 0 deletions karma-systemjs-config.js
Original file line number Diff line number Diff line change
@@ -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);
14 changes: 12 additions & 2 deletions karma-test-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
23 changes: 15 additions & 8 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,7 +53,6 @@ module.exports = function(config) {
'/base/src/': '/base/dist/',
'/base/test-built/src': '/base/dist'
},

reporters: ['progress'],
port: 9876,
colors: true,
Expand Down
35 changes: 22 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
}
2 changes: 1 addition & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 2 additions & 3 deletions src/directives/google-map-info-window.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -36,8 +36,7 @@ let infoWindowId = 0;
@Component({
selector: 'sebm-google-map-info-window',
inputs: ['latitude', 'longitude', 'disableAutoPan'],
template: `
<div class='sebm-google-map-info-window-content'>
template: `<div class='sebm-google-map-info-window-content'>
<ng-content></ng-content>
</div>
`
Expand Down
10 changes: 1 addition & 9 deletions src/directives/google-map-marker.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
14 changes: 7 additions & 7 deletions src/directives/google-map.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand All @@ -204,20 +204,20 @@ 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();
}

/**
* 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') {
Expand Down Expand Up @@ -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) => {
Expand Down
6 changes: 1 addition & 5 deletions src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 1 addition & 1 deletion src/services/google-maps-api-wrapper.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
24 changes: 12 additions & 12 deletions src/services/google-maps-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -20,20 +20,20 @@ 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;
addListener(eventType: string, fn: Function): void;
}

export interface MarkerOptions {
position: LatLng | LatLngLiteral;
position: LatLng|LatLngLiteral;
title?: string;
map?: GoogleMap;
label?: string | MarkerLabel;
label?: string|MarkerLabel;
draggable?: boolean;
icon?: string;
}
Expand All @@ -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;
Expand All @@ -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;
}

Expand All @@ -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;
}
2 changes: 1 addition & 1 deletion src/services/info-window-manager.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/services/maps-api-loader/lazy-maps-api-loader.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/services/maps-api-loader/maps-api-loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Injectable} from 'angular2/core';
import {Injectable} from '@angular/core';

@Injectable()
export abstract class MapsAPILoader {
Expand Down
2 changes: 1 addition & 1 deletion src/services/marker-manager.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Loading

0 comments on commit 84bc54a

Please sign in to comment.