From 0b695150879402b0d971c5d2614a68a33aec6870 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Wed, 5 Aug 2020 23:59:41 -0700 Subject: [PATCH] chore: dep updates --- .gitignore | 2 ++ src/.npmignore | 3 ++- src/geolocation.android.ts | 26 ++++++++++++-------------- src/geolocation.ios.ts | 16 +++++++--------- src/package.json | 21 ++++++++++++--------- src/references.d.ts | 5 +++-- src/tsconfig.json | 14 ++++++-------- 7 files changed, 44 insertions(+), 43 deletions(-) diff --git a/.gitignore b/.gitignore index 5fcf31d..85c3842 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ publish/src publish/package src/platforms/android/nativescript_geolocation.aar !demo-vue/app/app.js +package-lock.json +*.tgz diff --git a/src/.npmignore b/src/.npmignore index c06aedb..2facde1 100644 --- a/src/.npmignore +++ b/src/.npmignore @@ -4,4 +4,5 @@ tsconfig.json /platforms/android/**/* !platforms/android/include.gradle -!platforms/android/nativescript_geolocation.aar \ No newline at end of file +!platforms/android/nativescript_geolocation.aar +*.tgz \ No newline at end of file diff --git a/src/geolocation.android.ts b/src/geolocation.android.ts index e003613..8fb24f0 100644 --- a/src/geolocation.android.ts +++ b/src/geolocation.android.ts @@ -1,6 +1,4 @@ -import { on as applicationOn, android as androidAppInstance, AndroidApplication, uncaughtErrorEvent, UnhandledErrorEventData } from "application"; -import { Accuracy } from "tns-core-modules/ui/enums"; -import { setTimeout, clearTimeout } from "tns-core-modules/timer"; +import { Enums, Application, UnhandledErrorEventData, AndroidApplication } from "@nativescript/core"; import { LocationBase, defaultGetLocationTimeout, fastestTimeUpdate, minTimeUpdate } from "./geolocation.common"; import { Options, successCallbackType, errorCallbackType } from "./location-monitor"; import * as permissions from "nativescript-permissions"; @@ -18,10 +16,10 @@ let attachedForErrorHandling = false; function _ensureLocationClient() { // Wrapped in a function as we should not access java object there because of the snapshots. fusedLocationClient = fusedLocationClient || - com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(androidAppInstance.context); + com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Application.android.context); } -androidAppInstance.on(AndroidApplication.activityResultEvent, function (args: any) { +Application.android.on(AndroidApplication.activityResultEvent, function (args: any) { if (args.requestCode === REQUEST_ENABLE_LOCATION) { if (args.resultCode === 0) { if (_onEnableLocationFail) { @@ -34,13 +32,13 @@ androidAppInstance.on(AndroidApplication.activityResultEvent, function (args: an }); function isAirplaneModeOn(): boolean { - return android.provider.Settings.System.getInt(androidAppInstance.context.getContentResolver(), + return android.provider.Settings.System.getInt(Application.android.context.getContentResolver(), android.provider.Settings.System.AIRPLANE_MODE_ON) !== 0; } function isProviderEnabled(provider: string): boolean { try { - const locationManager: android.location.LocationManager = (androidAppInstance.context) + const locationManager: android.location.LocationManager = (Application.android.context) .getSystemService(android.content.Context.LOCATION_SERVICE); return locationManager.isProviderEnabled(provider); } catch (ex) { @@ -115,7 +113,7 @@ function _getLocationRequest(options: Options): any { if (options.updateDistance) { mLocationRequest.setSmallestDisplacement(options.updateDistance); } - if (options.desiredAccuracy === Accuracy.high) { + if (options.desiredAccuracy === Enums.Accuracy.high) { mLocationRequest.setPriority(com.google.android.gms.location.LocationRequest.PRIORITY_HIGH_ACCURACY); } else { mLocationRequest.setPriority(com.google.android.gms.location.LocationRequest.PRIORITY_BALANCED_POWER_ACCURACY); @@ -178,7 +176,7 @@ export function watchLocation(successCallback: successCallbackType, errorCallbac if (!attachedForErrorHandling) { attachedForErrorHandling = true; - applicationOn(uncaughtErrorEvent, errorHandler.bind(this)); + Application.on(Application.uncaughtErrorEvent, errorHandler.bind(this)); } let locationRequest = _getLocationRequest(options); @@ -215,7 +213,7 @@ export function enableLocationRequest(always?: boolean): Promise { // on REQUEST_ENABLE_LOCATION Activity Result _onEnableLocationSuccess = resolve; _onEnableLocationFail = reject; - return ex.startResolutionForResult(androidAppInstance.foregroundActivity, REQUEST_ENABLE_LOCATION); + return ex.startResolutionForResult(Application.android.foregroundActivity, REQUEST_ENABLE_LOCATION); } catch (sendEx) { // Ignore the error. return resolve(); @@ -240,7 +238,7 @@ function _makeGooglePlayServicesAvailable(): Promise { return; } let googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance(); - googleApiAvailability.makeGooglePlayServicesAvailable(androidAppInstance.foregroundActivity) + googleApiAvailability.makeGooglePlayServicesAvailable(Application.android.foregroundActivity) .addOnSuccessListener(_getTaskSuccessListener(resolve)) .addOnFailureListener(_getTaskFailListener(reject)); }); @@ -253,7 +251,7 @@ function _isGooglePlayServicesAvailable(): boolean { let isLocationServiceEnabled = true; let googleApiAvailability = com.google.android.gms.common.GoogleApiAvailability.getInstance(); - let resultCode = googleApiAvailability.isGooglePlayServicesAvailable(androidAppInstance.context); + let resultCode = googleApiAvailability.isGooglePlayServicesAvailable(Application.android.context); if (resultCode !== com.google.android.gms.common.ConnectionResult.SUCCESS) { isLocationServiceEnabled = false; } @@ -268,12 +266,12 @@ function _isLocationServiceEnabled(options?: Options): Promise { return; } - options = options || { desiredAccuracy: Accuracy.high, updateTime: 0, updateDistance: 0, maximumAge: 0, timeout: 0 }; + options = options || { desiredAccuracy: Enums.Accuracy.high, updateTime: 0, updateDistance: 0, maximumAge: 0, timeout: 0 }; let locationRequest = _getLocationRequest(options); let locationSettingsBuilder = new com.google.android.gms.location.LocationSettingsRequest.Builder(); locationSettingsBuilder.addLocationRequest(locationRequest); locationSettingsBuilder.setAlwaysShow(true); - let locationSettingsClient = com.google.android.gms.location.LocationServices.getSettingsClient(androidAppInstance.context); + let locationSettingsClient = com.google.android.gms.location.LocationServices.getSettingsClient(Application.android.context); locationSettingsClient.checkLocationSettings(locationSettingsBuilder.build()) .addOnSuccessListener(_getTaskSuccessListener(resolve)) .addOnFailureListener(_getTaskFailListener(reject)); diff --git a/src/geolocation.ios.ts b/src/geolocation.ios.ts index 531e263..9f65c83 100644 --- a/src/geolocation.ios.ts +++ b/src/geolocation.ios.ts @@ -1,6 +1,4 @@ -import { Accuracy } from "tns-core-modules/ui/enums"; -import { setTimeout, clearTimeout } from "tns-core-modules/timer"; -import { on as applicationOn, uncaughtErrorEvent, UnhandledErrorEventData } from "tns-core-modules/application"; +import { Application, Enums, UnhandledErrorEventData, Device } from "@nativescript/core"; import { LocationBase, @@ -12,13 +10,13 @@ import { successCallbackType, errorCallbackType } from "./location-monitor"; -import * as Platform from "platform"; const locationManagers = {}; const locationListeners = {}; let watchId = 0; let attachedForErrorHandling = false; +@NativeClass() class LocationListenerImpl extends NSObject implements CLLocationManagerDelegate { public static ObjCProtocols = [CLLocationManagerDelegate]; // tslint:disable-line:variable-name @@ -140,7 +138,7 @@ function errorHandler(errData: UnhandledErrorEventData) { } function getVersionMaj () { - return parseInt(Platform.device.osVersion.split(".")[0]); + return parseInt(Device.osVersion.split(".")[0]); } // options - desiredAccuracy, updateDistance, minimumUpdateTime, maximumAge, timeout @@ -184,7 +182,7 @@ export function getCurrentLocation(options: Options): Promise { return; } - if (options.desiredAccuracy !== Accuracy.any && !initLocation) { + if (options.desiredAccuracy !== Enums.Accuracy.any && !initLocation) { // regardless of desired accuracy ios returns first location as quick as possible even if not as accurate as requested initLocation = location; return; @@ -223,7 +221,7 @@ export function watchLocation(successCallback: successCallbackType, options: Options): number { if (!attachedForErrorHandling) { attachedForErrorHandling = true; - applicationOn(uncaughtErrorEvent, errorHandler.bind(this)); + Application.on(Application.uncaughtErrorEvent, errorHandler.bind(this)); } let zonedSuccessCallback = (global).zonedCallback(successCallback); @@ -359,7 +357,7 @@ export class LocationMonitor { static createiOSLocationManager(locListener: any, options: Options): CLLocationManager { let iosLocManager = new CLLocationManager(); iosLocManager.delegate = locListener; - iosLocManager.desiredAccuracy = options ? options.desiredAccuracy : Accuracy.high; + iosLocManager.desiredAccuracy = options ? options.desiredAccuracy : Enums.Accuracy.high; iosLocManager.distanceFilter = options ? options.updateDistance : minRangeUpdate; locationManagers[locListener.id] = iosLocManager; locationListeners[locListener.id] = locListener; @@ -384,7 +382,7 @@ function getIOSLocationManager(locListener: any, options: Options): CLLocationMa let manager = new iosLocationManager(); manager.delegate = locListener; - manager.desiredAccuracy = options ? options.desiredAccuracy : Accuracy.high; + manager.desiredAccuracy = options ? options.desiredAccuracy : Enums.Accuracy.high; manager.distanceFilter = options ? options.updateDistance : minRangeUpdate; locationManagers[locListener.id] = manager; diff --git a/src/package.json b/src/package.json index c25a68d..a44f02c 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { - "name": "nativescript-geolocation", - "version": "5.1.0", + "name": "@nativescript/geolocation", + "version": "7.0.0", "description": "Provides API for getting and monitoring location for NativeScript app.", "main": "geolocation", "typings": "index.d.ts", @@ -12,7 +12,7 @@ }, "scripts": { "tsc": "tsc -skipLibCheck", - "build": "npm i && tsc", + "build": "npm i && ts-patch install && tsc", "test.android": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build android && tns test android --justlaunch", "test.ios": "npm i && npm run tsc && npm run tslint && cd ../demo && tns build ios && tns test ios --justlaunch", "tslint": "cd .. && tslint \"**/*.ts\" --config tslint.json --exclude \"**/node_modules/**\" --exclude \"*demo*/platforms/**\"", @@ -38,15 +38,18 @@ "homepage": "https://github.com/NativeScript/nativescript-geolocation", "readmeFilename": "README.md", "devDependencies": { - "tns-core-modules": "^5.0.0", - "tns-platform-declarations": "^5.0.0", - "typescript": "~3.1.6", + "@nativescript/core": "rc", + "@nativescript/types": "rc", + "@nativescript/webpack": "~2.1.3", + "typescript": "~3.9.0", "prompt": "~1.0.0", - "rimraf": "~2.6.2", - "tslint": "~5.11.0" + "rimraf": "~3.0.2", + "tslint": "~6.1.3", + "ts-patch": "~1.3.0" }, "dependencies": { - "nativescript-permissions": "~1.3.0" + "nativescript-permissions": "~1.3.0", + "ts-node": "^8.10.2" }, "bootstrapper": "nativescript-plugin-seed" } diff --git a/src/references.d.ts b/src/references.d.ts index 1e5e961..a4d2ba5 100644 --- a/src/references.d.ts +++ b/src/references.d.ts @@ -1,2 +1,3 @@ -/// -/// +/// +/// +/// diff --git a/src/tsconfig.json b/src/tsconfig.json index 8110abf..28326fd 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { - "target": "es5", - "module": "commonjs", + "target": "es2017", + "module": "esnext", + "moduleResolution": "node", "declaration": false, "removeComments": true, "preserveConstEnums": true, @@ -20,12 +21,9 @@ "noImplicitUseStrict": false, "noFallthroughCasesInSwitch": true, "baseUrl": ".", - "paths": { - "*": [ - "./node_modules/tns-core-modules/*", - "./node_modules/*" - ] - } + "plugins": [ + { "transform": "@nativescript/webpack/transformers/ns-transform-native-classes", "type": "raw" } + ] }, "exclude": [ "node_modules",