Skip to content

Commit

Permalink
webpack
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 14, 2018
1 parent 146ca67 commit 2601995
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 48 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ matrix:
before_install:
- gem install cocoapods
- pod repo update
script: cd ../demo && npm run build-ios-bundle
script: cd ../demo && tns build ios --bundle
- language: android
os: linux
env:
- Webpack="Android"
jdk: oraclejdk8
before_install: nvm install 6.10.3
script: cd ../demo && npm run build-android-bundle
script: cd ../demo && tns build android --bundle
- stage: "Build"
env:
- BuildAndroid="25"
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright 2017 Eddy Verbruggen
Copyright 2018 Eddy Verbruggen

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 4 additions & 0 deletions demo/app/vendor-platform.android.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require("application");
if (!global["__snapshot"]) {
// In case snapshot generation is enabled these modules will get into the bundle
// but will not be required/evaluated.
// The snapshot webpack plugin will add them to the tns-java-classes.js bundle file.
// This way, they will be evaluated on app start as early as possible.
require("ui/frame");
require("ui/frame/activity");
}
3 changes: 3 additions & 0 deletions demo/app/vendor-platform.ios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// There is a bug in angular: https://github.com/angular/angular-cli/pull/8589/files
// Legendary stuff, its webpack plugin pretty much doesn't work with empty TypeScript files in v1.8.3
void 0;
7 changes: 7 additions & 0 deletions demo/app/vendor.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
// Snapshot the ~/app.css and the theme
const application = require("application");
require("ui/styling/style-scope");
const appCssContext = require.context("~/", false, /^\.\/app\.(css|scss|less|sass)$/);
global.registerWebpackModules(appCssContext);
application.loadAppCss();

require("./vendor-platform");

require("bundle-entry-points");
31 changes: 12 additions & 19 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
}
},
"dependencies": {
"nativescript-mapbox": "file:///Users/eddyverbruggen/sandboxes/nativescript-mapbox/src",
"nativescript-theme-core": "^1.0.2",
"nativescript-mapbox": "../src",
"nativescript-theme-core": "^1.0.4",
"nativescript-unit-test-runner": "^0.3.4",
"tns-core-modules": "^3.1.1"
"tns-core-modules": "~3.4.0"
},
"devDependencies": {
"awesome-typescript-loader": "~3.1.3",
Expand All @@ -28,23 +28,16 @@
"karma-nativescript-launcher": "^0.4.0",
"lazy": "1.0.11",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-typescript": "^0.4.0",
"nativescript-dev-webpack": "0.7.3",
"nativescript-dev-typescript": "libs",
"nativescript-dev-webpack": "~0.9.0",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.1.0",
"tns-platform-declarations": "^3.2.0",
"typescript": "^2.4.2",
"webpack": "~3.2.0",
"tns-platform-declarations": "~3.4.0",
"typescript": "~2.4.0",
"webpack": "~3.8.1",
"webpack-bundle-analyzer": "^2.8.2",
"webpack-sources": "~1.0.1"
},
"scripts": {
"ns-bundle": "ns-bundle",
"publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
"generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
"start-android-bundle": "npm run ns-bundle --android --run-app",
"start-ios-bundle": "npm run ns-bundle --ios --run-app",
"build-android-bundle": "npm run ns-bundle --android --build-app",
"build-ios-bundle": "npm run ns-bundle --ios --build-app"
"webpack-sources": "~1.0.1",
"css-loader": "~0.28.7",
"nativescript-worker-loader": "~0.8.1"
}
}
}
129 changes: 103 additions & 26 deletions src/mapbox.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,12 @@ export interface ShowOptions {
}

export interface ShowResult {
ios: any /* MGLMapView */;
android: any /* com.mapbox.mapboxsdk.maps.MapView */;
ios: any
/* MGLMapView */
;
android: any
/* com.mapbox.mapboxsdk.maps.MapView */
;
}

