@rnmapbox/maps 10.0.0-beta.43 → 10.0.0-beta.45

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 (58) hide show
  1. package/android/install.md +49 -1
  2. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/camera/CameraStop.java +4 -4
  3. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.java +3 -3
  4. package/android/rctmgl/src/main/java-mapboxgl/common/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/RCTMGLPackage.java +0 -2
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerView.kt +162 -51
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewManager.kt +10 -0
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLPointAnnotation.kt +6 -6
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/camera/CameraStop.kt +11 -7
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/images/RCTMGLImages.kt +22 -2
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/mapview/RCTMGLMapView.kt +17 -19
  12. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyle.kt +1 -1
  13. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/modules/RCTMGLSnapshotModule.java +1 -1
  14. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/utils/DownloadMapImageTask.kt +2 -1
  15. package/docs/MapboxGL.md +1 -1
  16. package/docs/MarkerView.md +17 -10
  17. package/docs/PointAnnotation.md +1 -1
  18. package/docs/ShapeSource.md +13 -9
  19. package/docs/SymbolLayer.md +1 -1
  20. package/docs/docs.json +145 -161
  21. package/index.d.ts +7 -56
  22. package/ios/RCTMGL-v10/RCTLog.swift +5 -5
  23. package/ios/RCTMGL-v10/RCTMGLCamera.swift +2 -2
  24. package/ios/RCTMGL-v10/RCTMGLMapViewManager.swift +2 -2
  25. package/ios/RCTMGL-v10/RCTMGLMarkerView.swift +186 -105
  26. package/ios/RCTMGL-v10/RCTMGLMarkerViewManager.m +2 -1
  27. package/ios/RCTMGL-v10/RCTMGLShapeSourceManager.swift +1 -1
  28. package/ios/RCTMGL-v10/RCTMGLUtils.swift +1 -1
  29. package/ios/RCTMGL-v10/RCTMGLVectorLayer.swift +1 -1
  30. package/ios/install.md +3 -2
  31. package/javascript/components/AbstractLayer.tsx +9 -6
  32. package/javascript/components/AbstractSource.tsx +23 -0
  33. package/javascript/components/HeadingIndicator.tsx +1 -1
  34. package/javascript/components/Images.js +1 -1
  35. package/javascript/components/MapView.js +5 -2
  36. package/javascript/components/MarkerView.tsx +81 -76
  37. package/javascript/components/NativeBridgeComponent.tsx +20 -14
  38. package/javascript/components/PointAnnotation.tsx +3 -2
  39. package/javascript/components/RasterSource.js +1 -1
  40. package/javascript/components/ShapeSource.tsx +412 -0
  41. package/javascript/components/Style.js +2 -2
  42. package/javascript/components/SymbolLayer.tsx +3 -5
  43. package/javascript/components/VectorSource.js +6 -3
  44. package/javascript/components/annotations/Annotation.js +1 -1
  45. package/javascript/index.js +2 -2
  46. package/javascript/utils/animated/Animated.js +2 -2
  47. package/javascript/utils/deprecation.ts +7 -4
  48. package/javascript/utils/filterUtils.tsx +1 -1
  49. package/javascript/utils/index.d.ts +19 -6
  50. package/package.json +1 -1
  51. package/scripts/autogenHelpers/DocJSONBuilder.js +17 -1
  52. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapper.kt +0 -8
  53. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/annotation/RCTMGLMarkerViewWrapperManager.kt +0 -21
  54. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapper.swift +0 -24
  55. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.m +0 -8
  56. package/ios/RCTMGL-v10/RCTMGLMarkerViewWrapperManager.swift +0 -14
  57. package/javascript/components/AbstractSource.js +0 -15
  58. package/javascript/components/ShapeSource.js +0 -373
