react-native-nitro-geolocation 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE +4 -1
  2. package/README.md +598 -0
  3. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +341 -0
  4. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +76 -5
  5. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/RequestAuthorization.kt +164 -0
  6. package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +228 -0
  7. package/ios/LocationManager.swift +529 -0
  8. package/ios/NitroGeolocation.swift +96 -2
  9. package/nitrogen/generated/.gitattributes +1 -0
  10. package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +62 -0
  11. package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
  12. package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +77 -0
  13. package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +79 -0
  14. package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +77 -0
  15. package/nitrogen/generated/android/c++/JGeolocationError.hpp +69 -0
  16. package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +77 -0
  17. package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +59 -0
  18. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -0
  19. package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +69 -0
  20. package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +62 -0
  21. package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +69 -0
  22. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +22 -0
  23. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +81 -0
  24. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +81 -0
  25. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +81 -0
  26. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +47 -0
  27. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +41 -0
  28. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +47 -0
  29. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +32 -0
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +87 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +22 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +38 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/nitrogeolocationOnLoad.kt +35 -0
  34. package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +81 -0
  35. package/nitrogen/generated/android/nitrogeolocation+autolinking.gradle +27 -0
  36. package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +50 -0
  37. package/nitrogen/generated/android/nitrogeolocationOnLoad.hpp +25 -0
  38. package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +60 -0
  39. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +56 -0
  40. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +252 -0
  41. package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +67 -0
  42. package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +33 -0
  43. package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +25 -0
  44. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.cpp +11 -0
  45. package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +125 -0
  46. package/nitrogen/generated/ios/swift/AuthorizationLevelInternal.swift +44 -0
  47. package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
  48. package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +47 -0
  49. package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +47 -0
  50. package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +149 -0
  51. package/nitrogen/generated/ios/swift/GeolocationError.swift +79 -0
  52. package/nitrogen/generated/ios/swift/GeolocationOptions.swift +185 -0
  53. package/nitrogen/generated/ios/swift/GeolocationResponse.swift +46 -0
  54. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +54 -0
  55. package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +236 -0
  56. package/nitrogen/generated/ios/swift/LocationProviderInternal.swift +44 -0
  57. package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +104 -0
  58. package/nitrogen/generated/shared/c++/AuthorizationLevelInternal.hpp +80 -0
  59. package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +91 -0
  60. package/nitrogen/generated/shared/c++/GeolocationError.hpp +83 -0
  61. package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +91 -0
  62. package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +72 -0
  63. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +26 -0
  64. package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +79 -0
  65. package/nitrogen/generated/shared/c++/LocationProviderInternal.hpp +80 -0
  66. package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +84 -0
  67. package/package.json +34 -10
  68. package/src/NitroGeolocation.nitro.ts +38 -3
  69. package/src/NitroGeolocationModule.ts +5 -0
  70. package/src/clearWatch.ts +13 -0
  71. package/src/getCurrentPosition.ts +14 -0
  72. package/src/index.tsx +32 -7
  73. package/src/requestAuthorization.ts +9 -0
  74. package/src/setRNConfiguration.ts +22 -0
  75. package/src/stopObserving.ts +12 -0
  76. package/src/types.ts +43 -0
  77. package/src/watchPosition.ts +26 -0
  78. package/nitro.json +0 -17
  79. package/turbo.json +0 -42
