Skip to content

Commit d93e2bc

Browse files
committed
fix: export handling cleanup and declaration fixes
1 parent 1261758 commit d93e2bc

16 files changed

+2578
-2477
lines changed

demo-angular/package.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@
88
"e2e-watch": "tsc -p e2e --watch"
99
},
1010
"dependencies": {
11-
"@angular/animations": "~10.1.0",
12-
"@angular/common": "~10.1.0",
13-
"@angular/compiler": "~10.1.0",
14-
"@angular/core": "~10.1.0",
15-
"@angular/forms": "~10.1.0",
16-
"@angular/platform-browser": "~10.1.0",
17-
"@angular/platform-browser-dynamic": "~10.1.0",
18-
"@angular/router": "~10.1.0",
19-
"@nativescript/angular": "^10.0.3",
20-
"@nativescript/core": "^7.0.3",
21-
"@nativescript/theme": "^2.3.3",
11+
"@angular/animations": "~11.2.0",
12+
"@angular/common": "~11.2.0",
13+
"@angular/compiler": "~11.2.0",
14+
"@angular/core": "~11.2.0",
15+
"@angular/forms": "~11.2.0",
16+
"@angular/platform-browser": "~11.2.0",
17+
"@angular/platform-browser-dynamic": "~11.2.0",
18+
"@angular/router": "~11.2.0",
19+
"@nativescript/angular": "~11.8.0",
20+
"@nativescript/core": "^8.0.0",
21+
"@nativescript/theme": "^3.0.0",
2222
"@nativescript/webpack": "^3.0.4",
2323
"@nativescript-community/perms": "^2.1.1",
2424
"@nativescript-community/ui-mapbox": "file:../plugin",
2525
"nativescript-ui-sidedrawer": "~9.0.0",
2626
"reflect-metadata": "~0.1.12",
2727
"rxjs": "^6.4.0",
2828
"rxjs-compat": "^6.5.3",
29-
"zone.js": "~0.9.1"
29+
"zone.js": "~0.11.3"
3030
},
3131
"devDependencies": {
32-
"@angular/compiler-cli": "~10.1.0",
33-
"@nativescript/android": "7.0.0",
34-
"@ngtools/webpack": "~10.1.0",
32+
"@angular/compiler-cli": "~11.2.0",
33+
"@nativescript/android": "8.0.0",
34+
"@ngtools/webpack": "~11.2.0",
3535
"@types/chai": "~4.1.7",
3636
"@types/mocha": "~5.2.5",
3737
"@types/node": "~10.12.18",
@@ -44,7 +44,7 @@
4444
"nativescript-dev-appium": "^6.1.2",
4545
"node-sass": "^4.7.1",
4646
"tslint": "~5.19.0",
47-
"typescript": "~3.9.0"
47+
"typescript": "~4.0.0"
4848
},
4949
"gitHead": "12284faf57b80a564bca5377e12c149c89d282c3",
5050
"readme": "NativeScript Application",

demo/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"dependencies": {
3-
"@nativescript/core": "^7.0.13",
3+
"@nativescript/core": "^8.0.0",
44
"@nativescript-community/perms": "^2.1.1",
55
"@nativescript/webpack": "3.0.8",
66
"@nativescript-community/ui-mapbox": "file:../plugin"
77
},
88
"devDependencies": {
99
"@babel/core": "~7.12.3",
1010
"@babel/preset-env": "~7.12.1",
11-
"@nativescript/android": "7.0.1",
12-
"@nativescript/ios": "7.0.5",
13-
"@nativescript/types": "7.0.4",
14-
"typescript": "~3.9.7"
11+
"@nativescript/android": "8.0.0",
12+
"@nativescript/ios": "8.0.0",
13+
"@nativescript/types": "8.0.0",
14+
"typescript": "~4.0.0"
1515
},
1616
"main": "app.js"
1717
}

demo/tsconfig.json

