@nativescript-community/ui-mapbox 6.2.31 → 7.0.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 (42) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/common.d.ts +56 -26
  3. package/common.js +44 -28
  4. package/expression/expression-parser.android.d.ts +2 -2
  5. package/expression/expression-parser.android.js +4 -3
  6. package/expression/expression-parser.ios.d.ts +2 -2
  7. package/expression/expression-parser.ios.js +28 -13
  8. package/index.android.d.ts +59 -66
  9. package/index.android.js +1388 -1244
  10. package/index.d.ts +36 -5
  11. package/index.ios.d.ts +72 -243
  12. package/index.ios.js +1161 -1999
  13. package/layers/layer-factory.android.d.ts +7 -5
  14. package/layers/layer-factory.android.js +71 -41
  15. package/layers/layer-factory.d.ts +2 -1
  16. package/layers/layer-factory.ios.d.ts +8 -8
  17. package/layers/layer-factory.ios.js +46 -100
  18. package/layers/parser/property-parser.android.d.ts +3 -1
  19. package/layers/parser/property-parser.android.js +25 -24
  20. package/layers/parser/property-parser.d.ts +1 -1
  21. package/layers/parser/property-parser.ios.d.ts +0 -2
  22. package/layers/parser/property-parser.ios.js +0 -149
  23. package/markers/Marker.android.d.ts +28 -0
  24. package/markers/Marker.android.js +54 -0
  25. package/markers/Marker.common.d.ts +2 -0
  26. package/markers/Marker.common.js +31 -0
  27. package/markers/MarkerManager.android.d.ts +35 -0
  28. package/markers/MarkerManager.android.js +220 -0
  29. package/package.json +7 -6
  30. package/platforms/android/include.gradle +31 -27
  31. package/platforms/android/ui_mapbox.aar +0 -0
  32. package/platforms/ios/Podfile +3 -1
  33. package/platforms/ios/Resources/default_pin.png +0 -0
  34. package/platforms/ios/src/MapboxBridge.swift +1479 -0
  35. package/platforms/ios/src/NativeExpressionParser.swift +33 -0
  36. package/platforms/ios/src/NativeLayerFactory.swift +108 -0
  37. package/tsconfig.tsbuildinfo +1 -0
  38. package/typings/Mapbox.ios.d.ts +2 -3242
  39. package/typings/geojson.android.d.ts +689 -0
  40. package/typings/index.android.d.ts +46 -0
  41. package/typings/mapbox.android.d.ts +39968 -12560
  42. package/typings/mapbox.bridge.ios.d.ts +129 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.0](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.31...v7.0.0) (2025-10-25)