@@ -0,0 +1,22 @@
1
+ import type { RNConfigurationInternal } from "./NitroGeolocation.nitro";
2
+ import { NitroGeolocationHybridObject } from "./NitroGeolocationModule";
3
+ import type { GeolocationConfiguration } from "./types";
4
+
5
+ // Mapping layer: convert "android" to "android_platform" for C++
6
+ function mapConfigToInternal(
7
+ config: GeolocationConfiguration
8
+ ): RNConfigurationInternal {
9
+ return {
10
+ skipPermissionRequests: config.skipPermissionRequests,
11
+ authorizationLevel: config.authorizationLevel,
12
+ enableBackgroundLocationUpdates: config.enableBackgroundLocationUpdates,
13
+ locationProvider:
14
+ config.locationProvider === "android"
15
+ ? "android_platform"
16
+ : config.locationProvider
17
+ };
18
+ }
19
+
20
+ export function setRNConfiguration(config: GeolocationConfiguration): void {
21
+ NitroGeolocationHybridObject.setRNConfiguration(mapConfigToInternal(config));
22
+ }
@@ -0,0 +1,12 @@
1
+ import { NitroModules } from "react-native-nitro-modules";
2
+ import type { NitroGeolocation } from "./NitroGeolocation.nitro";
3
+
4
+ /**
5
+ * Stops observing all location updates.
6
+ * This will clear all active watch sessions.
7
+ */
8
+ export function stopObserving(): void {
9
+ const nitroGeolocation =
10
+ NitroModules.createHybridObject<NitroGeolocation>("NitroGeolocation");
11
+ nitroGeolocation.stopObserving();
12
+ }
package/src/types.ts ADDED
@@ -0,0 +1,43 @@
1
+ // Public API types (compatible with @react-native-community/geolocation)
2
+ export type AuthorizationLevel = "always" | "whenInUse" | "auto";
3
+ export type LocationProvider = "playServices" | "android" | "auto";
4
+
5
+ export interface GeolocationConfiguration {
6
+ skipPermissionRequests: boolean;
7
+ authorizationLevel?: AuthorizationLevel;
8
+ enableBackgroundLocationUpdates?: boolean;
9
+ locationProvider?: LocationProvider;
10
+ }
11
+
12
+ export interface GeolocationCoordinates {
13
+ latitude: number;
14
+ longitude: number;
15
+ altitude: number | null;
16
+ accuracy: number;
17
+ altitudeAccuracy: number | null;
18
+ heading: number | null;
19
+ speed: number | null;
20
+ }
21
+
22
+ export interface GeolocationResponse {
23
+ coords: GeolocationCoordinates;
24
+ timestamp: number;
25
+ }
26
+
27
+ export interface GeolocationError {
28
+ code: number;
29
+ message: string;
30
+ PERMISSION_DENIED: number;
31
+ POSITION_UNAVAILABLE: number;
32
+ TIMEOUT: number;
33
+ }
34
+
35
+ export interface GeolocationOptions {
36
+ timeout?: number;
37
+ maximumAge?: number;
38
+ enableHighAccuracy?: boolean;
39
+ interval?: number;
40
+ fastestInterval?: number;
41
+ distanceFilter?: number;
42
+ useSignificantChanges?: boolean;
43
+ }
@@ -0,0 +1,26 @@
1
+ import { NitroModules } from "react-native-nitro-modules";
2
+ import type { NitroGeolocation } from "./NitroGeolocation.nitro";
3
+ import type {
4
+ GeolocationError,
5
+ GeolocationOptions,
6
+ GeolocationResponse
7
+ } from "./types";
8
+
9
+ /**
10
+ * Invokes the success callback whenever the location changes.
11
+ * Returns a watchId (number) that can be used with clearWatch().
12
+ *
13
+ * @param success - Called whenever the location changes
14
+ * @param error - Called if an error occurs
15
+ * @param options - Configuration options for watching position
16
+ * @returns watchId - A number that identifies this watch session
17
+ */
18
+ export function watchPosition(
19
+ success: (position: GeolocationResponse) => void,
20
+ error?: (error: GeolocationError) => void,
21
+ options?: GeolocationOptions
22
+ ): number {
23
+ const nitroGeolocation =
24
+ NitroModules.createHybridObject<NitroGeolocation>("NitroGeolocation");
25
+ return nitroGeolocation.watchPosition(success, error, options);
26
+ }
package/nitro.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "cxxNamespace": ["nitrogeolocation"],
3
- "ios": {
4
- "iosModuleName": "NitroGeolocation"
5
- },
6
- "android": {
7
- "androidNamespace": ["nitrogeolocation"],
8
- "androidCxxLibName": "nitrogeolocation"
9
- },
10
- "autolinking": {
11
- "NitroGeolocation": {
12
- "swift": "NitroGeolocation",
13
- "kotlin": "NitroGeolocation"
14
- }
15
- },
16
- "ignorePaths": ["node_modules"]
17
- }
package/turbo.json DELETED
@@ -1,42 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "globalDependencies": [".nvmrc", ".yarnrc.yml"],
4
- "globalEnv": ["NODE_ENV"],
5
- "tasks": {
6
- "build:android": {
7
- "env": ["ANDROID_HOME", "ORG_GRADLE_PROJECT_newArchEnabled"],
8
- "inputs": [
9
- "package.json",
10
- "android",
11
- "!android/build",
12
- "src/*.ts",
13
- "src/*.tsx",
14
- "example/package.json",
15
- "example/android",
16
- "!example/android/.gradle",
17
- "!example/android/build",
18
- "!example/android/app/build"
19
- ],
20
- "outputs": []
21
- },
22
- "build:ios": {
23
- "env": [
24
- "RCT_NEW_ARCH_ENABLED",
25
- "RCT_USE_RN_DEP",
26
- "RCT_USE_PREBUILT_RNCORE"
27
- ],
28
- "inputs": [
29
- "package.json",
30
- "*.podspec",
31
- "ios",
32
- "src/*.ts",
33
- "src/*.tsx",
34
- "example/package.json",
35
- "example/ios",
36
- "!example/ios/build",
37
- "!example/ios/Pods"
38
- ],
39
- "outputs": []
40
- }
41
- }
42
- }