Skip to content

Commit

Permalink
feat: support angular2.0.0-rc.1
Browse files Browse the repository at this point in the history
  • Loading branch information
carl09 committed May 12, 2016
1 parent 3cda0ba commit 636a19a
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 84 deletions.
9 changes: 7 additions & 2 deletions gulp/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ const bundleConfig = {
defaultJSExtensions: true,
paths: {
'angular2-google-maps/*': '*',
'angular2/*': './node_modules/angular2/*',
'rxjs/*': './node_modules/rxjs/*',
},
packages: {
'@angular/core': { main: 'index.js', defaultExtension: 'js' },
},
map: {
'@angular': '@angular',
},
};

function bundle(moduleName, moduleBundleName, minify, done) {
Expand All @@ -23,7 +28,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
10 changes: 9 additions & 1 deletion gulp/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ const config = require('./config');
const fs = require('fs');
const path = require('path');

gulp.task('copyReleaseAssets', function copyReleaseAssets() {
gulp.task('copyReleaseAssets', ['copyReleaseAssets:int', 'copyReleaseAssets:ng']);

gulp.task('copyReleaseAssets:int', function copyReleaseAssets() {
return gulp.src(config.PATHS.releaseAssets)
.pipe(gulp.dest(config.PATHS.dist.base));
});

gulp.task('copyReleaseAssets:ng', function copyReleaseAssets() {
// Need to copy over angular dependencies for minify
return gulp.src(['node_modules/@angular/**/*'])
.pipe(gulp.dest(config.PATHS.dist.base + '/@angular'));
});

gulp.task('changelog', function changelog() {
return gulp.src('CHANGELOG.md', {
buffer: false,
Expand Down
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const runSequence = require('run-sequence');

// all grunt tasks, which are defined here, are intended for use via the CLI.
gulp.task('build', function build(done) {
runSequence('clean:dist', 'lint', ['copyReleaseAssets', 'scripts', 'bundle'], 'createPackageJson', done);
runSequence('clean:dist', 'lint', 'copyReleaseAssets', ['scripts', 'bundle'], 'createPackageJson', done);
});

gulp.task('serve', ['connect', 'watch:srcFiles']);
Expand Down
30 changes: 30 additions & 0 deletions karma-systemjs-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
(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/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/router-deprecated',
];
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
42 changes: 28 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,19 @@
},
"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/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "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",
"systemjs": "0.19.27"
},
"devDependencies": {
"babel-eslint": "4.1.8",
Expand Down Expand Up @@ -56,21 +63,28 @@
"replace": "0.3.0",
"require-dir": "0.3.0",
"run-sequence": "1.1.5",
"systemjs": "0.19.23",
"systemjs-builder": "0.15.13",
"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",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "^0.6.4"
"@angular/common": "2.0.0-rc.1",
"@angular/compiler": "2.0.0-rc.1",
"@angular/core": "2.0.0-rc.1",
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"es6-promise": "^3.1.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"systemjs": "0.19.27"
}
}
}
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
15 changes: 8 additions & 7 deletions src/directives/google-map-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
EventEmitter,
ContentChild,
AfterContentInit
} from 'angular2/core';
} from '@angular/core';
import {MarkerManager} from '../services/marker-manager';
import {SebmGoogleMapInfoWindow} from './google-map-info-window';
import {MouseEvent} from '../events';
Expand Down Expand Up @@ -129,12 +129,13 @@ export class SebmGoogleMapMarker implements OnDestroy,
}