7
+
8
+ ### Features
9
+
10
+ * **android:** plugin updated to v11 (not retro compat!) ([9b98b79](https://github.com/nativescript-community/ui-mapbox/commit/9b98b79cb9a0cf2474ac6336e754370940a29d2d))
11
+ * **ios:** updated SDK to v11+ ([fc9af79](https://github.com/nativescript-community/ui-mapbox/commit/fc9af79a296019fa8c44e4b019826b524c19af72))
12
+
6
13
  ## [6.2.31](https://github.com/nativescript-community/ui-mapbox/compare/v6.2.30...v6.2.31) (2024-10-04)
7
14
 
8
15
  **Note:** Version bump only for package @nativescript-community/ui-mapbox
package/common.d.ts CHANGED
@@ -37,8 +37,8 @@ export interface QuerySourceFeaturesOptions {
37
37
  export interface Feature {
38
38
  id?: any;
39
39
  type: string;
40
- geometry: Object;
41
- properties: Object;
40
+ geometry: object;
41
+ properties: object;
42
42
  }
43
43
  export interface AddPolygonOptions {
44
44
  /**
@@ -96,7 +96,7 @@ export interface MapboxMarker extends LatLng {
96
96
  /**
97
97
  * Set this in case you want to later pass it to 'removeMarker'.
98
98
  */
99
- id?: any;
99
+ id?: number;
100
100
  title?: string;
101
101
  subtitle?: string;
102
102
  /**
@@ -127,6 +127,10 @@ export interface MapboxMarker extends LatLng {
127
127
  update?: (newSettings: MapboxMarker) => void;
128
128
  ios?: any;
129
129
  android?: any;
130
+ /**
131
+ * internally used to know if the marker image is already downloaded
132
+ */
133
+ downloadedIcon?: ImageSource;
130
134
  }
131
135
  export interface SetZoomLevelOptions {
132
136
  level: number;
@@ -141,6 +145,7 @@ export interface SetTiltOptions {
141
145
  * default 5000 (milliseconds)
142
146
  */
143
147
  duration: number;
148
+ animated?: boolean;
144
149
  }
145
150
  export interface ShowOptionsMargins {
146
151
  left?: number;
@@ -190,6 +195,10 @@ export interface MapboxCluster {
190
195
  color: string;
191
196
  }
192
197
  export interface AddGeoJsonClusteredOptions {
198
+ id: any;
199
+ url: any;
200
+ pointColor: string;
201
+ pointRadius: number;
193
202
  /**
194
203
  * A unique identifier, like: "earthquakes"
195
204
  */
@@ -259,6 +268,7 @@ export interface VectorSource extends Source {
259
268
  tileSize?: number;
260
269
  }
261
270
  export interface GeoJSONSource extends Source {
271
+ url: any;
262
272
  type: 'geojson';
263
273
  data?: any;
264
274
  minzoom?: number;
@@ -275,19 +285,25 @@ export interface GeoJSONSource extends Source {
275
285
  export type UserLocationCameraMode = 'NONE' | 'NONE_COMPASS' | 'NONE_GPS' | 'TRACKING' | 'TRACKING_COMPASS' | 'TRACKING_GPS' | 'TRACKING_GPS_NORTH';
276
286
  export interface TrackUserOptions {
277
287
  cameraMode: UserLocationCameraMode;
278
- renderMode?: string;
288
+ renderMode?: 'NORMAL' | 'COMPASS' | 'GPS';
279
289
  /**
280
290
  * iOS only, as Android is always animated. Default true (because of Android).
281
291
  */
282
292
  animated?: boolean;
283
293
  }
284
294
  export interface AddExtrusionOptions {
295
+ id?: string;
296
+ source?: string;
297
+ sourceLayer?: string;
298
+ minZoom?: any;
299
+ color?: string;
300
+ opacity?: any;
285
301
  }
286
302
  export interface OfflineRegion {
287
303
  name: string;
288
304
  bounds: Bounds;
289
- minZoom: number;
290
- maxZoom: number;
305
+ minZoom?: number;
306
+ maxZoom?: number;
291
307
  style: MapStyle;
292
308
  metadata?: any;
293
309
  pixelRatio?: any;
@@ -305,12 +321,16 @@ export interface DownloadProgress {
305
321
  completedSize?: number;
306
322
  }
307
323
  export interface DownloadOfflineRegionOptions extends OfflineRegion {
324
+ styleUrl: any;
308
325
  onProgress?: (data: DownloadProgress) => void;
309
326
  /**
310
327
  * Optional, used on Android only.
311
328
  * Set this, in case no map has been show yet (and thus, no accessToken has been passed in yet).
312
329
  */
313
330
  accessToken?: string;
331
+ regionId?: string;
332
+ minZoom?: number;
333
+ maxZoom?: number;
314
334
  }
315
335
  export interface ListOfflineRegionsOptions {
316
336
  /**
@@ -470,10 +490,7 @@ export interface MapboxApi {
470
490
  unhide(): Promise<any>;
471
491
  destroy(nativeMap?: any): Promise<any>;
472
492
  onStart(nativeMap?: any): Promise<any>;
473
- onResume(nativeMap?: any): Promise<any>;
474
- onPause(nativeMap?: any): Promise<any>;
475
493
  onStop(nativeMap?: any): Promise<any>;
476
- onLowMemory(nativeMap?: any): Promise<any>;
477
494
  onDestroy(nativeMap?: any): Promise<any>;
478
495
  setMapStyle(style: string | MapStyle, nativeMap?: any): Promise<any>;
479
496
  addMarkers(markers: MapboxMarker[], nativeMap?: any): Promise<any>;
@@ -487,10 +504,8 @@ export interface MapboxApi {
487
504
  getUserLocation(nativeMap?: any): Promise<UserLocation>;
488
505
  showUserLocationMarker(options: any, nativeMap?: any): void;
489
506
  hideUserLocationMarker(nativeMap?: any): void;
490
- changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode, nativeMap?: any): void;
491
507
  forceUserLocationUpdate(location: any, nativeMap?: any): void;
492
508
  trackUser(options: TrackUserOptions, nativeMap?: any): Promise<void>;
493
- getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
494
509
  addSource(id: string, options: AddSourceOptions, nativeMapView?: any): Promise<any>;
495
510
  updateSource(id: string, options: UpdateSourceOptions, nativeMapView?: any): Promise<any>;
496
511
  removeSource(id: string, nativeMap?: any): Promise<any>;
@@ -513,9 +528,9 @@ export interface MapboxApi {
513
528
  setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
514
529
  setOnMoveEndListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
515
530
  setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any>;
516
- setOnCameraMoveListener(listener: (reason: any, animated?: boolean) => void, nativeMap?: any): Promise<any>;
531
+ setOnCameraChangeListener(listener: (reason: any, animated?: boolean) => void, nativeMap?: any): Promise<any>;
517
532
  setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any>;
518
- setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any>;
533
+ setOnMapIdleListener(listener: () => void, nativeMap?: any): Promise<any>;
519
534
  requestFineLocationPermission(): Promise<any>;
520
535
  hasFineLocationPermission(): Promise<boolean>;
521
536
  getViewport(nativeMap?: any): Promise<Viewport>;
@@ -543,8 +558,12 @@ export declare abstract class MapboxCommon implements MapboxCommonApi {
543
558
  constructor(view?: MapboxViewCommonBase);
544
559
  static defaults: Partial<ShowOptions>;
545
560
  static merge(obj1: {}, obj2: {}): any;
546
- requestFineLocationPermission(): Promise<any>;
547
561
  hasFineLocationPermission(): Promise<boolean>;
562
+ /**
563
+ * Request fine locaion permission
564
+ *
565
+ */
566
+ requestFineLocationPermission(): Promise<import("@nativescript-community/perms").Status>;
548
567
  protected fetchImageSource(imagePath: string): Promise<ImageSource>;
549
568
  }
550
569
  /**
@@ -562,7 +581,7 @@ export interface MapboxViewApi {
562
581
  setOnScrollListener(listener: (data?: LatLng) => void): Promise<void>;
563
582
  setOnMoveBeginListener(listener: (data?: LatLng) => void): Promise<void>;
564
583
  setOnFlingListener(listener: () => void): Promise<any>;
565
- setOnCameraMoveListener(listener: (reason: any, animated?: boolean) => void): Promise<any>;
584
+ setOnCameraChangeListener(listener: (reason: any, animated?: boolean) => void): Promise<any>;
566
585
  setOnCameraMoveCancelListener(listener: () => void): Promise<any>;
567
586
  setOnCameraIdleListener(listener: () => void): Promise<any>;
568
587
  getViewport(): Promise<Viewport>;
@@ -576,10 +595,8 @@ export interface MapboxViewApi {
576
595
  setTilt(options: SetTiltOptions): Promise<any>;
577
596
  getUserLocation(): Promise<UserLocation>;
578
597
  trackUser(options: TrackUserOptions): Promise<any>;
579
- getUserLocationCameraMode(nativeMap?: any): UserLocationCameraMode;
580
598
  showUserLocationMarker(options: any): void;
581
599
  hideUserLocationMarker(options: any): void;
582
- changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
583
600
  forceUserLocationUpdate(location: any): void;
584
601
  addSource(id: string, options: AddSourceOptions): Promise<any>;
585
602
  updateSource(id: string, options: UpdateSourceOptions): Promise<any>;
@@ -599,10 +616,7 @@ export interface MapboxViewApi {
599
616
  removeImage(imageId: string, nativeMap?: any): Promise<void>;
600
617
  destroy(): Promise<any>;
601
618
  onStart(): Promise<any>;
602
- onResume(): Promise<any>;
603
- onPause(): Promise<any>;
604
619
  onStop(): Promise<any>;
605
- onLowMemory(): Promise<any>;
606
620
  onDestroy(): Promise<any>;
607
621
  project(data: LatLng): {
608
622
  x: number;
@@ -641,7 +655,7 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
641
655
  setOnMoveBeginListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
642
656
  setOnMoveEndListener(listener: (data?: LatLng) => void, nativeMap?: any): Promise<void>;
643
657
  setOnFlingListener(listener: () => void, nativeMap?: any): Promise<any>;
644
- setOnCameraMoveListener(listener: (reason: any, animated?: boolean) => void, nativeMap?: any): Promise<any>;
658
+ setOnCameraChangeListener(listener: (reason: any, animated?: boolean) => void, nativeMap?: any): Promise<any>;
645
659
  setOnCameraMoveCancelListener(listener: () => void, nativeMap?: any): Promise<any>;
646
660
  setOnCameraIdleListener(listener: () => void, nativeMap?: any): Promise<any>;
647
661
  getViewport(): Promise<Viewport>;
@@ -656,10 +670,8 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
656
670
  getUserLocation(): Promise<UserLocation>;
657
671
  showUserLocationMarker(options: any): void;
658
672
  hideUserLocationMarker(): void;
659
- changeUserLocationMarkerMode(renderModeString: any, cameraModeString: UserLocationCameraMode): void;
660
673
  forceUserLocationUpdate(location: any): void;
661
674
  trackUser(options: TrackUserOptions): Promise<any>;
662
- getUserLocationCameraMode(): UserLocationCameraMode;
663
675
  addSource(id: string, options: AddSourceOptions): Promise<any>;
664
676
  updateSource(id: string, options: UpdateSourceOptions): Promise<any>;
665
677
  removeSource(id: string): Promise<any>;
@@ -680,10 +692,7 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
680
692
  removeImage(imageId: string): Promise<void>;
681
693
  destroy(): Promise<any>;
682
694
  onStart(): Promise<any>;
683
- onResume(nativeMap?: any): Promise<any>;
684
- onPause(nativeMap?: any): Promise<any>;
685
695
  onStop(nativeMap?: any): Promise<any>;
686
- onLowMemory(nativeMap?: any): Promise<any>;
687
696
  onDestroy(nativeMap?: any): Promise<any>;
688
697
  project(data: LatLng): {
689
698
  x: number;
@@ -693,6 +702,9 @@ export declare abstract class MapboxViewCommonBase extends ContentView implement
693
702
  x: number;
694
703
  y: number;
695
704
  }): LatLng;
705
+ downloadOfflineRegion(options: DownloadOfflineRegionOptions): Promise<any>;
706
+ listOfflineRegions(options?: ListOfflineRegionsOptions): Promise<OfflineRegion[]>;
707
+ deleteOfflineRegion(options: DeleteOfflineRegionOptions): Promise<any>;
696
708
  }
697
709
  /**
698
710
  * Properties definitions for the Mapbox XML tag.
@@ -730,6 +742,24 @@ export declare const delayProperty: Property<MapboxViewCommonBase, number>;
730
742
  * @link https://docs.nativescript.org/plugins/ui-plugin-custom
731
743
  */
732
744
  export declare abstract class MapboxViewBase extends MapboxViewCommonBase {
745
+ [zoomLevelProperty.setNative]: (value: number) => void;
746
+ [mapStyleProperty.setNative]: (value: string) => void;
747
+ [accessTokenProperty.setNative]: (value: string) => void;
748
+ [delayProperty.setNative]: (value: number) => void;
749
+ [latitudeProperty.setNative]: (value: number) => void;
750
+ [longitudeProperty.setNative]: (value: number) => void;
751
+ [showUserLocationProperty.setNative]: (value: boolean) => void;
752
+ [locationComponentOptionsProperty.setNative]: (value: boolean) => void;
753
+ [hideLogoProperty.setNative]: (value: boolean) => void;
754
+ [logoPositionProperty.setNative]: (value: ControlPosition) => void;
755
+ [hideAttributionProperty.setNative]: (value: boolean) => void;
756
+ [attributionPositionProperty.setNative]: (value: ControlPosition) => void;
757
+ [hideCompassProperty.setNative]: (value: boolean) => void;
758
+ [compassPositionProperty.setNative]: (value: ControlPosition) => void;
759
+ [disableZoomProperty.setNative]: (value: boolean) => void;
760
+ [disableRotationProperty.setNative]: (value: boolean) => void;
761
+ [disableScrollProperty.setNative]: (value: boolean) => void;
762
+ [disableTiltProperty.setNative]: (value: boolean) => void;
733
763
  static mapReadyEvent: string;
734
764
  static scrollEvent: string;
735
765
  static moveBeginEvent: string;
package/common.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { check, request } from '@nativescript-community/perms';
1
2
  import { ContentView, ImageSource, Property, Trace, Utils, booleanConverter } from '@nativescript/core';
2
3
  export * from './geo.utils';
3
4
  export * from './expression/expression-parser';
@@ -61,9 +62,15 @@ export class MapboxCommon {
61
62
  }
62
63
  return result;
63
64
  }
64
- async requestFineLocationPermission() { }
65
65
  async hasFineLocationPermission() {
66
- return true;
66
+ return (await check('location')) === 'authorized';
67
+ }
68
+ /**
69
+ * Request fine locaion permission
70
+ *
71
+ */
72
+ async requestFineLocationPermission() {
73
+ return request('location');
67
74
  }
68
75
  async fetchImageSource(imagePath) {
69
76
  if (Utils.isDataURI(imagePath)) {
@@ -77,7 +84,7 @@ export class MapboxCommon {
77
84
  }
78
85
  }
79
86
  MapboxCommon.defaults = {
80
- style: MapStyle.STREETS.toString(),
87
+ style: MapStyle.STREETS,
81
88
  margins: {
82
89
  left: 0,
83
90
  right: 0,
@@ -145,14 +152,14 @@ export class MapboxViewCommonBase extends ContentView {
145
152
  setOnFlingListener(listener, nativeMap) {
146
153
  return this.mapbox.setOnFlingListener(listener, this.getNativeMapView());
147
154
  }
148
- setOnCameraMoveListener(listener, nativeMap) {
149
- return this.mapbox.setOnCameraMoveListener(listener, this.getNativeMapView());
155
+ setOnCameraChangeListener(listener, nativeMap) {
156
+ return this.mapbox.setOnCameraChangeListener(listener, this.getNativeMapView());
150
157
  }
151
158
  setOnCameraMoveCancelListener(listener, nativeMap) {
152
159
  return this.mapbox.setOnCameraMoveCancelListener(listener, this.getNativeMapView());
153
160
  }
154
161
  setOnCameraIdleListener(listener, nativeMap) {
155
- return this.mapbox.setOnCameraIdleListener(listener, this.getNativeMapView());
162
+ return this.mapbox.setOnMapIdleListener(listener, this.getNativeMapView());
156
163
  }
157
164
  getViewport() {
158
165
  return this.mapbox.getViewport(this.getNativeMapView());
@@ -190,18 +197,18 @@ export class MapboxViewCommonBase extends ContentView {
190
197
  hideUserLocationMarker() {
191
198
  this.mapbox.hideUserLocationMarker(this.getNativeMapView());
192
199
  }
193
- changeUserLocationMarkerMode(renderModeString, cameraModeString) {
194
- this.mapbox.changeUserLocationMarkerMode(renderModeString, cameraModeString, this.getNativeMapView());
195
- }
200
+ // changeUserLocationMarkerMode(renderModeString, cameraModeString: UserLocationCameraMode): void {
201
+ // this.mapbox.changeUserLocationMarkerMode(renderModeString, cameraModeString, this.getNativeMapView());
202
+ // }
196
203
  forceUserLocationUpdate(location) {
197
204
  this.mapbox.forceUserLocationUpdate(location, this.getNativeMapView());
198
205
  }
199
206
  trackUser(options) {
200
207
  return this.mapbox.trackUser(options, this.getNativeMapView());
201
208
  }
202
- getUserLocationCameraMode() {
203
- return this.mapbox.getUserLocationCameraMode(this.getNativeMapView());
204
- }
209
+ // getUserLocationCameraMode(): UserLocationCameraMode {
210
+ // return this.mapbox.getUserLocationCameraMode(this.getNativeMapView());
211
+ // }
205
212
  addSource(id, options) {
206
213
  return this.mapbox.addSource(id, options, this.getNativeMapView());
207
214
  }
@@ -257,31 +264,40 @@ export class MapboxViewCommonBase extends ContentView {
257
264
  return this.mapbox.removeImage(imageId, this.getNativeMapView());
258
265
  }
259
266
  destroy() {
260
- return this.mapbox && this.mapbox.destroy(this.getNativeMapView());
267
+ return this.mapbox?.destroy(this.getNativeMapView());
261
268
  }
262
269
  onStart() {
263
- return this.mapbox && this.mapbox.onStart(this.getNativeMapView());
264
- }
265
- onResume(nativeMap) {
266
- return this.mapbox && this.mapbox.onResume(this.getNativeMapView());
267
- }
268
- onPause(nativeMap) {
269
- return this.mapbox && this.mapbox.onPause(this.getNativeMapView());
270
- }
270
+ return this.mapbox?.onStart(this.getNativeMapView());
271
+ }
272
+ // onResume(nativeMap?: any): Promise<any> {
273
+ // return this.mapbox && this.mapbox.onResume(this.getNativeMapView());
274
+ // }
275
+ // onPause(nativeMap?: any): Promise<any> {
276
+ // return this.mapbox && this.mapbox.onPause(this.getNativeMapView());
277
+ // }
271
278
  onStop(nativeMap) {
272
- return this.mapbox && this.mapbox.onStop(this.getNativeMapView());
273
- }
274
- onLowMemory(nativeMap) {
275
- return this.mapbox.onLowMemory(this.getNativeMapView());
279
+ return this.mapbox?.onStop(this.getNativeMapView());
276
280
  }
281
+ // onLowMemory(nativeMap?: any): Promise<any> {
282
+ // return this.mapbox.onLowMemory(this.getNativeMapView());
283
+ // }
277
284
  onDestroy(nativeMap) {
278
- return this.mapbox && this.mapbox.onDestroy(this.getNativeMapView());
285
+ return this.mapbox?.onDestroy(this.getNativeMapView());
279
286
  }
280
287
  project(data) {
281
- return this.mapbox && this.mapbox.project(data);
288
+ return this.mapbox.project(data);
282
289
  }
283
290
  projectBack(screenCoordinate) {
284
- return this.mapbox && this.mapbox.projectBack(screenCoordinate);
291
+ return this.mapbox.projectBack(screenCoordinate);
292
+ }
293
+ downloadOfflineRegion(options) {
294
+ return this.mapbox.downloadOfflineRegion(options);
295
+ }
296
+ listOfflineRegions(options) {
297
+ return this.mapbox.listOfflineRegions(options);
298
+ }
299
+ deleteOfflineRegion(options) {
300
+ return this.mapbox.deleteOfflineRegion(options);
285
301
  }
286
302
  }
287
303
  // -----------------------------------------------------------------
@@ -1,4 +1,4 @@
1
1
  export declare class ExpressionParser {
2
- static parseJson(json: any[]): com.mapbox.mapboxsdk.style.expressions.Expression;
3
- static toJson(filter: com.mapbox.mapboxsdk.style.expressions.Expression): any[];
2
+ static parseJson(json: any[]): com.mapbox.maps.extension.style.expressions.generated.Expression;
3
+ static toJson(filter: com.mapbox.maps.extension.style.expressions.generated.Expression): any[];
4
4
  }
@@ -1,16 +1,17 @@
1
+ const Expression = com.mapbox.maps.extension.style.expressions.generated.Expression;
1
2
  export class ExpressionParser {
2
3
  static parseJson(json) {
3
- const expression = com.mapbox.mapboxsdk.style.expressions.Expression.Converter.convert(JSON.stringify(json));
4
+ const expression = Expression.fromRaw(JSON.stringify(json));
4
5
  return expression;
5
6
  }
6
7
  static toJson(filter) {
7
8
  if (!filter) {
8
9
  return null;
9
10
  }
10
- if (!(filter instanceof com.mapbox.mapboxsdk.style.expressions.Expression)) {
11
+ if (!(filter instanceof com.mapbox.maps.extension.style.expressions.generated.Expression)) {
11
12
  throw new Error('Filter must be a Expression.');
12
13
  }
13
- return JSON.parse(filter.toString());
14
+ return JSON.parse(filter.toJson());
14
15
  }
15
16
  }
16
17
  //# sourceMappingURL=expression-parser.android.js.map
@@ -1,4 +1,4 @@
1
1
  export declare class ExpressionParser {
2
- static parseJson(json: any[]): NSPredicate;
3
- static toJson(filter: NSPredicate): any[];
2
+ static parseJson(json: any[]): any;
3
+ static toJson(filter: any): any[] | null;
4
4
  }
@@ -1,22 +1,37 @@
1
+ // src/ui-mapbox/expression-parser.ios.ts
2
+ // TypeScript shim that exports ExpressionParser (TS API) while delegating to native NativeExpressionParser when available.
1
3
  export class ExpressionParser {
4
+ // Return native predicate object (opaque) if native parser available, otherwise return the expression JSON.
2
5
  static parseJson(json) {
3
- const filterStr = NSString.stringWithString(JSON.stringify(json));
4
- const filterData = filterStr.dataUsingEncoding(NSUTF8StringEncoding);
5
- const filterJson = NSJSONSerialization.JSONObjectWithDataOptionsError(filterData, 1 /* NSJSONReadingOptions.MutableContainers */);
6
- const predicateFilter = NSPredicate.predicateWithMGLJSONObject(filterJson);
7
- return predicateFilter;
6
+ try {
7
+ if (global.NativeExpressionParser && global.NativeExpressionParser.parseJson) {
8
+ const res = global.NativeExpressionParser.parseJson(json);
9
+ if (res)
10
+ return res;
11
+ }
12
+ }
13
+ catch (e) {
14
+ // ignore and fallback
15
+ }
16
+ return json;
8
17
  }
18
+ // Try to convert native predicate back to JSON expression. Returns array or null.
9
19
  static toJson(filter) {
10
- if (!filter) {
11
- return null;
20
+ try {
21
+ if (!filter)
22
+ return null;
23
+ if (Array.isArray(filter))
24
+ return filter;
25
+ if (global.NativeExpressionParser && global.NativeExpressionParser.toJson) {
26
+ const res = global.NativeExpressionParser.toJson(filter);
27
+ if (res)
28
+ return res;
29
+ }
12
30
  }
13
- if (!(filter instanceof NSPredicate)) {
14
- throw new Error('Filter must be a NSPredicate.');
31
+ catch (e) {
32
+ // ignore
15
33
  }
16
- const expressionObj = filter.mgl_jsonExpressionObject;
17
- const data = NSJSONSerialization.dataWithJSONObjectOptionsError(expressionObj, 0);
18
- const expression = NSString.alloc().initWithDataEncoding(data, NSUTF8StringEncoding);
19
- return JSON.parse(expression);
34
+ return null;
20
35
  }
21
36
  }
22
37
  //# sourceMappingURL=expression-parser.ios.js.map