expo-gaode-map 2.2.32 → 2.2.33
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/README.md +2 -3
- package/android/src/main/cpp/cluster_jni.cpp +56 -0
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapModule.kt +45 -6
- package/android/src/main/java/expo/modules/gaodemap/ExpoGaodeMapOfflineModule.kt +1 -1
- package/android/src/main/java/expo/modules/gaodemap/modules/SDKInitializer.kt +23 -17
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerBitmapRenderer.kt +30 -16
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerView.kt +36 -31
- package/android/src/main/java/expo/modules/gaodemap/overlays/MarkerViewModule.kt +6 -6
- package/android/src/main/java/expo/modules/gaodemap/utils/GeometryUtils.kt +103 -0
- package/build/ExpoGaodeMapModule.d.ts +9 -259
- package/build/ExpoGaodeMapModule.d.ts.map +1 -1
- package/build/ExpoGaodeMapModule.js +19 -910
- package/build/ExpoGaodeMapModule.js.map +1 -1
- package/build/ExpoGaodeMapView.d.ts +3 -4
- package/build/ExpoGaodeMapView.d.ts.map +1 -1
- package/build/ExpoGaodeMapView.js +28 -25
- package/build/ExpoGaodeMapView.js.map +1 -1
- package/build/components/overlays/Circle.d.ts.map +1 -1
- package/build/components/overlays/Circle.js +1 -30
- package/build/components/overlays/Circle.js.map +1 -1
- package/build/components/overlays/Cluster.d.ts.map +1 -1
- package/build/components/overlays/Cluster.js +1 -42
- package/build/components/overlays/Cluster.js.map +1 -1
- package/build/components/overlays/HeatMap.d.ts.map +1 -1
- package/build/components/overlays/HeatMap.js +1 -20
- package/build/components/overlays/HeatMap.js.map +1 -1
- package/build/components/overlays/Marker.d.ts.map +1 -1
- package/build/components/overlays/Marker.js +14 -80
- package/build/components/overlays/Marker.js.map +1 -1
- package/build/components/overlays/Polygon.d.ts.map +1 -1
- package/build/components/overlays/Polygon.js +1 -25
- package/build/components/overlays/Polygon.js.map +1 -1
- package/build/components/overlays/Polyline.d.ts.map +1 -1
- package/build/components/overlays/Polyline.js +1 -31
- package/build/components/overlays/Polyline.js.map +1 -1
- package/build/index.d.ts +6 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +6 -2
- package/build/index.js.map +1 -1
- package/build/module/geometry.d.ts +183 -0
- package/build/module/geometry.d.ts.map +1 -0
- package/build/module/geometry.js +374 -0
- package/build/module/geometry.js.map +1 -0
- package/build/module/location.d.ts +49 -0
- package/build/module/location.d.ts.map +1 -0
- package/build/module/location.js +257 -0
- package/build/module/location.js.map +1 -0
- package/build/module/nativeModule.d.ts +5 -0
- package/build/module/nativeModule.d.ts.map +1 -0
- package/build/module/nativeModule.js +34 -0
- package/build/module/nativeModule.js.map +1 -0
- package/build/module/normalizers.d.ts +9 -0
- package/build/module/normalizers.d.ts.map +1 -0
- package/build/module/normalizers.js +109 -0
- package/build/module/normalizers.js.map +1 -0
- package/build/module/privacy.d.ts +20 -0
- package/build/module/privacy.d.ts.map +1 -0
- package/build/module/privacy.js +59 -0
- package/build/module/privacy.js.map +1 -0
- package/build/module/sdk.d.ts +20 -0
- package/build/module/sdk.d.ts.map +1 -0
- package/build/module/sdk.js +82 -0
- package/build/module/sdk.js.map +1 -0
- package/build/types/index.d.ts +1 -1
- package/build/types/index.js.map +1 -1
- package/build/types/native-module.types.d.ts +12 -16
- package/build/types/native-module.types.d.ts.map +1 -1
- package/build/types/native-module.types.js.map +1 -1
- package/build/types/overlays.types.d.ts +0 -16
- package/build/types/overlays.types.d.ts.map +1 -1
- package/build/types/overlays.types.js.map +1 -1
- package/build/types/route-playback.types.d.ts +3 -0
- package/build/types/route-playback.types.d.ts.map +1 -1
- package/build/types/route-playback.types.js.map +1 -1
- package/build/utils/RouteUtils.d.ts +1 -1
- package/build/utils/RouteUtils.d.ts.map +1 -1
- package/build/utils/RouteUtils.js +35 -1
- package/build/utils/RouteUtils.js.map +1 -1
- package/ios/ExpoGaodeMapModule.swift +38 -6
- package/ios/ExpoGaodeMapView.swift +10 -3
- package/ios/GaodeMapPrivacyManager.swift +26 -18
- package/ios/modules/LocationManager.swift +1 -1
- package/ios/overlays/MarkerView.swift +36 -25
- package/ios/overlays/MarkerViewModule.swift +4 -4
- package/ios/utils/ClusterNative.h +8 -0
- package/ios/utils/ClusterNative.mm +27 -0
- package/package.json +3 -1
- package/scripts/check-expo-modules.js +68 -0
- package/shared/cpp/GeometryEngine.cpp +112 -0
- package/shared/cpp/GeometryEngine.hpp +21 -0
- package/shared/cpp/tests/test_main.cpp +15 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
import { ErrorHandler, ErrorLogger } from '../utils/ErrorHandler';
|
|
3
|
+
import { normalizeLatLng } from '../utils/GeoUtils';
|
|
4
|
+
import { getNativeModule } from './nativeModule';
|
|
5
|
+
import { normalizeCoordinateType, normalizeGeoLanguage, normalizeHeadingEvent, normalizeLocationResult, normalizePermissionStatus, } from './normalizers';
|
|
6
|
+
import { assertPrivacyReady } from './privacy';
|
|
7
|
+
export const locationMethods = {
|
|
8
|
+
start() {
|
|
9
|
+
assertPrivacyReady('sdk');
|
|
10
|
+
const nativeModule = getNativeModule(true);
|
|
11
|
+
if (!nativeModule)
|
|
12
|
+
return;
|
|
13
|
+
try {
|
|
14
|
+
nativeModule.start();
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
ErrorLogger.warn('start 失败', { error });
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
stop() {
|
|
21
|
+
assertPrivacyReady('sdk');
|
|
22
|
+
const nativeModule = getNativeModule(true);
|
|
23
|
+
if (!nativeModule)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
nativeModule.stop();
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
ErrorLogger.warn('stop 失败', { error });
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
isStarted() {
|
|
33
|
+
assertPrivacyReady('sdk');
|
|
34
|
+
const nativeModule = getNativeModule(true);
|
|
35
|
+
if (!nativeModule)
|
|
36
|
+
return Promise.resolve(false);
|
|
37
|
+
try {
|
|
38
|
+
return nativeModule.isStarted();
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
ErrorLogger.warn('isStarted 失败', { error });
|
|
42
|
+
return Promise.resolve(false);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
async getCurrentLocation() {
|
|
46
|
+
assertPrivacyReady('sdk');
|
|
47
|
+
const nativeModule = getNativeModule();
|
|
48
|
+
if (!nativeModule) {
|
|
49
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const location = await nativeModule.getCurrentLocation();
|
|
53
|
+
return normalizeLocationResult(location);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw ErrorHandler.wrapNativeError(error, '获取当前位置');
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
async coordinateConvert(coordinate, type) {
|
|
60
|
+
assertPrivacyReady('sdk');
|
|
61
|
+
const nativeModule = getNativeModule();
|
|
62
|
+
if (!nativeModule) {
|
|
63
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
const normalizedCoordinate = normalizeLatLng(coordinate);
|
|
67
|
+
const normalizedType = normalizeCoordinateType(type);
|
|
68
|
+
if (normalizedType === null) {
|
|
69
|
+
return normalizedCoordinate;
|
|
70
|
+
}
|
|
71
|
+
return await nativeModule.coordinateConvert(normalizedCoordinate, normalizedType);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw ErrorHandler.wrapNativeError(error, '坐标转换');
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
setGeoLanguage(language) {
|
|
78
|
+
assertPrivacyReady('sdk');
|
|
79
|
+
const nativeModule = getNativeModule(true);
|
|
80
|
+
if (!nativeModule)
|
|
81
|
+
return;
|
|
82
|
+
try {
|
|
83
|
+
nativeModule.setGeoLanguage(normalizeGeoLanguage(language));
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
ErrorLogger.warn('setGeoLanguage 失败', { language, error });
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
setLocatingWithReGeocode(isReGeocode) {
|
|
90
|
+
assertPrivacyReady('sdk');
|
|
91
|
+
const nativeModule = getNativeModule(true);
|
|
92
|
+
if (!nativeModule)
|
|
93
|
+
return;
|
|
94
|
+
try {
|
|
95
|
+
nativeModule.setLocatingWithReGeocode(isReGeocode);
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
ErrorLogger.warn('setLocatingWithReGeocode 失败', { isReGeocode, error });
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
get isBackgroundLocationEnabled() {
|
|
102
|
+
const nativeModule = getNativeModule(true);
|
|
103
|
+
if (!nativeModule)
|
|
104
|
+
return false;
|
|
105
|
+
return nativeModule.isBackgroundLocationEnabled === true;
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* 检查位置权限状态
|
|
109
|
+
*/
|
|
110
|
+
async checkLocationPermission() {
|
|
111
|
+
assertPrivacyReady('sdk');
|
|
112
|
+
const nativeModule = getNativeModule();
|
|
113
|
+
if (!nativeModule) {
|
|
114
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
115
|
+
}
|
|
116
|
+
try {
|
|
117
|
+
return normalizePermissionStatus(await nativeModule.checkLocationPermission());
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw ErrorHandler.wrapNativeError(error, '检查权限');
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* 请求前台位置权限(增强版)
|
|
125
|
+
*/
|
|
126
|
+
async requestLocationPermission() {
|
|
127
|
+
assertPrivacyReady('sdk');
|
|
128
|
+
const nativeModule = getNativeModule();
|
|
129
|
+
if (!nativeModule) {
|
|
130
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
131
|
+
}
|
|
132
|
+
try {
|
|
133
|
+
const result = normalizePermissionStatus(await nativeModule.requestLocationPermission());
|
|
134
|
+
if (!result.granted) {
|
|
135
|
+
ErrorLogger.warn('前台位置权限未授予', result);
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
throw ErrorHandler.wrapNativeError(error, '请求前台权限');
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* 请求后台位置权限
|
|
145
|
+
* 注意:必须在前台权限已授予后才能请求
|
|
146
|
+
*/
|
|
147
|
+
async requestBackgroundLocationPermission() {
|
|
148
|
+
assertPrivacyReady('sdk');
|
|
149
|
+
const nativeModule = getNativeModule();
|
|
150
|
+
if (!nativeModule) {
|
|
151
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
const result = normalizePermissionStatus(await nativeModule.requestBackgroundLocationPermission());
|
|
155
|
+
if (!result.granted) {
|
|
156
|
+
ErrorLogger.warn('后台位置权限未授予', result);
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
throw ErrorHandler.wrapNativeError(error, '请求后台权限');
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
/**
|
|
165
|
+
* 打开应用设置页面
|
|
166
|
+
* 引导用户手动授予权限
|
|
167
|
+
*/
|
|
168
|
+
openAppSettings() {
|
|
169
|
+
const nativeModule = getNativeModule();
|
|
170
|
+
if (!nativeModule) {
|
|
171
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
nativeModule.openAppSettings();
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw ErrorHandler.wrapNativeError(error, '打开设置');
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
setAllowsBackgroundLocationUpdates(allows) {
|
|
181
|
+
assertPrivacyReady('sdk');
|
|
182
|
+
const nativeModule = getNativeModule();
|
|
183
|
+
if (!nativeModule) {
|
|
184
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
185
|
+
}
|
|
186
|
+
if (Platform.OS === 'ios' &&
|
|
187
|
+
allows &&
|
|
188
|
+
nativeModule &&
|
|
189
|
+
nativeModule.isBackgroundLocationEnabled === false) {
|
|
190
|
+
ErrorLogger.warn('⚠️ [ExpoGaodeMap] iOS 后台定位未正确配置,setAllowsBackgroundLocationUpdates(true) 可能不会生效,请检查 Info.plist 是否包含 UIBackgroundModes: location,或者在 app.json 中配置 enableBackgroundLocation: true,然后重新执行 npx expo prebuild');
|
|
191
|
+
}
|
|
192
|
+
if (Platform.OS === 'android' &&
|
|
193
|
+
allows &&
|
|
194
|
+
nativeModule &&
|
|
195
|
+
nativeModule.checkLocationPermission) {
|
|
196
|
+
nativeModule
|
|
197
|
+
.checkLocationPermission()
|
|
198
|
+
.then((status) => {
|
|
199
|
+
if (!status.backgroundLocation) {
|
|
200
|
+
ErrorLogger.warn('⚠️ [ExpoGaodeMap] Android 后台位置权限未授予,setAllowsBackgroundLocationUpdates(true) 可能不会生效,请先通过 requestBackgroundLocationPermission 或系统设置授予后台定位权限,或者检查是否在 app.json 中配置了 enableBackgroundLocation: true,然后重新执行 npx expo prebuild');
|
|
201
|
+
}
|
|
202
|
+
})
|
|
203
|
+
.catch(() => {
|
|
204
|
+
// 忽略检查失败,只影响日志,不影响功能
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
nativeModule.setAllowsBackgroundLocationUpdates(allows);
|
|
208
|
+
},
|
|
209
|
+
/**
|
|
210
|
+
* 添加定位监听器(便捷方法)
|
|
211
|
+
* 自动订阅 onLocationUpdate 事件,提供容错处理
|
|
212
|
+
* @param listener 定位回调函数
|
|
213
|
+
* @returns 订阅对象,调用 remove() 取消监听
|
|
214
|
+
* 注意:如果使用 Config Plugin 配置了 API Key,无需调用 initSDK()
|
|
215
|
+
*/
|
|
216
|
+
addLocationListener(listener) {
|
|
217
|
+
assertPrivacyReady('sdk');
|
|
218
|
+
const module = getNativeModule();
|
|
219
|
+
if (!module) {
|
|
220
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
221
|
+
}
|
|
222
|
+
if (!module.addListener) {
|
|
223
|
+
ErrorLogger.warn('Native module does not support events');
|
|
224
|
+
return {
|
|
225
|
+
remove: () => { },
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
return module.addListener('onLocationUpdate', (location) => {
|
|
229
|
+
listener(normalizeLocationResult(location));
|
|
230
|
+
}) || {
|
|
231
|
+
remove: () => { },
|
|
232
|
+
};
|
|
233
|
+
},
|
|
234
|
+
/**
|
|
235
|
+
* 添加方向监听器(iOS)
|
|
236
|
+
* 自动归一化 heading 事件字段,兼容旧版原生返回结构
|
|
237
|
+
*/
|
|
238
|
+
addHeadingListener(listener) {
|
|
239
|
+
assertPrivacyReady('sdk');
|
|
240
|
+
const module = getNativeModule();
|
|
241
|
+
if (!module) {
|
|
242
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
243
|
+
}
|
|
244
|
+
if (!module.addListener) {
|
|
245
|
+
ErrorLogger.warn('Native module does not support events');
|
|
246
|
+
return {
|
|
247
|
+
remove: () => { },
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
return module.addListener('onHeadingUpdate', (heading) => {
|
|
251
|
+
listener(normalizeHeadingEvent(heading));
|
|
252
|
+
}) || {
|
|
253
|
+
remove: () => { },
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
//# sourceMappingURL=location.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.js","sourceRoot":"","sources":["../../src/module/location.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAA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,EAAE;YACvD,QAAQ,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,IAAI;YACJ,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC;SAClB,CAAC;IACJ,CAAC;CACF,CAAC","sourcesContent":["import { Platform } from 'react-native';\n\nimport type {\n Coordinates,\n CoordinateType,\n GeoLanguage,\n HeadingListener,\n LatLng,\n LatLngPoint,\n LocationListener,\n ReGeocode,\n} from '../types';\nimport type { PermissionStatus } from '../types/common.types';\nimport { ErrorHandler, ErrorLogger } from '../utils/ErrorHandler';\nimport { normalizeLatLng } from '../utils/GeoUtils';\nimport { getNativeModule } from './nativeModule';\nimport {\n normalizeCoordinateType,\n normalizeGeoLanguage,\n normalizeHeadingEvent,\n normalizeLocationResult,\n normalizePermissionStatus,\n} from './normalizers';\nimport { assertPrivacyReady } from './privacy';\n\nexport const locationMethods = {\n start(): void {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return;\n try {\n nativeModule.start();\n } catch (error) {\n ErrorLogger.warn('start 失败', { error });\n }\n },\n\n stop(): void {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return;\n try {\n nativeModule.stop();\n } catch (error) {\n ErrorLogger.warn('stop 失败', { error });\n }\n },\n\n isStarted(): Promise<boolean> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return Promise.resolve(false);\n try {\n return nativeModule.isStarted();\n } catch (error) {\n ErrorLogger.warn('isStarted 失败', { error });\n return Promise.resolve(false);\n }\n },\n\n async getCurrentLocation(): Promise<Coordinates | ReGeocode> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n const location = await nativeModule.getCurrentLocation();\n return normalizeLocationResult(location);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '获取当前位置');\n }\n },\n\n async coordinateConvert(coordinate: LatLngPoint, type: CoordinateType): Promise<LatLng> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n const normalizedCoordinate = normalizeLatLng(coordinate);\n const normalizedType = normalizeCoordinateType(type);\n\n if (normalizedType === null) {\n return normalizedCoordinate;\n }\n\n return await nativeModule.coordinateConvert(normalizedCoordinate, normalizedType);\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '坐标转换');\n }\n },\n\n setGeoLanguage(language: GeoLanguage | string): void {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return;\n try {\n nativeModule.setGeoLanguage(normalizeGeoLanguage(language));\n } catch (error) {\n ErrorLogger.warn('setGeoLanguage 失败', { language, error });\n }\n },\n\n setLocatingWithReGeocode(isReGeocode: boolean): void {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return;\n try {\n nativeModule.setLocatingWithReGeocode(isReGeocode);\n } catch (error) {\n ErrorLogger.warn('setLocatingWithReGeocode 失败', { isReGeocode, error });\n }\n },\n\n get isBackgroundLocationEnabled(): boolean {\n const nativeModule = getNativeModule(true);\n if (!nativeModule) return false;\n return nativeModule.isBackgroundLocationEnabled === true;\n },\n\n /**\n * 检查位置权限状态\n */\n async checkLocationPermission(): Promise<PermissionStatus> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n return normalizePermissionStatus(await nativeModule.checkLocationPermission());\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '检查权限');\n }\n },\n\n /**\n * 请求前台位置权限(增强版)\n */\n async requestLocationPermission(): Promise<PermissionStatus> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n const result = normalizePermissionStatus(await nativeModule.requestLocationPermission());\n if (!result.granted) {\n ErrorLogger.warn('前台位置权限未授予', result);\n }\n return result;\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '请求前台权限');\n }\n },\n\n /**\n * 请求后台位置权限\n * 注意:必须在前台权限已授予后才能请求\n */\n async requestBackgroundLocationPermission(): Promise<PermissionStatus> {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n const result = normalizePermissionStatus(await nativeModule.requestBackgroundLocationPermission());\n if (!result.granted) {\n ErrorLogger.warn('后台位置权限未授予', result);\n }\n return result;\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '请求后台权限');\n }\n },\n\n /**\n * 打开应用设置页面\n * 引导用户手动授予权限\n */\n openAppSettings(): void {\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n try {\n nativeModule.openAppSettings();\n } catch (error) {\n throw ErrorHandler.wrapNativeError(error, '打开设置');\n }\n },\n\n setAllowsBackgroundLocationUpdates(allows: boolean): void {\n assertPrivacyReady('sdk');\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n\n if (\n Platform.OS === 'ios' &&\n allows &&\n nativeModule &&\n nativeModule.isBackgroundLocationEnabled === false\n ) {\n ErrorLogger.warn(\n '⚠️ [ExpoGaodeMap] iOS 后台定位未正确配置,setAllowsBackgroundLocationUpdates(true) 可能不会生效,请检查 Info.plist 是否包含 UIBackgroundModes: location,或者在 app.json 中配置 enableBackgroundLocation: true,然后重新执行 npx expo prebuild',\n );\n }\n\n if (\n Platform.OS === 'android' &&\n allows &&\n nativeModule &&\n nativeModule.checkLocationPermission\n ) {\n nativeModule\n .checkLocationPermission()\n .then((status: PermissionStatus) => {\n if (!status.backgroundLocation) {\n ErrorLogger.warn(\n '⚠️ [ExpoGaodeMap] Android 后台位置权限未授予,setAllowsBackgroundLocationUpdates(true) 可能不会生效,请先通过 requestBackgroundLocationPermission 或系统设置授予后台定位权限,或者检查是否在 app.json 中配置了 enableBackgroundLocation: true,然后重新执行 npx expo prebuild',\n );\n }\n })\n .catch(() => {\n // 忽略检查失败,只影响日志,不影响功能\n });\n }\n\n nativeModule.setAllowsBackgroundLocationUpdates(allows);\n },\n\n /**\n * 添加定位监听器(便捷方法)\n * 自动订阅 onLocationUpdate 事件,提供容错处理\n * @param listener 定位回调函数\n * @returns 订阅对象,调用 remove() 取消监听\n * 注意:如果使用 Config Plugin 配置了 API Key,无需调用 initSDK()\n */\n addLocationListener(listener: LocationListener): { remove: () => void } {\n assertPrivacyReady('sdk');\n const module = getNativeModule();\n if (!module) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n if (!module.addListener) {\n ErrorLogger.warn('Native module does not support events');\n return {\n remove: () => { },\n };\n }\n\n return module.addListener('onLocationUpdate', (location) => {\n listener(normalizeLocationResult(location));\n }) || {\n remove: () => { },\n };\n },\n\n /**\n * 添加方向监听器(iOS)\n * 自动归一化 heading 事件字段,兼容旧版原生返回结构\n */\n addHeadingListener(listener: HeadingListener): { remove: () => void } {\n assertPrivacyReady('sdk');\n const module = getNativeModule();\n if (!module) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n if (!module.addListener) {\n ErrorLogger.warn('Native module does not support events');\n return {\n remove: () => { },\n };\n }\n\n return module.addListener('onHeadingUpdate', (heading) => {\n listener(normalizeHeadingEvent(heading));\n }) || {\n remove: () => { },\n };\n },\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { NativeExpoGaodeMapModule } from '../types/native-module.types';
|
|
2
|
+
export declare function getNativeModule(optional?: boolean): NativeExpoGaodeMapModule | null;
|
|
3
|
+
export declare function getBoundNativeValue(module: NativeExpoGaodeMapModule, prop: PropertyKey): unknown;
|
|
4
|
+
export declare const nativeModule: NativeExpoGaodeMapModule;
|
|
5
|
+
//# sourceMappingURL=nativeModule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModule.d.ts","sourceRoot":"","sources":["../../src/module/nativeModule.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAK7E,wBAAgB,eAAe,CAAC,QAAQ,UAAQ,GAAG,wBAAwB,GAAG,IAAI,CAgBjF;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,wBAAwB,EAChC,IAAI,EAAE,WAAW,GAChB,OAAO,CAOT;AAED,eAAO,MAAM,YAAY,0BAKvB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo';
|
|
2
|
+
import { ErrorHandler, ErrorLogger } from '../utils/ErrorHandler';
|
|
3
|
+
let nativeModuleCache = null;
|
|
4
|
+
export function getNativeModule(optional = false) {
|
|
5
|
+
if (nativeModuleCache) {
|
|
6
|
+
return nativeModuleCache;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
nativeModuleCache = requireNativeModule('ExpoGaodeMap');
|
|
10
|
+
return nativeModuleCache;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (optional) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
const moduleError = ErrorHandler.nativeModuleUnavailable();
|
|
17
|
+
ErrorLogger.log(moduleError);
|
|
18
|
+
throw moduleError;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function getBoundNativeValue(module, prop) {
|
|
22
|
+
const value = Reflect.get(module, prop, module);
|
|
23
|
+
if (typeof value === 'function') {
|
|
24
|
+
return (...args) => value.apply(module, args);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
export const nativeModule = new Proxy({}, {
|
|
29
|
+
get(_target, prop) {
|
|
30
|
+
const module = getNativeModule(true);
|
|
31
|
+
return module ? getBoundNativeValue(module, prop) : undefined;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
//# sourceMappingURL=nativeModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeModule.js","sourceRoot":"","sources":["../../src/module/nativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAElE,IAAI,iBAAiB,GAAoC,IAAI,CAAC;AAE9D,MAAM,UAAU,eAAe,CAAC,QAAQ,GAAG,KAAK;IAC9C,IAAI,iBAAiB,EAAE,CAAC;QACtB,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAED,IAAI,CAAC;QACH,iBAAiB,GAAG,mBAAmB,CAA2B,cAAc,CAAC,CAAC;QAClF,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,WAAW,GAAG,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAC3D,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC7B,MAAM,WAAW,CAAC;IACpB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,MAAgC,EAChC,IAAiB;IAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAgB,EAAE,IAAI,EAAE,MAAgB,CAAC,CAAC;IACpE,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAChC,OAAO,CAAC,GAAG,IAAe,EAAE,EAAE,CAC3B,KAA2C,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,KAAK,CAAC,EAA8B,EAAE;IACpE,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,MAAM,CAAC,CAAC,CAAC,mBAAmB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { requireNativeModule } from 'expo';\n\nimport type { NativeExpoGaodeMapModule } from '../types/native-module.types';\nimport { ErrorHandler, ErrorLogger } from '../utils/ErrorHandler';\n\nlet nativeModuleCache: NativeExpoGaodeMapModule | null = null;\n\nexport function getNativeModule(optional = false): NativeExpoGaodeMapModule | null {\n if (nativeModuleCache) {\n return nativeModuleCache;\n }\n\n try {\n nativeModuleCache = requireNativeModule<NativeExpoGaodeMapModule>('ExpoGaodeMap');\n return nativeModuleCache;\n } catch (error) {\n if (optional) {\n return null;\n }\n const moduleError = ErrorHandler.nativeModuleUnavailable();\n ErrorLogger.log(moduleError);\n throw moduleError;\n }\n}\n\nexport function getBoundNativeValue(\n module: NativeExpoGaodeMapModule,\n prop: PropertyKey\n): unknown {\n const value = Reflect.get(module as object, prop, module as object);\n if (typeof value === 'function') {\n return (...args: unknown[]) =>\n (value as (...fnArgs: unknown[]) => unknown).apply(module, args);\n }\n return value;\n}\n\nexport const nativeModule = new Proxy({} as NativeExpoGaodeMapModule, {\n get(_target, prop) {\n const module = getNativeModule(true);\n return module ? getBoundNativeValue(module, prop) : undefined;\n },\n});\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Coordinates, CoordinateType, GeoLanguage, HeadingUpdate, LatLngPoint, ReGeocode } from '../types';
|
|
2
|
+
import type { PermissionStatus } from '../types/common.types';
|
|
3
|
+
export declare function normalizeCoordinateType(type: CoordinateType): number | null;
|
|
4
|
+
export declare function normalizeGeoLanguage(language: GeoLanguage | string): GeoLanguage;
|
|
5
|
+
export declare function normalizeLocationResult<T extends Coordinates | ReGeocode>(location: T): T;
|
|
6
|
+
export declare function normalizeHeadingEvent(payload: HeadingUpdate | Record<string, unknown>): HeadingUpdate;
|
|
7
|
+
export declare function normalizePermissionStatus(permission: PermissionStatus | Record<string, unknown>): PermissionStatus;
|
|
8
|
+
export type { LatLngPoint };
|
|
9
|
+
//# sourceMappingURL=normalizers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizers.d.ts","sourceRoot":"","sources":["../../src/module/normalizers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,cAAc,EACd,WAAW,EACX,aAAa,EACb,WAAW,EACX,SAAS,EACV,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAI9D,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAqB3E;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,GAAG,MAAM,GAAG,WAAW,CAyBhF;AAED,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,WAAW,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CAQzF;AAED,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,aAAa,CAcrG;AAED,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,gBAAgB,CAqDlH;AAED,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { ErrorHandler } from '../utils/ErrorHandler';
|
|
2
|
+
import { CoordinateType as CoordinateTypeValue } from '../types';
|
|
3
|
+
export function normalizeCoordinateType(type) {
|
|
4
|
+
switch (type) {
|
|
5
|
+
case CoordinateTypeValue.AMap:
|
|
6
|
+
return null;
|
|
7
|
+
case CoordinateTypeValue.MapBar:
|
|
8
|
+
return 1;
|
|
9
|
+
case CoordinateTypeValue.Baidu:
|
|
10
|
+
return 2;
|
|
11
|
+
case CoordinateTypeValue.MapABC:
|
|
12
|
+
case CoordinateTypeValue.SoSoMap:
|
|
13
|
+
return 3;
|
|
14
|
+
case CoordinateTypeValue.Google:
|
|
15
|
+
case CoordinateTypeValue.GPS:
|
|
16
|
+
return 0;
|
|
17
|
+
default:
|
|
18
|
+
throw ErrorHandler.invalidParameter('type', 'CoordinateType.AMap | MapBar | Baidu | MapABC | SoSoMap | Google | GPS', type);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function normalizeGeoLanguage(language) {
|
|
22
|
+
const normalized = String(language).trim().toUpperCase();
|
|
23
|
+
switch (normalized) {
|
|
24
|
+
case 'DEFAULT':
|
|
25
|
+
return 'DEFAULT';
|
|
26
|
+
case 'EN':
|
|
27
|
+
case 'EN-US':
|
|
28
|
+
case 'EN_US':
|
|
29
|
+
case 'EN-GB':
|
|
30
|
+
case 'EN_GB':
|
|
31
|
+
return 'EN';
|
|
32
|
+
case 'ZH':
|
|
33
|
+
case 'ZH-CN':
|
|
34
|
+
case 'ZH_CN':
|
|
35
|
+
case 'ZH-HANS':
|
|
36
|
+
case 'ZH_HANS':
|
|
37
|
+
return 'ZH';
|
|
38
|
+
default:
|
|
39
|
+
throw ErrorHandler.invalidParameter('language', "'DEFAULT' | 'EN' | 'ZH' | 常见别名(如 'en', 'zh-CN')", language);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function normalizeLocationResult(location) {
|
|
43
|
+
const rawLocation = location;
|
|
44
|
+
const heading = rawLocation.heading ?? rawLocation.bearing ?? 0;
|
|
45
|
+
return {
|
|
46
|
+
...rawLocation,
|
|
47
|
+
heading,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export function normalizeHeadingEvent(payload) {
|
|
51
|
+
const raw = payload;
|
|
52
|
+
const fallbackHeading = Number(raw.heading ?? raw.trueHeading ?? raw.magneticHeading ?? 0);
|
|
53
|
+
const fallbackAccuracy = Number(raw.accuracy ?? raw.headingAccuracy ?? 0);
|
|
54
|
+
return {
|
|
55
|
+
magneticHeading: Number(raw.magneticHeading ?? fallbackHeading),
|
|
56
|
+
trueHeading: Number(raw.trueHeading ?? fallbackHeading),
|
|
57
|
+
headingAccuracy: fallbackAccuracy,
|
|
58
|
+
x: Number(raw.x ?? 0),
|
|
59
|
+
y: Number(raw.y ?? 0),
|
|
60
|
+
z: Number(raw.z ?? 0),
|
|
61
|
+
timestamp: Number(raw.timestamp ?? Date.now()),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export function normalizePermissionStatus(permission) {
|
|
65
|
+
const raw = permission;
|
|
66
|
+
const rawStatus = String(raw.status ?? '');
|
|
67
|
+
let status;
|
|
68
|
+
switch (rawStatus) {
|
|
69
|
+
case 'granted':
|
|
70
|
+
case 'authorizedAlways':
|
|
71
|
+
case 'authorizedWhenInUse':
|
|
72
|
+
status = 'granted';
|
|
73
|
+
break;
|
|
74
|
+
case 'denied':
|
|
75
|
+
case 'restricted':
|
|
76
|
+
status = 'denied';
|
|
77
|
+
break;
|
|
78
|
+
case 'notDetermined':
|
|
79
|
+
case 'undetermined':
|
|
80
|
+
case 'unknown':
|
|
81
|
+
case '':
|
|
82
|
+
default:
|
|
83
|
+
status = 'undetermined';
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
const granted = Boolean(raw.granted ?? (status === 'granted'));
|
|
87
|
+
const shouldShowRationale = typeof raw.shouldShowRationale === 'boolean' ? raw.shouldShowRationale : undefined;
|
|
88
|
+
const explicitPermanent = typeof raw.isPermanentlyDenied === 'boolean' ? raw.isPermanentlyDenied : undefined;
|
|
89
|
+
const canAskAgain = typeof raw.canAskAgain === 'boolean'
|
|
90
|
+
? raw.canAskAgain
|
|
91
|
+
: granted
|
|
92
|
+
? true
|
|
93
|
+
: typeof shouldShowRationale === 'boolean'
|
|
94
|
+
? shouldShowRationale
|
|
95
|
+
: explicitPermanent === true
|
|
96
|
+
? false
|
|
97
|
+
: status === 'undetermined';
|
|
98
|
+
const isPermanentlyDenied = explicitPermanent ??
|
|
99
|
+
(!granted && status === 'denied' && canAskAgain === false);
|
|
100
|
+
return {
|
|
101
|
+
...raw,
|
|
102
|
+
expires: raw.expires ?? 'never',
|
|
103
|
+
granted,
|
|
104
|
+
status: status,
|
|
105
|
+
canAskAgain,
|
|
106
|
+
isPermanentlyDenied,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=normalizers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizers.js","sourceRoot":"","sources":["../../src/module/normalizers.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,cAAc,IAAI,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEjE,MAAM,UAAU,uBAAuB,CAAC,IAAoB;IAC1D,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,mBAAmB,CAAC,IAAI;YAC3B,OAAO,IAAI,CAAC;QACd,KAAK,mBAAmB,CAAC,MAAM;YAC7B,OAAO,CAAC,CAAC;QACX,KAAK,mBAAmB,CAAC,KAAK;YAC5B,OAAO,CAAC,CAAC;QACX,KAAK,mBAAmB,CAAC,MAAM,CAAC;QAChC,KAAK,mBAAmB,CAAC,OAAO;YAC9B,OAAO,CAAC,CAAC;QACX,KAAK,mBAAmB,CAAC,MAAM,CAAC;QAChC,KAAK,mBAAmB,CAAC,GAAG;YAC1B,OAAO,CAAC,CAAC;QACX;YACE,MAAM,YAAY,CAAC,gBAAgB,CACjC,MAAM,EACN,wEAAwE,EACxE,IAAI,CACL,CAAC;IACN,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,QAA8B;IACjE,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzD,QAAQ,UAAU,EAAE,CAAC;QACnB,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,OAAO;YACP,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,OAAO,mBAAmB,KAAK,SAAS;gBACxC,CAAC,CAAC,mBAAmB;gBACrB,CAAC,CAAC,iBAAiB,KAAK,IAAI;oBAC1B,CAAC,CAAC,KAAK;oBACP,CAAC,CAAC,MAAM,KAAK,cAAc,CAAC;IAEtC,MAAM,mBAAmB,GACvB,iBAAiB;QACjB,CAAC,CAAC,OAAO,IAAI,MAAM,KAAK,QAAQ,IAAI,WAAW,KAAK,KAAK,CAAC,CAAC;IAE7D,OAAO;QACL,GAAG,GAAG;QACN,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,OAAO;QAC/B,OAAO;QACP,MAAM,EAAE,MAA+C;QACvD,WAAW;QACX,mBAAmB;KACpB,CAAC;AACJ,CAAC","sourcesContent":["import type {\n Coordinates,\n CoordinateType,\n GeoLanguage,\n HeadingUpdate,\n LatLngPoint,\n ReGeocode,\n} from '../types';\nimport type { PermissionStatus } from '../types/common.types';\nimport { ErrorHandler } from '../utils/ErrorHandler';\nimport { CoordinateType as CoordinateTypeValue } from '../types';\n\nexport function normalizeCoordinateType(type: CoordinateType): number | null {\n switch (type) {\n case CoordinateTypeValue.AMap:\n return null;\n case CoordinateTypeValue.MapBar:\n return 1;\n case CoordinateTypeValue.Baidu:\n return 2;\n case CoordinateTypeValue.MapABC:\n case CoordinateTypeValue.SoSoMap:\n return 3;\n case CoordinateTypeValue.Google:\n case CoordinateTypeValue.GPS:\n return 0;\n default:\n throw ErrorHandler.invalidParameter(\n 'type',\n 'CoordinateType.AMap | MapBar | Baidu | MapABC | SoSoMap | Google | GPS',\n type\n );\n }\n}\n\nexport function normalizeGeoLanguage(language: GeoLanguage | string): GeoLanguage {\n const normalized = String(language).trim().toUpperCase();\n\n switch (normalized) {\n case 'DEFAULT':\n return 'DEFAULT';\n case 'EN':\n case 'EN-US':\n case 'EN_US':\n case 'EN-GB':\n case 'EN_GB':\n return 'EN';\n case 'ZH':\n case 'ZH-CN':\n case 'ZH_CN':\n case 'ZH-HANS':\n case 'ZH_HANS':\n return 'ZH';\n default:\n throw ErrorHandler.invalidParameter(\n 'language',\n \"'DEFAULT' | 'EN' | 'ZH' | 常见别名(如 'en', 'zh-CN')\",\n language\n );\n }\n}\n\nexport function normalizeLocationResult<T extends Coordinates | ReGeocode>(location: T): T {\n const rawLocation = location as T & { bearing?: number; heading?: number };\n const heading = rawLocation.heading ?? rawLocation.bearing ?? 0;\n\n return {\n ...rawLocation,\n heading,\n };\n}\n\nexport function normalizeHeadingEvent(payload: HeadingUpdate | Record<string, unknown>): HeadingUpdate {\n const raw = payload as Record<string, unknown>;\n const fallbackHeading = Number(raw.heading ?? raw.trueHeading ?? raw.magneticHeading ?? 0);\n const fallbackAccuracy = Number(raw.accuracy ?? raw.headingAccuracy ?? 0);\n\n return {\n magneticHeading: Number(raw.magneticHeading ?? fallbackHeading),\n trueHeading: Number(raw.trueHeading ?? fallbackHeading),\n headingAccuracy: fallbackAccuracy,\n x: Number(raw.x ?? 0),\n y: Number(raw.y ?? 0),\n z: Number(raw.z ?? 0),\n timestamp: Number(raw.timestamp ?? Date.now()),\n };\n}\n\nexport function normalizePermissionStatus(permission: PermissionStatus | Record<string, unknown>): PermissionStatus {\n const raw = permission as Partial<PermissionStatus> & Record<string, unknown>;\n const rawStatus = String(raw.status ?? '');\n\n let status: 'granted' | 'denied' | 'undetermined';\n switch (rawStatus) {\n case 'granted':\n case 'authorizedAlways':\n case 'authorizedWhenInUse':\n status = 'granted';\n break;\n case 'denied':\n case 'restricted':\n status = 'denied';\n break;\n case 'notDetermined':\n case 'undetermined':\n case 'unknown':\n case '':\n default:\n status = 'undetermined';\n break;\n }\n\n const granted = Boolean(raw.granted ?? (status === 'granted'));\n const shouldShowRationale =\n typeof raw.shouldShowRationale === 'boolean' ? raw.shouldShowRationale : undefined;\n const explicitPermanent =\n typeof raw.isPermanentlyDenied === 'boolean' ? raw.isPermanentlyDenied : undefined;\n\n const canAskAgain =\n typeof raw.canAskAgain === 'boolean'\n ? raw.canAskAgain\n : granted\n ? true\n : typeof shouldShowRationale === 'boolean'\n ? shouldShowRationale\n : explicitPermanent === true\n ? false\n : status === 'undetermined';\n\n const isPermanentlyDenied =\n explicitPermanent ??\n (!granted && status === 'denied' && canAskAgain === false);\n\n return {\n ...raw,\n expires: raw.expires ?? 'never',\n granted,\n status: status as unknown as PermissionStatus['status'],\n canAskAgain,\n isPermanentlyDenied,\n };\n}\n\nexport type { LatLngPoint };\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PrivacyConfig, PrivacyStatus } from '../types/common.types';
|
|
2
|
+
export declare function assertPrivacyReady(scene?: 'map' | 'sdk'): void;
|
|
3
|
+
export declare const privacyMethods: {
|
|
4
|
+
/**
|
|
5
|
+
* 设置当前隐私协议版本
|
|
6
|
+
* 当版本号变化时,之前的同意状态会失效
|
|
7
|
+
*/
|
|
8
|
+
setPrivacyVersion(version: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* 清空已持久化的隐私同意状态
|
|
11
|
+
*/
|
|
12
|
+
resetPrivacyConsent(): void;
|
|
13
|
+
/**
|
|
14
|
+
* 一次性同步完整的隐私状态
|
|
15
|
+
* 推荐业务层只调用这个方法
|
|
16
|
+
*/
|
|
17
|
+
setPrivacyConfig(config: PrivacyConfig): void;
|
|
18
|
+
getPrivacyStatus(): PrivacyStatus;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=privacy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../../src/module/privacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAI1E,wBAAgB,kBAAkB,CAAC,KAAK,GAAE,KAAK,GAAG,KAAa,GAAG,IAAI,CASrE;AAED,eAAO,MAAM,cAAc;IACzB;;;OAGG;+BACwB,MAAM,GAAG,IAAI;IAMxC;;OAEG;2BACoB,IAAI;IAM3B;;;OAGG;6BACsB,aAAa,GAAG,IAAI;wBAMzB,aAAa;CAelC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ErrorHandler } from '../utils/ErrorHandler';
|
|
2
|
+
import { getNativeModule } from './nativeModule';
|
|
3
|
+
export function assertPrivacyReady(scene = 'sdk') {
|
|
4
|
+
const nativeModule = getNativeModule();
|
|
5
|
+
if (!nativeModule) {
|
|
6
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
7
|
+
}
|
|
8
|
+
const status = nativeModule.getPrivacyStatus();
|
|
9
|
+
if (!status.isReady) {
|
|
10
|
+
throw ErrorHandler.privacyNotAgreed(scene);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export const privacyMethods = {
|
|
14
|
+
/**
|
|
15
|
+
* 设置当前隐私协议版本
|
|
16
|
+
* 当版本号变化时,之前的同意状态会失效
|
|
17
|
+
*/
|
|
18
|
+
setPrivacyVersion(version) {
|
|
19
|
+
const nativeModule = getNativeModule();
|
|
20
|
+
if (!nativeModule)
|
|
21
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
22
|
+
nativeModule.setPrivacyVersion(version);
|
|
23
|
+
},
|
|
24
|
+
/**
|
|
25
|
+
* 清空已持久化的隐私同意状态
|
|
26
|
+
*/
|
|
27
|
+
resetPrivacyConsent() {
|
|
28
|
+
const nativeModule = getNativeModule();
|
|
29
|
+
if (!nativeModule)
|
|
30
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
31
|
+
nativeModule.resetPrivacyConsent();
|
|
32
|
+
},
|
|
33
|
+
/**
|
|
34
|
+
* 一次性同步完整的隐私状态
|
|
35
|
+
* 推荐业务层只调用这个方法
|
|
36
|
+
*/
|
|
37
|
+
setPrivacyConfig(config) {
|
|
38
|
+
const nativeModule = getNativeModule();
|
|
39
|
+
if (!nativeModule)
|
|
40
|
+
throw ErrorHandler.nativeModuleUnavailable();
|
|
41
|
+
nativeModule.setPrivacyConfig(config);
|
|
42
|
+
},
|
|
43
|
+
getPrivacyStatus() {
|
|
44
|
+
const nativeModule = getNativeModule();
|
|
45
|
+
if (!nativeModule) {
|
|
46
|
+
return {
|
|
47
|
+
hasShow: false,
|
|
48
|
+
hasContainsPrivacy: false,
|
|
49
|
+
hasAgree: false,
|
|
50
|
+
isReady: false,
|
|
51
|
+
privacyVersion: null,
|
|
52
|
+
agreedPrivacyVersion: null,
|
|
53
|
+
restoredFromStorage: false,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return nativeModule.getPrivacyStatus();
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=privacy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"privacy.js","sourceRoot":"","sources":["../../src/module/privacy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,UAAU,kBAAkB,CAAC,QAAuB,KAAK;IAC7D,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;IACvC,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IACD,MAAM,MAAM,GAAG,YAAY,CAAC,gBAAgB,EAAE,CAAC;IAC/C,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,YAAY,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B;;;OAGG;IACH,iBAAiB,CAAC,OAAe;QAC/B,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY;YAAE,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAChE,YAAY,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,mBAAmB;QACjB,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY;YAAE,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAChE,YAAY,CAAC,mBAAmB,EAAE,CAAC;IACrC,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,MAAqB;QACpC,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY;YAAE,MAAM,YAAY,CAAC,uBAAuB,EAAE,CAAC;QAChE,YAAY,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,gBAAgB;QACd,MAAM,YAAY,GAAG,eAAe,EAAE,CAAC;QACvC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,kBAAkB,EAAE,KAAK;gBACzB,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,KAAK;gBACd,cAAc,EAAE,IAAI;gBACpB,oBAAoB,EAAE,IAAI;gBAC1B,mBAAmB,EAAE,KAAK;aAC3B,CAAC;QACJ,CAAC;QACD,OAAO,YAAY,CAAC,gBAAgB,EAAE,CAAC;IACzC,CAAC;CACF,CAAC","sourcesContent":["import type { PrivacyConfig, PrivacyStatus } from '../types/common.types';\nimport { ErrorHandler } from '../utils/ErrorHandler';\nimport { getNativeModule } from './nativeModule';\n\nexport function assertPrivacyReady(scene: 'map' | 'sdk' = 'sdk'): void {\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n throw ErrorHandler.nativeModuleUnavailable();\n }\n const status = nativeModule.getPrivacyStatus();\n if (!status.isReady) {\n throw ErrorHandler.privacyNotAgreed(scene);\n }\n}\n\nexport const privacyMethods = {\n /**\n * 设置当前隐私协议版本\n * 当版本号变化时,之前的同意状态会失效\n */\n setPrivacyVersion(version: string): void {\n const nativeModule = getNativeModule();\n if (!nativeModule) throw ErrorHandler.nativeModuleUnavailable();\n nativeModule.setPrivacyVersion(version);\n },\n\n /**\n * 清空已持久化的隐私同意状态\n */\n resetPrivacyConsent(): void {\n const nativeModule = getNativeModule();\n if (!nativeModule) throw ErrorHandler.nativeModuleUnavailable();\n nativeModule.resetPrivacyConsent();\n },\n\n /**\n * 一次性同步完整的隐私状态\n * 推荐业务层只调用这个方法\n */\n setPrivacyConfig(config: PrivacyConfig): void {\n const nativeModule = getNativeModule();\n if (!nativeModule) throw ErrorHandler.nativeModuleUnavailable();\n nativeModule.setPrivacyConfig(config);\n },\n\n getPrivacyStatus(): PrivacyStatus {\n const nativeModule = getNativeModule();\n if (!nativeModule) {\n return {\n hasShow: false,\n hasContainsPrivacy: false,\n hasAgree: false,\n isReady: false,\n privacyVersion: null,\n agreedPrivacyVersion: null,\n restoredFromStorage: false,\n };\n }\n return nativeModule.getPrivacyStatus();\n },\n};\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SDKConfig } from '../types/common.types';
|
|
2
|
+
export declare const sdkMethods: {
|
|
3
|
+
/**
|
|
4
|
+
* 初始化 SDK,并缓存配置(包含 webKey)
|
|
5
|
+
* 注意:允许不提供任何 API Key,因为原生端可能已通过 Config Plugin 配置
|
|
6
|
+
*/
|
|
7
|
+
initSDK(config: SDKConfig): void;
|
|
8
|
+
isSDKInitialized(): boolean;
|
|
9
|
+
setLoadWorldVectorMap(enabled: boolean): void;
|
|
10
|
+
getVersion(): string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* 获取最近一次 initSDK 的配置
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSDKConfig(): SDKConfig | null;
|
|
16
|
+
/**
|
|
17
|
+
* 获取用于 Web API 的 webKey(若未初始化或未提供则返回 undefined)
|
|
18
|
+
*/
|
|
19
|
+
export declare function getWebKey(): string | undefined;
|
|
20
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/module/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAOvD,eAAO,MAAM,UAAU;IACrB;;;OAGG;oBACa,SAAS,GAAG,IAAI;wBAuCZ,OAAO;mCAII,OAAO,GAAG,IAAI;kBAU/B,MAAM;CAUrB,CAAC;AAEF;;EAEE;AACF,wBAAgB,YAAY,IAAI,SAAS,GAAG,IAAI,CAE/C;AAED;;EAEE;AACF,wBAAgB,SAAS,IAAI,MAAM,GAAG,SAAS,CAE9C"}
|