-4
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030
"types": [],
3131
"baseUrl": ".",
3232
"paths": {
33-
"*": [
34-
"./node_modules/tns-core-modules/*",
35-
"./node_modules/*"
36-
],
3733
"~/*": [
3834
"app/*"
3935
]

package.json

+17-16
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
"setup": "ts-patch install",
1919
"prepare": "npm run setup",
2020
"build.angular": "ng-packagr -p src/angular/package.json -c src/angular/tsconfig.json",
21-
"clean": "rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json plugin/README.md demo/node_modules demo-angular/node_modules",
21+
"clean": "npx rimraf ./plugin/**/*.d.ts ./plugin/**/*.js ./plugin/**/*.js.map plugin/node_modules plugin/package-lock.json plugin/README.md demo/node_modules demo-angular/node_modules",
22+
"reset": "npm run clean && yarn && npm run setup",
2223
"tsc": "cpy '**/*.d.ts' '../plugin' --parents --cwd=src && tsc -skipLibCheck -d",
23-
"build": "cp README.md ./plugin && rm -f .tsbuildinfo && npm run tsc ",
24+
"build": "cp README.md ./plugin && rm -f .tsbuildinfo && npm run tsc",
2425
"publish": "npm run setup && npm run build && lerna publish --create-release=github",
2526
"commitmsg": "commitlint -e $GIT_PARAMS",
2627
"demo.ios": "npm run build && cd ./demo && ns run ios",
@@ -66,21 +67,21 @@
6667
"homepage": "https://github.com/nativescript-community/ui-mapbox",
6768
"readmeFilename": "README.md",
6869
"devDependencies": {
69-
"@angular/animations": "~10.1.5",
70-
"@angular/common": "~10.1.5",
71-
"@angular/compiler": "~10.1.5",
72-
"@angular/compiler-cli": "~10.1.5",
73-
"@angular/core": "~10.1.5",
74-
"@angular/forms": "~10.1.5",
75-
"@angular/platform-browser": "~10.1.5",
76-
"@angular/platform-browser-dynamic": "11.0.0-rc.3",
77-
"@angular/router": "~10.1.5",
70+
"@angular/animations": "~11.2.0",
71+
"@angular/common": "~11.2.0",
72+
"@angular/compiler": "~11.2.0",
73+
"@angular/compiler-cli": "~11.2.0",
74+
"@angular/core": "~11.2.0",
75+
"@angular/forms": "~11.2.0",
76+
"@angular/platform-browser": "~11.2.0",
77+
"@angular/platform-browser-dynamic": "~11.2.0",
78+
"@angular/router": "~11.2.0",
7879
"@commitlint/cli": "^11.0.0",
7980
"@commitlint/config-conventional": "^11.0.0",
8081
"@nativescript-community/perms": "^2.1.1",
81-
"@nativescript/angular": "10.1.7",
82-
"@nativescript/core": "7.0.13",
83-
"@nativescript/ios": "7.0.5",
82+
"@nativescript/angular": "~11.8.0",
83+
"@nativescript/core": "~8.0.0",
84+
"@nativescript/ios": "8.0.0",
8485
"@nativescript/types-android": "~7.0.4",
8586
"@nativescript/types-ios": "~7.0.4",
8687
"@nativescript/webpack": "3.0.8",
@@ -94,7 +95,7 @@
9495
"eslint-plugin-prettier": "^3.1.4",
9596
"husky": "^4.3.0",
9697
"lerna": "^3.22.1",
97-
"ng-packagr": "~10.1.2",
98+
"ng-packagr": "~11.2.0",
9899
"prettier": "^2.1.2",
99100
"prompt": "^1.0.0",
100101
"react-nativescript": "^2.1.0",
@@ -103,7 +104,7 @@
103104
"svelte-native": "0.9.5",
104105
"ts-patch": "^1.3.0",
105106
"tslib": "2.0.3",
106-
"typescript": "3.9.7",
107+
"typescript": "~4.0.0",
107108
"zone.js": "0.11.3",
108109
"vue": "^2.6.12"
109110
},

plugin/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@nativescript-community/ui-mapbox",
33
"version": "6.2.9",
44
"description": "Interactive, thoroughly customizable maps powered by vector tiles and OpenGL.",
5-
"main": "mapbox",
5+
"main": "index",
66
"typings": "index.d.ts",
77
"nativescript": {
88
"platforms": {

plugin/platforms/ios/Podfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
platform :ios, '10.0'
1+
platform :ios, '13.0'
22

33
pod 'Mapbox-iOS-SDK'

src/mapbox.common.ts src/common.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Color, ContentView, ImageSource, Property, Trace, booleanConverter } from '@nativescript/core';
22

3+
export * from './geo.utils';
4+
export * from './filter/filter-parser';
5+
export * from './layers/layer-factory';
6+
export * from './layers/parser/property-parser';
7+
38
export const MapboxTraceCategory = 'NativescriptMapbox';
49
export enum CLogTypes {
510
log = Trace.messageType.log,

src/filter/filter-parser.d.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export declare class FilterParser {
2+
static parseJson(json: any[]): any;
3+
static toJson(filter: any): any[];
4+
}

src/mapbox.android.ts src/index.android.ts

+7-44
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@
55
*/
66

77
import { request } from '@nativescript-community/perms';
8-
import { AndroidApplication, Application, Color, File, Image, ImageSource, Trace, Utils, knownFolders, path } from '@nativescript/core';
9-
import { getImage } from '@nativescript/core/http';
10-
import { FilterParser } from './filter/filter-parser.android';
11-
import { GeoUtils } from './geo.utils';
12-
import { layout } from '@nativescript/core/utils';
13-
import { LayerFactory } from './layers/layer-factory';
8+
import { AndroidApplication, Application, Color, File, Image, ImageSource, Trace, Utils, knownFolders, path, Http } from '@nativescript/core';
9+
import { FilterParser } from './filter/filter-parser';
10+
import { LayerFactory, Layer } from './layers/layer-factory';
1411
import {
1512
AddExtrusionOptions,
1613
AddGeoJsonClusteredOptions,
@@ -46,11 +43,11 @@ import {
4643
UserLocationCameraMode,
4744
Viewport,
4845
telemetryProperty
49-
} from './mapbox.common';
46+
} from './common';
5047

5148
// Export the enums for devs not using TS
5249

53-
export { MapboxTraceCategory, MapStyle };
50+
export * from './common';
5451

5552
function _getLocation(loc: globalAndroid.location.Location) {
5653
if (loc === null) {
@@ -3244,7 +3241,7 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
32443241
return;
32453242
}
32463243
// ..or not to cache
3247-
getImage(marker.icon).then(
3244+
Http.getImage(marker.icon).then(
32483245
(output) => {
32493246
marker.iconDownloaded = output.android;
32503247
this._markerIconDownloadCache[marker.icon] = marker.iconDownloaded;
@@ -3277,40 +3274,6 @@ export class Mapbox extends MapboxCommon implements MapboxApi {
32773274
project(data: LatLng) {
32783275
const mapboxPoint = new com.mapbox.mapboxsdk.geometry.LatLng(data.lat, data.lng);
32793276
const screenLocation = this._mapboxMapInstance.getProjection().toScreenLocation(mapboxPoint);
3280-
return { x: layout.toDeviceIndependentPixels(screenLocation.x), y: layout.toDeviceIndependentPixels(screenLocation.y) };
3281-
}
3282-
}
3283-
3284-
export class Layer implements LayerCommon {
3285-
public id: string;
3286-
private instance: any;
3287-
3288-
constructor(instance: any) {
3289-
this.instance = instance;
3290-
this.id = instance.getId();
3291-
}
3292-
3293-
public visibility(): boolean {
3294-
return this.instance.getVisibility().getValue() === 'visible' ? true : false;
3295-
}
3296-
3297-
public show(): void {
3298-
this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'visible')]);
3299-
}
3300-
3301-
public hide(): void {
3302-
this.instance.setProperties([new com.mapbox.mapboxsdk.style.layers.PropertyValue('visibility', 'none')]);
3303-
}
3304-
3305-
public getNativeInstance() {
3306-
return this.instance;
3307-
}
3308-
3309-
public setFilter(filter: any[]) {
3310-
this.instance.setFilter(FilterParser.parseJson(filter));
3311-
}
3312-
3313-
public getFilter(): any[] {
3314-
return FilterParser.toJson(this.instance.getFilter());
3277+
return { x: Utils.layout.toDeviceIndependentPixels(screenLocation.x), y: Utils.layout.toDeviceIndependentPixels(screenLocation.y) };
33153278
}
33163279
}

src/index.d.ts

+98-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,100 @@
1-
/**
2-
* iOS and Android apis should match.
3-
* It doesn't matter if you export `.ios` or `.android`, either one but only one.
4-
*/
5-
export * from './mapbox.ios';
1+
import { ImageSource } from '@nativescript/core';
2+
import { AddExtrusionOptions, AddGeoJsonClusteredOptions, AddPolygonOptions, AddPolylineOptions, AddSourceOptions, AnimateCameraOptions, DeleteOfflineRegionOptions, DownloadOfflineRegionOptions, Feature, LatLng, LayerCommon, ListOfflineRegionsOptions, MapboxApi, MapboxCommon, MapboxMarker, MapboxViewBase, MapStyle, OfflineRegion, QueryRenderedFeaturesOptions, QuerySourceFeaturesOptions, SetCenterOptions, SetTiltOptions, SetViewportOptions, SetZoomLevelOptions, ShowOptions, TrackUserOptions, UpdateSourceOptions, UserLocation, UserLocationCameraMode, Viewport } from './common';
63

74
// Export any shared classes, constants, etc.
8-
export * from './mapbox.common';
5+
export * from './common';
6+
7+
export declare function setLogLevel(level: 'none' | 'info' | 'debug' | 'error' | 'fault' | 'verbose'): void;
8+
export declare class MapboxView extends MapboxViewBase {
9+
private nativeMapView;
10+
private delegate;
11+
private settings;
12+
private initialized;
13+
private initCountHack;
14+
setConfig(settings: any): void;
15+
getNativeMapView(): any;
16+
createNativeView(): Object;
17+
onLoaded(): void;
18+
initNativeView(): void;
19+
disposeNativeView(): Promise<void>;
20+
getMapboxApi(): any;
21+
initMap(): void;
22+
onLayout(left: number, top: number, right: number, bottom: number): void;
23+
}
24+
export declare class Mapbox extends MapboxCommon implements MapboxApi {
25+
private _mapboxViewInstance;
26+
private eventCallbacks;
27+
private userLocationRenderMode;
28+
setMapboxViewInstance(mapboxViewInstance: any): void;
29+
initEventHandlerShim(settings: any, mapboxNativeViewInstance: any): void;
30+
onMapEvent(eventName: any, id: any, callback: any, nativeMapView?: any): void;
31+
offMapEvent(eventName: any, id: any, nativeMapView?: any): void;
32+
private checkForClickEvent;
33+
private _addMarkers;
34+
show(options: ShowOptions): Promise<any>;
35+
hide(): Promise<void>;
36+
unhide(): Promise<void>;
37+
destroy(nativeMap?: any): Promise<void>;
38+
onStart(nativeMap?: any): Promise<void>;
39+
onResume(nativeMap?: any): Promise<void>;
40+
onPause(nativeMap?: any): Promise<void>;
41+
onStop(nativeMap?: any): Promise<void>;
42+
onLowMemory(nativeMap?: any): Promise<void>;
43+
onDestroy(nativeMap?: any): Promise<void>;
44+
setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<void>;
45+
getImage(imageId: string, nativeMap?: any): Promise<ImageSource>;
46+
addImage(imageId: string, image: string, nativeMap?: any): Promise<void>;
47+
removeImage(imageId: string, nativeMap?: any): Promise<void>;
48+
addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<void>;
49+
removeMarkers(ids?: any, nativeMap?: any): Promise<void>;
50+
setCenter(options: SetCenterOptions, nativeMap?: any): Promise<void>;
51+
getCenter(nativeMap?: any): Promise<LatLng>;
52+
setZoomLevel(options: SetZoomLevelOptions, nativeMap?: any): Promise<void>;
53+
getZoomLevel(nativeMap?: any): Promise<number>;
54+
setTilt(options: SetTiltOptions, nativeMap?: any): Promise<void>;
55+
getTilt(nativeMap?: any): Promise<number>;
56+
getUserLocation(nativeMap?: any): Promise<UserLocation>;
57+
_stringToCameraMode(mode: UserLocationCameraMode): any;
58+
_stringToRenderMode(mode: any): any;
59+
showUserLocationMarker(options: any, nativeMap?: any): Promise<void>;
60+
hideUserLocationMarker(nativeMap?: any): Promise<void>;
61+
changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): Promise<void>;
62+
forceUserLocationUpdate(location: any, nativeMap?: any): void;
63+
queryRenderedFeatures(options: QueryRenderedFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
64+
querySourceFeatures(sourceId: string, options?: QuerySourceFeaturesOptions, nativeMap?: any): Promise<Feature[]>;
65+
addPolygon(options: AddPolygonOptions, nativeMap?: any): Promise<void>;
66+
addPolyline(options: AddPolylineOptions, nativeMap?: any): Promise<void>;
67+
private removePolyById;
68+
private removePolys;
69+
removePolygons(ids?: any[], nativeMap?: any): Promise<void>;
70+
removePolylines(ids?: any[], nativeMap?: any): Promise<void>;
71+
animateCamera(options: AnimateCameraOptions, nativeMap?: any): Promise<void>;
72+
setOnMapClickListener(listener: (data: LatLng) => void, nativeMap?: any): Promise<void>;
73+
setOnMapLongClickListener(listener: (data: LatLng) => void, nativeMap?: any): Promise<void>;
74+
setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
75+
setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
76+
setOnFlingListener(listener: () => void, nativeMap?: any): Promise<void>;
77+
setOnCameraMoveListener(listener: (reason: any, animated?: any) => void, nativeMap?: any): Promise<void>;
78+
setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<void>;
79+
setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<void>;
80+
getViewport(nativeMap?: any): Promise<Viewport>;
81+
setViewport(options: SetViewportOptions, nativeMap?: any): Promise<void>;
82+
downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<void>;
83+
listOfflineRegions(options?: ListOfflineRegionsOptions): Promise<OfflineRegion[]>;
84+
deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<void>;
85+
addExtrusion(options: AddExtrusionOptions, nativeMap?: any): Promise<void>;
86+
updateSource(id: string, options: UpdateSourceOptions, nativeMap?: any): Promise<unknown>;
87+
addSource(id: string, options: AddSourceOptions, nativeMap?: any): Promise<void>;
88+
removeSource(id: string, nativeMap?: any): Promise<void>;
89+
addLayer(style: any, belowLayerId?: string, nativeMapView?: any): Promise<void>;
90+
removeLayer(id: string, nativeMapViewInstance?: any): Promise<void>;
91+
addLinePoint(id: string, lnglat: any, sourceId?: string, nativeMapView?: any): Promise<void>;
92+
addGeoJsonClustered(options: AddGeoJsonClusteredOptions, nativeMapViewInstance?: any): Promise<void>;
93+
trackUser(options: TrackUserOptions, nativeMap?: any): Promise<void>;
94+
getLayer(name: string, nativeMap?: any): Promise<LayerCommon>;
95+
getLayers(nativeMap?: any): Promise<LayerCommon[]>;
96+
project(data: LatLng): {
97+
x: number;
98+
y: number;
99+
};
100+
}

0 commit comments

Comments
 (0)