Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Compatibility for Angular v15+ #2034

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
sudo: false
node_js:
- '10'
- '18'

env:
global:
Expand Down
6 changes: 4 additions & 2 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"cli": {
"packageManager": "yarn"
"packageManager": "yarn",
"analytics": false
},
"newProjectRoot": "packages",
"projects": {
Expand Down Expand Up @@ -85,5 +86,6 @@
}
}
}
}},
}
}
}
5 changes: 3 additions & 2 deletions jest.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'jest-preset-angular';
import 'jest-preset-angular/setup-jest';

(window as any).google = {
maps: {
Animation: { BOUNCE: 1, DROP: 2 },
Expand All @@ -25,5 +26,5 @@ import 'jest-preset-angular';
FORWARD_CLOSED_ARROW: 1,
FORWARD_OPEN_ARROW: 2,
},
}
},
};
4 changes: 2 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build.environment]
YARN_VERSION = "1.22.4"
NODE_VERSION = "10"
YARN_VERSION = "1.22.19"
NODE_VERSION = "18"
55 changes: 27 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "3.0.0-beta.1",
"version": "4.0.0-beta.0",
"description": "Angular components for Google Maps",
"repository": {
"type": "git",
Expand Down Expand Up @@ -42,35 +42,34 @@
},
"homepage": "https://angular-maps.com",
"dependencies": {
"@angular/animations": "^14.0.0",
"@angular/common": "^14.0.0",
"@angular/compiler": "^14.0.0",
"@angular/core": "^14.0.0",
"@angular/forms": "^14.0.0",
"@angular/platform-browser": "^14.0.0",
"@angular/platform-browser-dynamic": "^14.0.0",
"@angular/router": "^14.0.0",
"rxjs": "~6.6.0",
"@angular/animations": "^15.2.9",
"@angular/common": "^15.2.9",
"@angular/compiler": "^15.2.9",
"@angular/core": "^15.2.9",
"@angular/forms": "^15.2.9",
"@angular/platform-browser": "^15.2.9",
"@angular/platform-browser-dynamic": "^15.2.9",
"@angular/router": "^15.2.9",
"rxjs": "~7.8.0",
"tslib": "^2.4.0",
"zone.js": "~0.11.4"
"zone.js": "~0.12.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.0.0",
"@angular/cli": "^14.0.0",
"@angular/compiler-cli": "^14.0.0",
"@compodoc/compodoc": "^1.1.10",
"@types/jest": "^26.0.4",
"@types/node": "^14.0.22",
"codelyzer": "^6.0.0",
"conventional-changelog": "^3.1.21",
"jest": "^26.1.0",
"jest-preset-angular": "^8.2.1",
"ng-packagr": "^14.0.0",
"protractor": "~7.0.0",
"rimraf": "^3.0.2",
"ts-node": "~8.10.2",
"@angular-devkit/build-angular": "^15.2.8",
"@angular/cli": "^15.2.8",
"@angular/compiler-cli": "^15.2.9",
"@compodoc/compodoc": "^1.1.20",
"@types/jest": "^28.0.0",
"@types/node": "^18.15.3",
"codelyzer": "^6.0.2",
"conventional-changelog": "^3.1.25",
"jest": "^28.0.0",
"jest-preset-angular": "^12.2.6",
"ng-packagr": "^15.2.2",
"rimraf": "^4.4.1",
"ts-node": "~10.9.1",
"tslint": "~6.1.0",
"typescript": "~4.6.4",
"yarn": "^1.22.4"
"typescript": "~4.9.5",
"yarn": "^1.22.19"
}
}
}
16 changes: 8 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agm/core",
"version": "3.0.0-beta.1",
"version": "4.0.0-beta.1",
"description": "Angular components for Google Maps",
"author": "Sebastian Holstein <info@sebastian-holstein.de>",
"license": "MIT",
Expand All @@ -21,16 +21,16 @@
"gmaps"
],
"peerDependencies": {
"@angular/common": "^9.1.0 || ^10.0.0",
"@angular/core": "^9.1.0 || ^10.0.0"
"@angular/common": "^15.2.9",
"@angular/core": "^15.2.9"
},
"dependencies": {
"tslib": "^2.0.0"
"tslib": "^2.4.0"
},
"devDependencies": {
"@types/googlemaps": "^3.39.8",
"@types/jest": "^26.0.3",
"jest": "^26.1.0",
"jest-preset-angular": "^8.2.1"
"@types/googlemaps": "3.39.8",
"@types/jest": "^29.5.1",
"jest": "^29.5.0",
"jest-preset-angular": "^12.2.6"
}
}
4 changes: 2 additions & 2 deletions packages/core/src/lib/directives/map.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CUSTOM_ELEMENTS_SCHEMA, ElementRef, Injectable, SimpleChange } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';