@@ -0,0 +1,412 @@
1
+ import React from 'react';
2
+ import {
3
+ HostComponent,
4
+ NativeMethods,
5
+ NativeModules,
6
+ NativeSyntheticEvent,
7
+ requireNativeComponent,
8
+ } from 'react-native';
9
+
10
+ import { getFilter } from '../utils/filterUtils';
11
+ import {
12
+ toJSONString,
13
+ cloneReactChildrenWithProps,
14
+ isFunction,
15
+ isAndroid,
16
+ } from '../utils';
17
+ import { copyPropertiesAsDeprecated } from '../utils/deprecation';
18
+
19
+ import AbstractSource from './AbstractSource';
20
+ import NativeBridgeComponent from './NativeBridgeComponent';
21
+
22
+ const MapboxGL = NativeModules.MGLModule;
23
+
24
+ export const NATIVE_MODULE_NAME = 'RCTMGLShapeSource';
25
+
26
+ export type OnPressEvent = {
27
+ features: Array<GeoJSON.Feature>;
28
+ coordinates: {
29
+ latitude: number;
30
+ longitude: number;
31
+ };
32
+ point: {
33
+ x: number;
34
+ y: number;
35
+ };
36
+ };
37
+ type OnPressEventDeprecated = OnPressEvent & {
38
+ nativeEvent?: OnPressEvent;
39
+ };
40
+
41
+ export type Props = {
42
+ /**
43
+ * A string that uniquely identifies the source.
44
+ */
45
+ id: string;
46
+
47
+ /**
48
+ * An HTTP(S) URL, absolute file URL, or local file URL relative to the current application’s resource bundle.
49
+ */
50
+ url?: string;
51
+
52
+ /**
53
+ * The contents of the source. A shape can represent a GeoJSON geometry, a feature, or a feature collection.
54
+ */
55
+ shape?:
56
+ | GeoJSON.GeometryCollection
57
+ | GeoJSON.Feature
58
+ | GeoJSON.FeatureCollection
59
+ | GeoJSON.Geometry;
60
+
61
+ /**
62
+ * Enables clustering on the source for point shapes.
63
+ */
64
+ cluster?: boolean;
65
+
66
+ /**
67
+ * Specifies the radius of each cluster if clustering is enabled.
68
+ * A value of 512 produces a radius equal to the width of a tile.
69
+ * The default value is 50.
70
+ */
71
+ clusterRadius?: number;
72
+
73
+ /**
74
+ * Specifies the maximum zoom level at which to cluster points if clustering is enabled.
75
+ * Defaults to one zoom level less than the value of maxZoomLevel so that, at the maximum zoom level,
76
+ * the shapes are not clustered.
77
+ */
78
+ clusterMaxZoomLevel?: number;
79
+
80
+ /**
81
+ * [`mapbox-gl` (v8) implementation only]
82
+ * Specifies custom properties on the generated clusters if clustering
83
+ * is enabled, aggregating values from clustered points.
84
+ *
85
+ * Has the form `{ "property_name": [operator, map_expression]}`, where
86
+ * `operator` is a custom reduce expression that references a special `["accumulated"]` value -
87
+ * it accumulates the property value from clusters/points the cluster contains
88
+ * `map_expression` produces the value of a single point
89
+ *
90
+ * Example: `{ "resultingSum": [["+", ["accumulated"], ["get", "resultingSum"]], ["get", "scalerank"]] }`
91
+ *
92
+ */
93
+ clusterProperties?: object;
94
+
95
+ /**
96
+ * Specifies the maximum zoom level at which to create vector tiles.
97
+ * A greater value produces greater detail at high zoom levels.
98
+ * The default value is 18.
99
+ */
100
+ maxZoomLevel?: number;
101
+
102
+ /**
103
+ * Specifies the size of the tile buffer on each side.
104
+ * A value of 0 produces no buffer. A value of 512 produces a buffer as wide as the tile itself.
105
+ * Larger values produce fewer rendering artifacts near tile edges and slower performance.
106
+ * The default value is 128.
107
+ */
108
+ buffer?: number;
109
+
110
+ /**
111
+ * Specifies the Douglas-Peucker simplification tolerance.
112
+ * A greater value produces simpler geometries and improves performance.
113
+ * The default value is 0.375.
114
+ */
115
+ tolerance?: number;
116
+
117
+ /**
118
+ * Whether to calculate line distance metrics.
119
+ * This is required for line layers that specify lineGradient values.
120
+ * The default value is false.
121
+ */
122
+ lineMetrics?: boolean;
123
+
124
+ /**
125
+ * Source press listener, gets called when a user presses one of the children layers only
126
+ * if that layer has a higher z-index than another source layers
127
+ *
128
+ * @param {Object} event
129
+ * @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
130
+ * @param {Object} event.coordinates - the coordinates of the click
131
+ * @param {Object} event.point - the point of the click
132
+ * @return void
133
+ */
134
+ onPress?: (event: OnPressEvent) => void;
135
+
136
+ /**
137
+ * Overrides the default touch hitbox(44x44 pixels) for the source layers
138
+ */
139
+ hitbox?: {
140
+ /**
141
+ * `width` of hitbox
142
+ */
143
+ width: number;
144
+ /**
145
+ * `height` of hitbox
146
+ */
147
+ height: number;
148
+ };
149
+
150
+ children: React.ReactElement | React.ReactElement[];
151
+ };
152
+
153
+ /**
154
+ * ShapeSource is a map content source that supplies vector shapes to be shown on the map.
155
+ * The shape may be an url or a GeoJSON object
156
+ */
157
+ export class ShapeSource extends NativeBridgeComponent(
158
+ AbstractSource<Props, NativeProps>,
159
+ NATIVE_MODULE_NAME,
160
+ ) {
161
+ static NATIVE_ASSETS_KEY = 'assets';
162
+
163
+ static defaultProps = {
164
+ id: MapboxGL.StyleSource.DefaultSourceID,
165
+ };
166
+
167
+ constructor(props: Props) {
168
+ super(props);
169
+ }
170
+
171
+ _setNativeRef(
172
+ nativeRef: React.Component<NativeProps> & Readonly<NativeMethods>,
173
+ ) {
174
+ this.setNativeRef(nativeRef);
175
+ super._runPendingNativeCommands(nativeRef);
176
+ }
177
+
178
+ /**
179
+ * Returns all features from the source that match the query parameters whether the feature is currently
180
+ * rendered on the map.
181
+ *
182
+ * @example
183
+ * shapeSource.features()
184
+ *
185
+ * @param {Array=} filter - an optional filter statement to filter the returned Features.
186
+ * @return {FeatureCollection}
187
+ */
188
+ async features(filter: Array<string> = []) {
189
+ const res: { data: string } = await this._runNativeCommand(
190
+ 'features',
191
+ this._nativeRef,
192
+ getFilter(filter),
193
+ );
194
+
195
+ if (isAndroid()) {
196
+ return JSON.parse(res.data);
197
+ }
198
+
199
+ return res.data;
200
+ }
201
+
202
+ /**
203
+ * Returns the zoom needed to expand the cluster.
204
+ *
205
+ * @example
206
+ * const zoom = await shapeSource.getClusterExpansionZoom(clusterId);
207
+ *
208
+ * @param {Feature} feature - The feature cluster to expand.
209
+ * @return {number}
210
+ */
211
+ async getClusterExpansionZoom(
212
+ feature: string | GeoJSON.Feature,
213
+ ): Promise<string> {
214
+ if (typeof feature === 'number') {
215
+ console.warn(
216
+ 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
217
+ );
218
+ const res: { data: string } = await this._runNativeCommand(
219
+ 'getClusterExpansionZoomById',
220
+ this._nativeRef,
221
+ [feature],
222
+ );
223
+ return res.data;
224
+ }
225
+
226
+ const res: { data: string } = await this._runNativeCommand(
227
+ 'getClusterExpansionZoom',
228
+ this._nativeRef,
229
+ [JSON.stringify(feature)],
230
+ );
231
+ return res.data;
232
+ }
233
+
234
+ /**
235
+ * Returns the FeatureCollection from the cluster.
236
+ *
237
+ * @example
238
+ * const collection = await shapeSource.getClusterLeaves(clusterId, limit, offset);
239
+ *
240
+ * @param {GeoJSON.Feature} feature - The feature cluster to expand.
241
+ * @param {number} limit - The number of points to return.
242
+ * @param {number} offset - The amount of points to skip (for pagination).
243
+ * @return {FeatureCollection}
244
+ */
245
+ async getClusterLeaves(
246
+ feature: number | GeoJSON.Feature,
247
+ limit: number,
248
+ offset: number,
249
+ ) {
250
+ if (typeof feature === 'number') {
251
+ console.warn(
252
+ 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
253
+ );
254
+ const res: { data: string } = await this._runNativeCommand(
255
+ 'getClusterLeavesById',
256
+ this._nativeRef,
257
+ [feature, limit, offset],
258
+ );
259
+
260
+ if (isAndroid()) {
261
+ return JSON.parse(res.data);
262
+ }
263
+
264
+ return res.data;
265
+ }
266
+
267
+ const res: { data: string } = await this._runNativeCommand(
268
+ 'getClusterLeaves',
269
+ this._nativeRef,
270
+ [JSON.stringify(feature), limit, offset],
271
+ );
272
+
273
+ if (isAndroid()) {
274
+ return JSON.parse(res.data);
275
+ }
276
+
277
+ return res.data;
278
+ }
279
+
280
+ /**
281
+ * Returns the FeatureCollection from the cluster (on the next zoom level).
282
+ *
283
+ * @example
284
+ * const collection = await shapeSource.getClusterChildren(clusterId);
285
+ *
286
+ * @param {GeoJSON.Feature} feature - The feature cluster to expand.
287
+ * @return {FeatureCollection}
288
+ */
289
+ async getClusterChildren(feature: number | GeoJSON.Feature) {
290
+ if (typeof feature === 'number') {
291
+ console.warn(
292
+ 'Using cluster_id is deprecated and will be removed from the future releases. Please use cluster as an argument instead.',
293
+ );
294
+ const res: { data: string } = await this._runNativeCommand(
295
+ 'getClusterChildrenById',
296
+ this._nativeRef,
297
+ [feature],
298
+ );
299
+
300
+ if (isAndroid()) {
301
+ return JSON.parse(res.data);
302
+ }
303
+
304
+ return res.data;
305
+ }
306
+
307
+ const res: { data: string } = await this._runNativeCommand(
308
+ 'getClusterChildren',
309
+ this._nativeRef,
310
+ [JSON.stringify(feature)],
311
+ );
312
+
313
+ if (isAndroid()) {
314
+ return JSON.parse(res.data);
315
+ }
316
+
317
+ return res.data;
318
+ }
319
+
320
+ setNativeProps(props: NativeProps) {
321
+ const shallowProps = Object.assign({}, props);
322
+
323
+ // Adds support for Animated
324
+ if (shallowProps.shape && typeof shallowProps.shape !== 'string') {
325
+ shallowProps.shape = JSON.stringify(shallowProps.shape);
326
+ }
327
+
328
+ super.setNativeProps(shallowProps);
329
+ }
330
+
331
+ _getShape() {
332
+ if (!this.props.shape) {
333
+ return;
334
+ }
335
+ return toJSONString(this.props.shape);
336
+ }
337
+
338
+ onPress(
339
+ event: NativeSyntheticEvent<{
340
+ payload: OnPressEvent;
341
+ }>,
342
+ ) {
343
+ const {
344
+ nativeEvent: {
345
+ payload: { features, coordinates, point },
346
+ },
347
+ } = event;
348
+ let newEvent: OnPressEventDeprecated = {
349
+ features,
350
+ coordinates,
351
+ point,
352
+ };
353
+
354
+ newEvent = copyPropertiesAsDeprecated(
355
+ event as unknown as Record<string, unknown>,
356
+ newEvent,
357
+ (key) => {
358
+ console.warn(
359
+ `event.${key} is deprecated on ShapeSource#onPress, please use event.features`,
360
+ );
361
+ },
362
+ {
363
+ nativeEvent: (origNativeEvent: unknown) => ({
364
+ ...(origNativeEvent as OnPressEvent),
365
+ payload: features[0],
366
+ }),
367
+ },
368
+ );
369
+ this.props.onPress?.(newEvent);
370
+ }
371
+
372
+ render() {
373
+ const props = {
374
+ id: this.props.id,
375
+ url: this.props.url,
376
+ shape: this._getShape(),
377
+ hitbox: this.props.hitbox,
378
+ hasPressListener: isFunction(this.props.onPress),
379
+ onMapboxShapeSourcePress: this.onPress.bind(this),
380
+ cluster: this.props.cluster ? 1 : 0,
381
+ clusterRadius: this.props.clusterRadius,
382
+ clusterMaxZoomLevel: this.props.clusterMaxZoomLevel,
383
+ clusterProperties: this.props.clusterProperties,
384
+ maxZoomLevel: this.props.maxZoomLevel,
385
+ buffer: this.props.buffer,
386
+ tolerance: this.props.tolerance,
387
+ lineMetrics: this.props.lineMetrics,
388
+ onPress: undefined,
389
+ ref: (
390
+ nativeRef: React.Component<NativeProps> & Readonly<NativeMethods>,
391
+ ) => this._setNativeRef(nativeRef),
392
+ onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
393
+ };
394
+
395
+ return (
396
+ <RCTMGLShapeSource {...props}>
397
+ {cloneReactChildrenWithProps(this.props.children, {
398
+ sourceID: this.props.id,
399
+ })}
400
+ </RCTMGLShapeSource>
401
+ );
402
+ }
403
+ }
404
+
405
+ type NativeProps = {
406
+ id: string;
407
+ shape?: string;
408
+ };
409
+
410
+ type NativeShapeSource = HostComponent<NativeProps>;
411
+ const RCTMGLShapeSource: NativeShapeSource =
412
+ requireNativeComponent(NATIVE_MODULE_NAME);
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
 