private _addEventListeners() {
this._markerManager.createEventObservable('click', this).subscribe(() => {
if (this._infoWindow != null) {
this._infoWindow.open();
}
this.markerClick.next(null);
});
this._markerManager.createEventObservable('click', this)
.subscribe(() => {
if (this._infoWindow != null) {
this._infoWindow.open();
}
this.markerClick.next(null);
});
this._markerManager.createEventObservable<mapTypes.MouseEvent>('dragend', this)
.subscribe((e: mapTypes.MouseEvent) => {
this.dragEnd.next({coords: {lat: e.latLng.lat(), lng: e.latLng.lng()}});
Expand Down
56 changes: 36 additions & 20 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 @@ -34,20 +34,31 @@ import {MouseEvent} from '../events';
selector: 'sebm-google-map',
providers: [GoogleMapsAPIWrapper, MarkerManager, InfoWindowManager],
inputs: [
'longitude', 'latitude', 'zoom', 'disableDoubleClickZoom', 'disableDefaultUI', 'scrollwheel',
'backgroundColor', 'draggableCursor', 'draggingCursor', 'keyboardShortcuts', 'zoomControl'
'longitude',
'latitude',
'zoom',
'disableDoubleClickZoom',
'disableDefaultUI',
'scrollwheel',
'backgroundColor',
'draggableCursor',
'draggingCursor',
'keyboardShortcuts',
'zoomControl'
],
outputs: ['mapClick', 'mapRightClick', 'mapDblClick', 'centerChange'],
host: {'[class.sebm-google-map-container]': 'true'},
styles: [`
styles: [
`
.sebm-google-map-container-inner {
width: inherit;
height: inherit;
}
.sebm-google-map-content {
display:none;
}
`],
`
],
template: `
<div class='sebm-google-map-container-inner'></div>
<div class='sebm-google-map-content'>
Expand Down Expand Up @@ -113,8 +124,12 @@ export class SebmGoogleMap implements OnChanges,
* Map option attributes that can change over time
*/
private static _mapOptionsAttributes: string[] = [
'disableDoubleClickZoom', 'scrollwheel', 'draggableCursor', 'draggingCursor',
'keyboardShortcuts', 'zoomControl'
'disableDoubleClickZoom',
'scrollwheel',
'draggableCursor',
'draggingCursor',
'keyboardShortcuts',
'zoomControl'
];

/**
Expand Down Expand Up @@ -237,19 +252,19 @@ export class SebmGoogleMap implements OnChanges,
}

private _handleMapCenterChange() {
this._mapsWrapper.subscribeToMapEvent<void>('center_changed').subscribe(() => {
this._mapsWrapper.getCenter().then((center: LatLng) => {
this._latitude = center.lat();
this._longitude = center.lng();
this.centerChange.emit(<LatLngLiteral>{lat: this._latitude, lng: this._longitude});
});
});
this._mapsWrapper.subscribeToMapEvent<void>('center_changed')
.subscribe(() => {
this._mapsWrapper.getCenter().then((center: LatLng) => {
this._latitude = center.lat();
this._longitude = center.lng();
this.centerChange.emit(<LatLngLiteral>{lat: this._latitude, lng: this._longitude});
});
});
}

private _handleMapZoomChange() {
this._mapsWrapper.subscribeToMapEvent<void>('zoom_changed').subscribe(() => {
this._mapsWrapper.getZoom().then((z: number) => this._zoom = z);
});
this._mapsWrapper.subscribeToMapEvent<void>('zoom_changed')
.subscribe(() => { this._mapsWrapper.getZoom().then((z: number) => this._zoom = z); });
}

private _handleMapMouseEvents() {
Expand All @@ -259,13 +274,14 @@ 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: 'click', emitter: this.mapClick},
{name: 'rightclick', emitter: this.mapRightClick},
{name: 'dblclick', emitter: this.mapDblClick}
];

events.forEach((e: Event) => {
this._mapsWrapper.subscribeToMapEvent<{latLng: LatLng}>(e.name).subscribe(
(event: {latLng: LatLng}) => {
this._mapsWrapper.subscribeToMapEvent<{latLng: LatLng}>(e.name)
.subscribe((event: {latLng: LatLng}) => {
const value = <MouseEvent>{coords: {lat: event.latLng.lat(), lng: event.latLng.lng()}};
e.emitter.emit(value);
});
Expand Down
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
Loading

0 comments on commit 636a19a

Please sign in to comment.