@rnmapbox/maps 10.1.35 → 10.1.37-rc.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.
- package/android/src/main/java/com/rnmapbox/rnmbx/RNMBXPackage.kt +1 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt +20 -9
- package/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java +68 -0
- package/lib/commonjs/app.plugin.js +1 -0
- package/lib/commonjs/modules/location/locationManager.js +16 -3
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/commonjs/plugin/build/generateCode.d.ts +42 -0
- package/lib/commonjs/plugin/build/generateCode.js +107 -0
- package/lib/commonjs/plugin/build/withMapbox.d.ts +19 -0
- package/lib/commonjs/plugin/build/withMapbox.js +291 -0
- package/lib/commonjs/plugin/copy-plugin.ts +56 -0
- package/lib/commonjs/plugin/install.md +110 -0
- package/lib/commonjs/plugin/jest.config.js +1 -0
- package/lib/commonjs/plugin/src/generateCode.ts +155 -0
- package/lib/commonjs/plugin/src/withMapbox.ts +466 -0
- package/lib/commonjs/plugin/tsconfig.eslint.json +5 -0
- package/lib/commonjs/plugin/tsconfig.json +9 -0
- package/lib/commonjs/specs/NativeRNMBXLocationModule.js +9 -0
- package/lib/commonjs/specs/NativeRNMBXLocationModule.js.map +1 -0
- package/lib/module/modules/location/locationManager.js +16 -4
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/module/specs/NativeRNMBXLocationModule.js +5 -0
- package/lib/module/specs/NativeRNMBXLocationModule.js.map +1 -0
- package/lib/typescript/src/modules/location/locationManager.d.ts +2 -2
- package/lib/typescript/src/modules/location/locationManager.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts +29 -0
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts.map +1 -0
- package/package.json +5 -13
- package/plugin/copy-plugin.ts +56 -0
- package/plugin/tsconfig.eslint.json +5 -0
- package/src/modules/location/locationManager.ts +20 -9
- package/src/specs/NativeRNMBXLocationModule.ts +32 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
const rootDir = path.resolve(__dirname, '..');
|
|
5
|
+
const destDir = path.resolve(rootDir, 'lib/commonjs');
|
|
6
|
+
const pluginDir = path.resolve(rootDir, 'plugin');
|
|
7
|
+
const appPluginFile = path.resolve(rootDir, 'app.plugin.js');
|
|
8
|
+
|
|
9
|
+
function copyFileSync(source: string, target: string) {
|
|
10
|
+
let targetFile = target;
|
|
11
|
+
|
|
12
|
+
// If target is a directory, a new file with the same name will be created
|
|
13
|
+
if (fs.existsSync(target)) {
|
|
14
|
+
if (fs.lstatSync(target).isDirectory()) {
|
|
15
|
+
targetFile = path.join(target, path.basename(source));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fs.writeFileSync(targetFile, fs.readFileSync(source));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function copyFolderRecursiveSync(source: string, target: string) {
|
|
23
|
+
let files = [];
|
|
24
|
+
|
|
25
|
+
// Check if folder needs to be created or integrated
|
|
26
|
+
const targetFolder = path.join(target, path.basename(source));
|
|
27
|
+
if (!fs.existsSync(targetFolder)) {
|
|
28
|
+
fs.mkdirSync(targetFolder);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Copy
|
|
32
|
+
if (fs.lstatSync(source).isDirectory()) {
|
|
33
|
+
files = fs.readdirSync(source);
|
|
34
|
+
files.forEach((file) => {
|
|
35
|
+
const curSource = path.join(source, file);
|
|
36
|
+
if (fs.lstatSync(curSource).isDirectory()) {
|
|
37
|
+
copyFolderRecursiveSync(curSource, targetFolder);
|
|
38
|
+
} else {
|
|
39
|
+
copyFileSync(curSource, targetFolder);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Ensure destination directory exists
|
|
46
|
+
if (!fs.existsSync(destDir)) {
|
|
47
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Copy app.plugin.js
|
|
51
|
+
copyFileSync(appPluginFile, destDir);
|
|
52
|
+
|
|
53
|
+
// Copy plugin folder
|
|
54
|
+
copyFolderRecursiveSync(pluginDir, destDir);
|
|
55
|
+
|
|
56
|
+
console.log('Files copied successfully.');
|
|
@@ -5,13 +5,18 @@ import {
|
|
|
5
5
|
NativeEventSubscription,
|
|
6
6
|
EmitterSubscription,
|
|
7
7
|
type AppStateStatus,
|
|
8
|
-
|
|
8
|
+
Platform,
|
|
9
|
+
EventSubscription,
|
|
10
|
+
} from 'react-native'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
import NativeRNMBXLocationModule from '../../specs/NativeRNMBXLocationModule'
|
|
13
|
+
|
|
14
|
+
const MapboxGL = NativeModules.RNMBXModule
|
|
15
|
+
const MapboxGLLocationManager: typeof NativeRNMBXLocationModule = Platform.select({ios: NativeModules.RNMBXLocationModule, android: NativeRNMBXLocationModule})
|
|
12
16
|
|
|
13
17
|
export const LocationModuleEventEmitter = new NativeEventEmitter(
|
|
14
|
-
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
MapboxGLLocationManager as any,
|
|
15
20
|
);
|
|
16
21
|
|
|
17
22
|
/**
|
|
@@ -74,7 +79,7 @@ export class LocationManager {
|
|
|
74
79
|
_lastKnownLocation: Location | null;
|
|
75
80
|
_isListening: boolean;
|
|
76
81
|
_requestsAlwaysUse: boolean;
|
|
77
|
-
subscription: EmitterSubscription | null;
|
|
82
|
+
subscription: EmitterSubscription | EventSubscription | null;
|
|
78
83
|
_appStateListener: NativeEventSubscription;
|
|
79
84
|
_minDisplacement?: number;
|
|
80
85
|
|
|
@@ -167,10 +172,16 @@ export class LocationManager {
|
|
|
167
172
|
if (!this._isListening) {
|
|
168
173
|
MapboxGLLocationManager.start(validDisplacement);
|
|
169
174
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
if (Platform.OS === 'ios') {
|
|
176
|
+
this.subscription = LocationModuleEventEmitter.addListener(
|
|
177
|
+
MapboxGL.LocationCallbackName.Update,
|
|
178
|
+
this._onUpdate,
|
|
179
|
+
);
|
|
180
|
+
} else {
|
|
181
|
+
this.subscription = MapboxGLLocationManager.onLocationUpdate((location) => {
|
|
182
|
+
this._onUpdate(location.payload);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
174
185
|
|
|
175
186
|
this._isListening = true;
|
|
176
187
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TurboModule, TurboModuleRegistry} from "react-native";
|
|
2
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
|
|
4
|
+
type LocationEvent = {
|
|
5
|
+
type: string //"userlocationdupdated"
|
|
6
|
+
payload: {
|
|
7
|
+
coords: {
|
|
8
|
+
latitude: number
|
|
9
|
+
longitude: number
|
|
10
|
+
altitude: number
|
|
11
|
+
accuracy: number
|
|
12
|
+
speed: number
|
|
13
|
+
heading: number
|
|
14
|
+
}
|
|
15
|
+
timestamp: number
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface Spec extends TurboModule {
|
|
20
|
+
start(minDisplacement: number): void
|
|
21
|
+
stop(): void
|
|
22
|
+
setRequestsAlwaysUse(requestsAlwaysUse: boolean): void
|
|
23
|
+
setMinDisplacement(minDisplacement: number): void
|
|
24
|
+
getLastKnownLocation(): Promise<LocationEvent['payload']>
|
|
25
|
+
simulateHeading(changesPerSecond: number, increment: number): void
|
|
26
|
+
setLocationEventThrottle(throttle: number): void
|
|
27
|
+
|
|
28
|
+
readonly onLocationUpdate: EventEmitter<LocationEvent>
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('RNMBXLocationModule');
|
|
32
|
+
|