import { Subject } from 'rxjs';
import { FitBoundsService } from '../services/fit-bounds';
Expand Down Expand Up @@ -28,7 +28,7 @@ describe('AgmMap', () => {
let fixture: ComponentFixture<AgmMap>;
let component: AgmMap;

beforeEach(async(() => {
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
AgmMap,
Expand Down
17 changes: 8 additions & 9 deletions packages/core/src/lib/directives/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ export class AgmZoomControl extends AgmMapControl{
`,
})
export class AgmMap implements OnChanges, AfterContentInit, OnDestroy {
/**
* Map option attributes that can change over time
*/
private static _mapOptionsAttributes: string[] = [
'disableDoubleClickZoom', 'scrollwheel', 'draggable', 'draggableCursor', 'draggingCursor',
'keyboardShortcuts', 'styles', 'zoom', 'minZoom', 'maxZoom', 'mapTypeId', 'clickableIcons',
'gestureHandling', 'tilt', 'restriction',
];
/**
* The longitude that defines the center of the map.
*/
Expand Down Expand Up @@ -343,15 +351,6 @@ export class AgmMap implements OnChanges, AfterContentInit, OnDestroy {
*/
@Input() restriction: google.maps.MapRestriction;

/**
* Map option attributes that can change over time
*/
private static _mapOptionsAttributes: string[] = [
'disableDoubleClickZoom', 'scrollwheel', 'draggable', 'draggableCursor', 'draggingCursor',
'keyboardShortcuts', 'styles', 'zoom', 'minZoom', 'maxZoom', 'mapTypeId', 'clickableIcons',
'gestureHandling', 'tilt', 'restriction',
];

private _observableSubscriptions: Subscription[] = [];
private _fitBoundsSubscription: Subscription;

Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/lib/directives/polyline-point.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('AgmPolylinePoint', () => {
polylinePoint.positionChanged.emit = jest.fn();

const positionChanges:
SimpleChanges = {'latitude': new SimpleChange('previousLat', 'newLat', false)};
SimpleChanges = {latitude: new SimpleChange('previousLat', 'newLat', false)};

polylinePoint.ngOnChanges(positionChanges);

Expand All @@ -25,7 +25,7 @@ describe('AgmPolylinePoint', () => {
polylinePoint.positionChanged.emit = jest.fn();

const positionChanges:
SimpleChanges = {'longitude': new SimpleChange('previousLng', 'newLng', false)};
SimpleChanges = {longitude: new SimpleChange('previousLng', 'newLng', false)};

polylinePoint.ngOnChanges(positionChanges);

Expand All @@ -38,8 +38,8 @@ describe('AgmPolylinePoint', () => {
polylinePoint.positionChanged.emit = jest.fn();

const positionChanges: SimpleChanges = {
'latitude': new SimpleChange('previousLat', 'newLat', false),
'longitude': new SimpleChange('previousLng', 'newLng', false),
latitude: new SimpleChange('previousLat', 'newLat', false),
longitude: new SimpleChange('previousLng', 'newLng', false),
};

polylinePoint.ngOnChanges(positionChanges);
Expand All @@ -58,8 +58,8 @@ describe('AgmPolylinePoint', () => {
expect(value).toEqual({ latLng: {lat: 50, lng: -50} });

const positionChanges: SimpleChanges = {
'latitude': new SimpleChange(50, 100, false),
'longitude': new SimpleChange(-50, -100, false),
latitude: new SimpleChange(50, 100, false),
longitude: new SimpleChange(-50, -100, false),
};
polylinePoint.ngOnChanges(positionChanges);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/lib/services/fit-bounds.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, from, Observable, timer } from 'rxjs';
import {
flatMap,
map,
mergeMap,
sample,
shareReplay,
switchMap,
Expand Down Expand Up @@ -37,7 +37,7 @@ export class FitBoundsService {

constructor(loader: MapsAPILoader) {
this.bounds$ = from(loader.load()).pipe(
flatMap(() => this._includeInBounds$),
mergeMap(() => this._includeInBounds$),
sample(
this._boundsChangeSampleTime$.pipe(switchMap(time => timer(0, time))),
),
Expand Down
16 changes: 6 additions & 10 deletions packages/core/src/lib/services/geocoder-service.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import { Injectable } from '@angular/core';
import { bindCallback, ConnectableObservable, Observable, of, ReplaySubject, throwError } from 'rxjs';
import { map, multicast, switchMap } from 'rxjs/operators';
import { bindCallback, connectable, Connectable, Observable, of, ReplaySubject, throwError } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { MapsAPILoader } from './maps-api-loader/maps-api-loader';

@Injectable({ providedIn: 'root' })
@Injectable({providedIn: 'root'})
export class AgmGeocoder {
protected readonly geocoder$: Observable<google.maps.Geocoder>;

constructor(loader: MapsAPILoader) {
const connectableGeocoder$ = new Observable(subscriber => {
const connectableGeocoder$: Connectable<google.maps.Geocoder> = connectable(new Observable(subscriber => {
loader.load().then(() => subscriber.next());
})
.pipe(
map(() => this._createGeocoder()),
multicast(new ReplaySubject(1)),
) as ConnectableObservable<google.maps.Geocoder>;
}).pipe(map(() => this._createGeocoder())), {connector: () => new ReplaySubject(1)});

connectableGeocoder$.connect(); // ignore the subscription
// since we will remain subscribed till application exits
Expand All @@ -29,7 +25,7 @@ export class AgmGeocoder {
}

private _getGoogleResults(geocoder: google.maps.Geocoder, request: google.maps.GeocoderRequest):
Observable<google.maps.GeocoderResult[]> {
Observable<google.maps.GeocoderResult[]> {
const geocodeObservable = bindCallback(geocoder.geocode);
return geocodeObservable(request).pipe(
switchMap(([results, status]) => {
Expand Down
17 changes: 8 additions & 9 deletions packages/core/src/lib/services/managers/polygon-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ describe('PolygonManager', () => {
[PolygonManager, GoogleMapsAPIWrapper],
(polygonManager: PolygonManager, apiWrapper: GoogleMapsAPIWrapper) => {
paths = new MvcArrayMock<google.maps.MVCArray<google.maps.LatLng>>();
let path = new MvcArrayMock<google.maps.LatLng>();
const path: MvcArrayMock<google.maps.LatLng> = new MvcArrayMock<google.maps.LatLng>();
path.push(initLatLng);
paths.push(path);

const polygonInstance: any = {
getPaths: () => paths,
setMap: jest.fn(),
Expand Down Expand Up @@ -113,7 +112,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
paths.push(new MvcArrayMock());
paths.push(new MvcArrayMock());
});
Expand All @@ -140,7 +139,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
paths.pop();
paths.removeAt(0);
});
Expand All @@ -166,7 +165,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
const firstMvcArray = new MvcArrayMock<google.maps.LatLng>();
firstMvcArray.push(initLatLng);
firstMvcArray.push(initLatLng);
Expand Down Expand Up @@ -196,7 +195,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
paths.getAt(0).push(initLatLng);
paths.getAt(0).push(initLatLng);
});
Expand All @@ -223,7 +222,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
paths.getAt(0).pop();
paths.getAt(0).removeAt(0);
});
Expand All @@ -249,7 +248,7 @@ describe('PolygonManager', () => {
if (expectationIndex === expectations.length) {
done();
}
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
paths.push(new MvcArrayMock<google.maps.LatLng>());
paths.getAt(1).push(initLatLng);
});
Expand All @@ -270,7 +269,7 @@ describe('PolygonManager', () => {
eventName: 'removed_at',
...expectations[expectationIndex++],
});
}, fail /* shouldn't have errors */, fail /* shouldn't finish */);
});
const removedPath = paths.pop();
removedPath.pop();
done();
Expand Down
Loading