4
4
  import CircleLayer from './CircleLayer';
5
5
  import RasterLayer from './RasterLayer';
6
- import SymbolLayer from './SymbolLayer';
6
+ import { SymbolLayer } from './SymbolLayer';
7
7
  import LineLayer from './LineLayer';
8
8
  import FillLayer from './FillLayer';
9
9
  import FillExtrusionLayer from './FillExtrusionLayer';
@@ -12,7 +12,7 @@ import HeatmapLayer from './HeatmapLayer';
12
12
  import VectorSource from './VectorSource';
13
13
  import RasterSource from './RasterSource';
14
14
  import ImageSource from './ImageSource';
15
- import ShapeSource from './ShapeSource';
15
+ import { ShapeSource } from './ShapeSource';
16
16
 
17
17
  function toCamelCase(s) {
18
18
  return s.replace(/([-_][a-z])/gi, ($1) => {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { View, NativeModules, requireNativeComponent } from 'react-native';
3
3
 
4
- import { type SymbolLayerStyleProps } from '../utils/MapboxStyles';
4
+ import { Expression, type SymbolLayerStyleProps } from '../utils/MapboxStyles';
5
5
  import { type StyleValue } from '../utils/StyleValue';
6
6
 
7
7
  import AbstractLayer from './AbstractLayer';
@@ -46,7 +46,7 @@ export type Props = {
46
46
  /**
47
47
  * Filter only the features in the source layer that satisfy a condition that you define
48
48
  */
49
- filter?: string[];
49
+ filter?: Expression;
50
50
 
51
51
  /**
52
52
  * The minimum zoom level at which the layer gets parsed and appears.
@@ -74,7 +74,7 @@ const RCTMGLSymbolLayer =
74
74
  /**
75
75
  * SymbolLayer is a style layer that renders icon and text labels at points or along lines on the map.
76
76
  */
77
- class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
77
+ export class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
78
78
  static defaultProps = {
79
79
  sourceID: MapboxGL.StyleSource.DefaultSourceID,
80
80
  };
@@ -109,5 +109,3 @@ class SymbolLayer extends AbstractLayer<Props, NativeTypeProps> {
109
109
  );
110
110
  }
111
111
  }
112
-
113
- export default SymbolLayer;
@@ -22,7 +22,10 @@ export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
22
22
  * VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
23
23
  * The location of and metadata about the tiles are defined either by an option dictionary or by an external file that conforms to the TileJSON specification.
24
24
  */
25
- class VectorSource extends NativeBridgeComponent(AbstractSource) {
25
+ class VectorSource extends NativeBridgeComponent(
26
+ AbstractSource,
27
+ NATIVE_MODULE_NAME,
28
+ ) {
26
29
  static propTypes = {
27
30
  ...viewPropTypes,
28
31
 
@@ -98,7 +101,7 @@ class VectorSource extends NativeBridgeComponent(AbstractSource) {
98
101
  };
99
102
 
100
103
  constructor(props) {
101
- super(props, NATIVE_MODULE_NAME);
104
+ super(props);
102
105
  }
103
106
 
104
107
  _setNativeRef(nativeRef) {
@@ -177,7 +180,7 @@ class VectorSource extends NativeBridgeComponent(AbstractSource) {
177
180
  onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
178
181
  };
179
182
  return (
180
- <RCTMGLVectorSource ref="nativeSource" {...props}>
183
+ <RCTMGLVectorSource ref={this.setNativeRef} {...props}>
181
184
  {cloneReactChildrenWithProps(this.props.children, {
182
185
  sourceID: this.props.id,
183
186
  })}
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Easing } from 'react-native';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
- import SymbolLayer from '../SymbolLayer';
5
+ import { SymbolLayer } from '../SymbolLayer';
6
6
  import Animated from '../../utils/animated/Animated';
7
7
  import { AnimatedPoint } from '../../classes';
8
8
 
@@ -9,7 +9,7 @@ import Annotation from './components/annotations/Annotation';
9
9
  import Callout from './components/Callout';
10
10
  import UserLocation from './components/UserLocation';
11
11
  import VectorSource from './components/VectorSource';
12
- import ShapeSource from './components/ShapeSource';
12
+ import { ShapeSource } from './components/ShapeSource';
13
13
  import RasterSource from './components/RasterSource';
14
14
  import RasterDemSource from './components/RasterDemSource';
15
15
  import ImageSource from './components/ImageSource';
@@ -20,7 +20,7 @@ import HeatmapLayer from './components/HeatmapLayer';
20
20
  import LineLayer from './components/LineLayer';
21
21
  import CircleLayer from './components/CircleLayer';
22
22
  import SkyLayer from './components/SkyLayer';
23
- import SymbolLayer from './components/SymbolLayer';
23
+ import { SymbolLayer } from './components/SymbolLayer';
24
24
  import RasterLayer from './components/RasterLayer';
25
25
  import BackgroundLayer from './components/BackgroundLayer';
26
26
  import { Terrain } from './components/Terrain';
@@ -1,12 +1,12 @@
1
1
  import { Animated as RNAnimated } from 'react-native';
2
2
 
3
- import ShapeSource from '../../components/ShapeSource';
3
+ import { ShapeSource } from '../../components/ShapeSource';
4
4
  import ImageSource from '../../components/ImageSource';
5
5
  import FillLayer from '../../components/FillLayer';
6
6
  import FillExtrusionLayer from '../../components/FillExtrusionLayer';
7
7
  import LineLayer from '../../components/LineLayer';
8
8
  import CircleLayer from '../../components/CircleLayer';
9
- import SymbolLayer from '../../components/SymbolLayer';
9
+ import { SymbolLayer } from '../../components/SymbolLayer';
10
10
  import RasterLayer from '../../components/RasterLayer';
11
11
  import BackgroundLayer from '../../components/BackgroundLayer';
12
12
 
@@ -18,12 +18,15 @@ export function deprecatedClass<C extends new (...args: any[]) => object>(
18
18
  * Copy properties from origObject to newObject, which not exists in newObject,
19
19
  * calls onDeprecatedCalled callback in case a copied property is invoked.
20
20
  */
21
- export function copyPropertiesAsDeprecated(
22
- origObject: { [key: string]: unknown },
23
- newObject: { [key: string]: unknown },
21
+ export function copyPropertiesAsDeprecated<
22
+ DeprecatedType extends Record<string, unknown>,
23
+ WithDeprecatedType extends Record<string, unknown>,
24
+ >(
25
+ origObject: DeprecatedType,
26
+ newObject: WithDeprecatedType,
24
27
  onDeprecatedCalled: (key: string) => void,
25
28
  accessors: { [key: string]: (value: unknown) => unknown } = {},
26
- ): { [key: string]: unknown } {
29
+ ): WithDeprecatedType {
27
30
  const result = newObject;
28
31
  for (const [key, value] of Object.entries(origObject)) {
29
32
  if (!newObject[key]) {
@@ -1,4 +1,4 @@
1
- export function getFilter(filter: string[] | unknown) {
1
+ export function getFilter(filter: string[] | unknown): string[] {
2
2
  if (!Array.isArray(filter) || filter.length === 0) {
3
3
  return [];
4
4
  }
@@ -1,14 +1,27 @@
1
+ import React from 'react';
2
+
3
+ export type NativeArg =
4
+ | string
5
+ | number
6
+ | { [k: string]: NativeArg }
7
+ | NativeArg[];
8
+
1
9
  export function isAndroid(): boolean;
2
- export function isBoolean(_: unknown): argument is boolean;
3
- export function isNumber(_: unknown): argument is number;
4
- export function isString(_: unknown): argument is string;
10
+ export function isBoolean(argument: unknown): argument is boolean;
11
+ export function isNumber(argument: unknown): argument is number;
12
+ export function isString(argument: unknown): argument is string;
5
13
  // eslint-disable-next-line @typescript-eslint/ban-types
6
14
  export function isFunction(argument: unknown): argument is Function;
7
15
 
8
16
  export function toJSONString(_: unknown): string;
9
- export function runNativeCommand<RefType>(
17
+ export function runNativeCommand<RefType, ReturnType = NativeArg>(
10
18
  module: string,
11
19
  name: string,
12
20
  nativeRef: RefType,
13
- args: string[],
14
- ): void;
21
+ args: NativeArg[],
22
+ ): Promise<ReturnType>;
23
+
24
+ export function cloneReactChildrenWithProps(
25
+ children: React.ReactElement | React.ReactElement[],
26
+ propsToAdd: { [key: string]: string } = {},
27
+ ): React.ReactElement | React.ReactElement[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rnmapbox/maps",
3
3
  "description": "A Mapbox react native module for creating custom maps",
4
- "version": "10.0.0-beta.43",
4
+ "version": "10.0.0-beta.45",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -48,6 +48,7 @@ class DocJSONBuilder {
48
48
  return {
49
49
  match: fileExtensionsRegex,
50
50
  shortName: true,
51
+ sort: true,
51
52
  };
52
53
  }
53
54
 
@@ -422,6 +423,18 @@ class DocJSONBuilder {
422
423
  });
423
424
  }
424
425
 
426
+ sortObject(not_sorted) {
427
+ return Object.keys(not_sorted)
428
+ .sort()
429
+ .reduce(
430
+ (acc, key) => ({
431
+ ...acc,
432
+ [key]: not_sorted[key],
433
+ }),
434
+ {},
435
+ );
436
+ }
437
+
425
438
  async generate() {
426
439
  this.generateModulesTask({}, MODULES_PATH);
427
440
 
@@ -433,7 +446,10 @@ class DocJSONBuilder {
433
446
  ];
434
447
 
435
448
  return Promise.all(tasks).then(() => {
436
- fs.writeFileSync(OUTPUT_PATH, JSON.stringify(results, null, 2));
449
+ fs.writeFileSync(
450
+ OUTPUT_PATH,
451
+ JSON.stringify(this.sortObject(results), null, 2),
452
+ );
437
453
  return true;
438
454
  });
439
455
  }
@@ -1,8 +0,0 @@
1
- package com.mapbox.rctmgl.components.annotation
2
- import android.content.Context
3
- import android.util.Log
4
- import android.view.View
5
- import com.facebook.react.views.view.ReactViewGroup
6
-
7
- class RCTMGLMarkerViewWrapper(context: Context?, private val mManager: RCTMGLMarkerViewWrapperManager) : ReactViewGroup(context) {
8
- }
@@ -1,21 +0,0 @@
1
- package com.mapbox.rctmgl.components.annotation
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.uimanager.ThemedReactContext
5
- import com.facebook.react.uimanager.ViewGroupManager
6
-
7
- class RCTMGLMarkerViewWrapperManager(reactApplicationContext: ReactApplicationContext?) :
8
- ViewGroupManager<RCTMGLMarkerViewWrapper>() {
9
-
10
- override fun getName(): String {
11
- return REACT_CLASS
12
- }
13
-
14
- override fun createViewInstance(reactContext: ThemedReactContext): RCTMGLMarkerViewWrapper {
15
- return RCTMGLMarkerViewWrapper(reactContext, this)
16
- }
17
-
18
- companion object {
19
- const val REACT_CLASS = "RCTMGLMarkerViewWrapper"
20
- }
21
- }