export interface AnimateCameraOptions {
Expand All @@ -261,50 +265,69 @@ export interface AnimateCameraOptions {

export interface MapboxCommonApi {
requestFineLocationPermission(): Promise<any>;

hasFineLocationPermission(): Promise<boolean>;
}

export interface MapboxApi {
show(options: ShowOptions): Promise<ShowResult>;

hide(): Promise<any>;

unhide(): Promise<any>;

destroy(nativeMap?: any): Promise<any>;

setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<any>;

addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<any>;

removeMarkers(options?: any, nativeMap?: any): Promise<any>;

setCenter(options: SetCenterOptions, nativeMap?: any): Promise<any>;

getCenter(nativeMap?: any): Promise<LatLng>;

setZoomLevel(options: SetZoomLevelOptions, nativeMap?: any): Promise<any>;

getZoomLevel(nativeMap?: any): Promise<number>;

setTilt(options: SetTiltOptions, nativeMap?: any): Promise<any>;

getTilt(nativeMap?: any): Promise<number>;

addPolygon(options: AddPolygonOptions, nativeMap?: any): Promise<any>;

addPolyline(options: AddPolylineOptions, nativeMap?: any): Promise<any>;

removePolylines(ids?: Array<any>, nativeMap?: any): Promise<any>;

animateCamera(options: AnimateCameraOptions, nativeMap?: any): Promise<any>;

setOnMapClickListener(listener: (data: LatLng) => void, nativeMap?): Promise<any>;

setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<any>;

setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any>;

setOnCameraMoveListener(listener: () => void, nativeMap?: any): Promise<any>;

setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any>;

setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any>;

requestFineLocationPermission(): Promise<any>;

hasFineLocationPermission(): Promise<boolean>;

getViewport(nativeMap?: any): Promise<Viewport>;

setViewport(options: SetViewportOptions, nativeMap?: any): Promise<any>;

downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<any>;

listOfflineRegions(): Promise<Array<OfflineRegion>>;

deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<any>;

addGeoJsonClustered(options: AddGeoJsonClusteredOptions): Promise<any>;
Expand Down Expand Up @@ -369,26 +392,47 @@ export abstract class MapboxCommon implements MapboxCommonApi {
export interface MapboxViewApi {
// these functions can be called after the mapReady event fired
addMarkers(markers: MapboxMarker[]): Promise<any>;

removeMarkers(options?: any): Promise<any>;

setOnMapClickListener(listener: (data: LatLng) => void): Promise<any>;

setOnScrollListener(listener: (data?: LatLng) => void): Promise<any>;

setOnFlingListener(listener: () => void): Promise<any>;

setOnCameraMoveListener(listener: () => void): Promise<any>;

setOnCameraMoveCancelListener(listener: () => void): Promise<any>;

setOnCameraIdleListener(listener: () => void): Promise<any>;

getViewport(): Promise<Viewport>;

setViewport(options: SetViewportOptions): Promise<any>;

setMapStyle(style: string | MapStyle): Promise<any>;

getCenter(): Promise<LatLng>;

setCenter(options: SetCenterOptions): Promise<any>;

getZoomLevel(): Promise<number>;

setZoomLevel(options: SetZoomLevelOptions): Promise<any>;

getTilt(): Promise<number>;

setTilt(options: SetTiltOptions): Promise<any>;

addPolygon(options: AddPolygonOptions): Promise<any>;

addPolyline(options: AddPolylineOptions): Promise<any>;

removePolylines(ids?: Array<any>): Promise<any>;

animateCamera(options: AnimateCameraOptions): Promise<any>;

destroy(): Promise<any>;
}

Expand All @@ -409,24 +453,24 @@ export abstract class MapboxViewCommonBase extends View implements MapboxViewApi
return this.mapbox.setOnMapClickListener(listener, this.getNativeMapView());
}

setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<any>{
return this.mapbox.setOnScrollListener(listener, this.getNativeMapView());
setOnScrollListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<any> {
return this.mapbox.setOnScrollListener(listener, this.getNativeMapView());
}

setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any>{
return this.mapbox.setOnFlingListener(listener, this.getNativeMapView());
setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any> {
return this.mapbox.setOnFlingListener(listener, this.getNativeMapView());
}

setOnCameraMoveListener(listener: () => void, nativeMap?: any): Promise<any>{
return this.mapbox.setOnCameraMoveListener(listener, this.getNativeMapView());
setOnCameraMoveListener(listener: () => void, nativeMap?: any): Promise<any> {
return this.mapbox.setOnCameraMoveListener(listener, this.getNativeMapView());
}

setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any>{
return this.mapbox.setOnCameraMoveCancelListener(listener, this.getNativeMapView());
setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any> {
return this.mapbox.setOnCameraMoveCancelListener(listener, this.getNativeMapView());
}

setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any>{
return this.mapbox.setOnCameraIdleListener(listener, this.getNativeMapView());
setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any> {
return this.mapbox.setOnCameraIdleListener(listener, this.getNativeMapView());
}

getViewport(): Promise<Viewport> {
Expand Down Expand Up @@ -486,46 +530,78 @@ export abstract class MapboxViewCommonBase extends View implements MapboxViewApi
}
}

export const zoomLevelProperty = new Property<MapboxViewCommonBase, number>({ name: "zoomLevel" });
export const zoomLevelProperty = new Property<MapboxViewCommonBase, number>({name: "zoomLevel"});
zoomLevelProperty.register(MapboxViewCommonBase);

export const accessTokenProperty = new Property<MapboxViewCommonBase, string>({ name: "accessToken" });
export const accessTokenProperty = new Property<MapboxViewCommonBase, string>({name: "accessToken"});
accessTokenProperty.register(MapboxViewCommonBase);

export const mapStyleProperty = new Property<MapboxViewCommonBase, string>({ name: "mapStyle" });
export const mapStyleProperty = new Property<MapboxViewCommonBase, string>({name: "mapStyle"});
mapStyleProperty.register(MapboxViewCommonBase);

export const latitudeProperty = new Property<MapboxViewCommonBase, number>({ name: "latitude" });
export const latitudeProperty = new Property<MapboxViewCommonBase, number>({name: "latitude"});
latitudeProperty.register(MapboxViewCommonBase);

export const longitudeProperty = new Property<MapboxViewCommonBase, number>({ name: "longitude" });
export const longitudeProperty = new Property<MapboxViewCommonBase, number>({name: "longitude"});
longitudeProperty.register(MapboxViewCommonBase);

export const showUserLocationProperty = new Property<MapboxViewCommonBase, boolean>({ name: "showUserLocation", defaultValue: MapboxCommon.defaults.showUserLocation, valueConverter: booleanConverter });
export const showUserLocationProperty = new Property<MapboxViewCommonBase, boolean>({
name: "showUserLocation",
defaultValue: MapboxCommon.defaults.showUserLocation,
valueConverter: booleanConverter
});
showUserLocationProperty.register(MapboxViewCommonBase);

export const hideLogoProperty = new Property<MapboxViewCommonBase, boolean>({ name: "hideLogo", defaultValue: MapboxCommon.defaults.hideLogo, valueConverter: booleanConverter });
export const hideLogoProperty = new Property<MapboxViewCommonBase, boolean>({
name: "hideLogo",
defaultValue: MapboxCommon.defaults.hideLogo,
valueConverter: booleanConverter
});
hideLogoProperty.register(MapboxViewCommonBase);

export const hideAttributionProperty = new Property<MapboxViewCommonBase, boolean>({ name: "hideAttribution", defaultValue: MapboxCommon.defaults.hideAttribution, valueConverter: booleanConverter });
export const hideAttributionProperty = new Property<MapboxViewCommonBase, boolean>({
name: "hideAttribution",
defaultValue: MapboxCommon.defaults.hideAttribution,
valueConverter: booleanConverter
});
hideAttributionProperty.register(MapboxViewCommonBase);

export const hideCompassProperty = new Property<MapboxViewCommonBase, boolean>({ name: "hideCompass", defaultValue: MapboxCommon.defaults.hideCompass, valueConverter: booleanConverter });
export const hideCompassProperty = new Property<MapboxViewCommonBase, boolean>({
name: "hideCompass",
defaultValue: MapboxCommon.defaults.hideCompass,
valueConverter: booleanConverter
});
hideCompassProperty.register(MapboxViewCommonBase);

export const disableZoomProperty = new Property<MapboxViewCommonBase, boolean>({ name: "disableZoom", defaultValue: MapboxCommon.defaults.disableZoom, valueConverter: booleanConverter });
export const disableZoomProperty = new Property<MapboxViewCommonBase, boolean>({
name: "disableZoom",
defaultValue: MapboxCommon.defaults.disableZoom,
valueConverter: booleanConverter
});
disableZoomProperty.register(MapboxViewCommonBase);

export const disableRotationProperty = new Property<MapboxViewCommonBase, boolean>({ name: "disableRotation", defaultValue: MapboxCommon.defaults.disableRotation, valueConverter: booleanConverter });
export const disableRotationProperty = new Property<MapboxViewCommonBase, boolean>({
name: "disableRotation",
defaultValue: MapboxCommon.defaults.disableRotation,
valueConverter: booleanConverter
});
disableRotationProperty.register(MapboxViewCommonBase);

export const disableScrollProperty = new Property<MapboxViewCommonBase, boolean>({ name: "disableScroll", defaultValue: MapboxCommon.defaults.disableScroll, valueConverter: booleanConverter });
export const disableScrollProperty = new Property<MapboxViewCommonBase, boolean>({
name: "disableScroll",
defaultValue: MapboxCommon.defaults.disableScroll,
valueConverter: booleanConverter
});
disableScrollProperty.register(MapboxViewCommonBase);

export const disableTiltProperty = new Property<MapboxViewCommonBase, boolean>({ name: "disableTilt", defaultValue: MapboxCommon.defaults.disableTilt, valueConverter: booleanConverter });
export const disableTiltProperty = new Property<MapboxViewCommonBase, boolean>({
name: "disableTilt",
defaultValue: MapboxCommon.defaults.disableTilt,
valueConverter: booleanConverter
});
disableTiltProperty.register(MapboxViewCommonBase);

export const delayProperty = new Property<MapboxViewCommonBase, number>({ name: "delay" });
export const delayProperty = new Property<MapboxViewCommonBase, number>({name: "delay"});
delayProperty.register(MapboxViewCommonBase);

export abstract class MapboxViewBase extends MapboxViewCommonBase {
Expand Down Expand Up @@ -610,4 +686,5 @@ export abstract class MapboxViewBase extends MapboxViewCommonBase {
this.config.disableTilt = value;
}
}

/*************** XML definition END ****************/

0 comments on commit 2601995

Please sign in to comment.