@maplibre/maplibre-react-native 9.1.0 → 10.0.0-alpha.2

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 (141) hide show
  1. package/.eslintrc.js +10 -2
  2. package/.husky/pre-commit +5 -0
  3. package/.yarn/plugins/@yarnpkg/plugin-typescript.cjs +9 -0
  4. package/.yarn/sdks/eslint/bin/eslint.js +20 -0
  5. package/.yarn/sdks/eslint/lib/api.js +20 -0
  6. package/.yarn/sdks/eslint/package.json +6 -0
  7. package/.yarn/sdks/integrations.yml +5 -0
  8. package/.yarn/sdks/prettier/index.js +20 -0
  9. package/.yarn/sdks/prettier/package.json +6 -0
  10. package/.yarn/sdks/typescript/bin/tsc +20 -0
  11. package/.yarn/sdks/typescript/bin/tsserver +20 -0
  12. package/.yarn/sdks/typescript/lib/tsc.js +20 -0
  13. package/.yarn/sdks/typescript/lib/tsserver.js +225 -0
  14. package/.yarn/sdks/typescript/lib/tsserverlibrary.js +225 -0
  15. package/.yarn/sdks/typescript/lib/typescript.js +20 -0
  16. package/.yarn/sdks/typescript/package.json +6 -0
  17. package/CHANGELOG.md +18 -0
  18. package/android/rctmgl/build.gradle +7 -7
  19. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/location/LocationManager.java +2 -2
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/modules/RCTMGLOfflineModule.java +21 -26
  21. package/docs/Annotation.md +8 -9
  22. package/docs/BackgroundLayer.md +2 -10
  23. package/docs/Callout.md +5 -5
  24. package/docs/Camera.md +18 -47
  25. package/docs/CircleLayer.md +2 -10
  26. package/docs/FillExtrusionLayer.md +2 -10
  27. package/docs/FillLayer.md +2 -10
  28. package/docs/HeatmapLayer.md +2 -10
  29. package/docs/ImageSource.md +3 -2
  30. package/docs/Images.md +5 -3
  31. package/docs/Light.md +1 -1
  32. package/docs/LineLayer.md +2 -10
  33. package/docs/MapView.md +53 -37
  34. package/docs/MarkerView.md +4 -2
  35. package/docs/NativeUserLocation.md +2 -2
  36. package/docs/PointAnnotation.md +5 -8
  37. package/docs/RasterLayer.md +2 -10
  38. package/docs/RasterSource.md +3 -2
  39. package/docs/ShapeSource.md +12 -7
  40. package/docs/Style.md +1 -1
  41. package/docs/SymbolLayer.md +3 -10
  42. package/docs/UserLocation.md +8 -10
  43. package/docs/VectorSource.md +6 -5
  44. package/docs/coordinates.md +6 -0
  45. package/docs/docs.json +518 -1272
  46. package/docs/location.md +6 -0
  47. package/docs/snapshotManager.md +3 -3
  48. package/javascript/@types/assets.d.ts +4 -0
  49. package/javascript/MGLModule.ts +37 -0
  50. package/javascript/Maplibre.ts +65 -0
  51. package/javascript/components/AbstractLayer.tsx +107 -0
  52. package/javascript/components/AbstractSource.tsx +27 -0
  53. package/javascript/components/BackgroundLayer.tsx +43 -0
  54. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  55. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  56. package/javascript/components/CircleLayer.tsx +46 -0
  57. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  58. package/javascript/components/FillLayer.tsx +41 -0
  59. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  60. package/javascript/components/HeatmapLayer.tsx +44 -0
  61. package/javascript/components/ImageSource.tsx +78 -0
  62. package/javascript/components/Images.tsx +134 -0
  63. package/javascript/components/Light.tsx +67 -0
  64. package/javascript/components/LineLayer.tsx +42 -0
  65. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  66. package/javascript/components/MarkerView.tsx +104 -0
  67. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  68. package/javascript/components/NativeUserLocation.tsx +33 -0
  69. package/javascript/components/PointAnnotation.tsx +221 -0
  70. package/javascript/components/RasterLayer.tsx +41 -0
  71. package/javascript/components/RasterSource.tsx +117 -0
  72. package/javascript/components/ShapeSource.tsx +383 -0
  73. package/javascript/components/{Style.js → Style.tsx} +129 -38
  74. package/javascript/components/SymbolLayer.tsx +72 -0
  75. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  76. package/javascript/components/VectorSource.tsx +207 -0
  77. package/javascript/components/annotations/Annotation.tsx +134 -0
  78. package/javascript/index.ts +4 -0
  79. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  80. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  81. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  82. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  83. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  84. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  85. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  86. package/javascript/types/BaseProps.ts +5 -0
  87. package/javascript/types/OnPressEvent.ts +13 -0
  88. package/javascript/types/index.ts +7 -0
  89. package/javascript/utils/BridgeValue.ts +90 -0
  90. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  91. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  92. package/javascript/utils/StyleValue.ts +49 -0
  93. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  94. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  95. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  96. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  97. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  98. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  99. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  100. package/javascript/utils/filterUtils.ts +9 -0
  101. package/javascript/utils/geoUtils.ts +79 -0
  102. package/javascript/utils/{index.js → index.ts} +44 -24
  103. package/javascript/utils/styleMap.ts +264 -0
  104. package/package.json +35 -27
  105. package/plugin/build/withMapLibre.js +18 -3
  106. package/scripts/autogenHelpers/globals.js +1 -1
  107. package/scripts/autogenerate.js +14 -6
  108. package/scripts/download-style-spec.sh +1 -1
  109. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  110. package/scripts/templates/index.d.ts.ejs +71 -42
  111. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  112. package/setup-jest.js +1 -10
  113. package/tsconfig.json +20 -61
  114. package/index.d.ts +0 -955
  115. package/javascript/components/AbstractLayer.js +0 -75
  116. package/javascript/components/AbstractSource.js +0 -15
  117. package/javascript/components/BackgroundLayer.js +0 -97
  118. package/javascript/components/CircleLayer.js +0 -101
  119. package/javascript/components/FillExtrusionLayer.js +0 -98
  120. package/javascript/components/FillLayer.js +0 -94
  121. package/javascript/components/HeatmapLayer.js +0 -99
  122. package/javascript/components/ImageSource.js +0 -82
  123. package/javascript/components/Images.js +0 -119
  124. package/javascript/components/Light.js +0 -47
  125. package/javascript/components/LineLayer.js +0 -94
  126. package/javascript/components/MarkerView.js +0 -87
  127. package/javascript/components/NativeUserLocation.js +0 -41
  128. package/javascript/components/PointAnnotation.js +0 -216
  129. package/javascript/components/RasterLayer.js +0 -95
  130. package/javascript/components/RasterSource.js +0 -124
  131. package/javascript/components/ShapeSource.js +0 -372
  132. package/javascript/components/SymbolLayer.js +0 -120
  133. package/javascript/components/VectorSource.js +0 -200
  134. package/javascript/components/annotations/Annotation.js +0 -122
  135. package/javascript/index.js +0 -149
  136. package/javascript/utils/BridgeValue.js +0 -81
  137. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  138. package/javascript/utils/filterUtils.js +0 -7
  139. package/javascript/utils/geoUtils.js +0 -73
  140. package/javascript/utils/styleMap.js +0 -1932
  141. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -1,200 +0,0 @@
1
- import {
2
- cloneReactChildrenWithProps,
3
- viewPropTypes,
4
- isFunction,
5
- isAndroid,
6
- } from '../utils';
7
- import {getFilter} from '../utils/filterUtils';
8
- import {copyPropertiesAsDeprecated} from '../utils/deprecation';
9
-
10
- import AbstractSource from './AbstractSource';
11
- import NativeBridgeComponent from './NativeBridgeComponent';
12
-
13
- import PropTypes from 'prop-types';
14
- import React from 'react';
15
- import {NativeModules, requireNativeComponent} from 'react-native';
16
-
17
- const MapLibreGL = NativeModules.MGLModule;
18
-
19
- export const NATIVE_MODULE_NAME = 'RCTMGLVectorSource';
20
-
21
- /**
22
- * VectorSource is a map content source that supplies tiled vector data in Mapbox Vector Tile format to be shown on the map.
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
- */
25
- class VectorSource extends NativeBridgeComponent(AbstractSource) {
26
- static propTypes = {
27
- ...viewPropTypes,
28
-
29
- /**
30
- * A string that uniquely identifies the source.
31
- */
32
- id: PropTypes.string.isRequired,
33
-
34
- /**
35
- * A URL to a TileJSON configuration file describing the source’s contents and other metadata.
36
- */
37
- url: PropTypes.string,
38
-
39
- /**
40
- * An array of tile URL templates. If multiple endpoints are specified, clients may use any combination of endpoints.
41
- * Example: https://example.com/vector-tiles/{z}/{x}/{y}.pbf
42
- */
43
- tileUrlTemplates: PropTypes.arrayOf(PropTypes.string),
44
-
45
- /**
46
- * An unsigned integer that specifies the minimum zoom level at which to display tiles from the source.
47
- * The value should be between 0 and 22, inclusive, and less than
48
- * maxZoomLevel, if specified. The default value for this option is 0.
49
- */
50
- minZoomLevel: PropTypes.number,
51
-
52
- /**
53
- * An unsigned integer that specifies the maximum zoom level at which to display tiles from the source.
54
- * The value should be between 0 and 22, inclusive, and less than
55
- * minZoomLevel, if specified. The default value for this option is 22.
56
- */
57
- maxZoomLevel: PropTypes.number,
58
-
59
- /**
60
- * Influences the y direction of the tile coordinates. (tms inverts y axis)
61
- */
62
- tms: PropTypes.bool,
63
-
64
- /**
65
- * An HTML or literal text string defining the buttons to be displayed in an action sheet when the
66
- * source is part of a map view’s style and the map view’s attribution button is pressed.
67
- */
68
- attribution: PropTypes.string,
69
-
70
- /**
71
- * Source press listener, gets called when a user presses one of the children layers only
72
- * if that layer has a higher z-index than another source layers
73
- *
74
- * @param {Object} event
75
- * @param {Object[]} event.features - the geojson features that have hit by the press (might be multiple)
76
- * @param {Object} event.coordinates - the coordinates of the click
77
- * @param {Object} event.point - the point of the click
78
- */
79
- onPress: PropTypes.func,
80
-
81
- /**
82
- * Overrides the default touch hitbox(44x44 pixels) for the source layers
83
- */
84
- hitbox: PropTypes.shape({
85
- /**
86
- * `width` of hitbox
87
- */
88
- width: PropTypes.number.isRequired,
89
- /**
90
- * `height` of hitbox
91
- */
92
- height: PropTypes.number.isRequired,
93
- }),
94
- };
95
-
96
- static defaultProps = {
97
- id: MapLibreGL.StyleSource.DefaultSourceID,
98
- };
99
-
100
- constructor(props) {
101
- super(props, NATIVE_MODULE_NAME);
102
- }
103
-
104
- _setNativeRef(nativeRef) {
105
- this._nativeRef = nativeRef;
106
- super._runPendingNativeCommands(nativeRef);
107
- }
108
-
109
- /**
110
- * Returns all features that match the query parameters regardless of whether or not the feature is
111
- * currently rendered on the map. The domain of the query includes all currently-loaded vector tiles
112
- * and GeoJSON source tiles. This function does not check tiles outside of the visible viewport.
113
- *
114
- * @example
115
- * vectorSource.features(['id1', 'id2'])
116
- *
117
- * @param {Array=} layerIDs - A set of strings that correspond to the names of layers defined in the current style. Only the features contained in these layers are included in the returned array.
118
- * @param {Array=} filter - an optional filter statement to filter the returned Features.
119
- * @return {FeatureCollection}
120
- */
121
- async features(layerIDs = [], filter = []) {
122
- const res = await this._runNativeCommand('features', this._nativeRef, [
123
- layerIDs,
124
- getFilter(filter),
125
- ]);
126
-
127
- if (isAndroid()) {
128
- return JSON.parse(res.data);
129
- }
130
-
131
- return res.data;
132
- }
133
-
134
- onPress(event) {
135
- const {
136
- nativeEvent: {
137
- payload: {features, coordinates, point},
138
- },
139
- } = event;
140
- let newEvent = {
141
- features,
142
- coordinates,
143
- point,
144
- };
145
- newEvent = copyPropertiesAsDeprecated(
146
- event,
147
- newEvent,
148
- key => {
149
- console.warn(
150
- `event.${key} is deprecated on VectorSource#onPress, please use event.features`,
151
- );
152
- },
153
- {
154
- nativeEvent: origNativeEvent => ({
155
- ...origNativeEvent,
156
- payload: features[0],
157
- }),
158
- },
159
- );
160
- this.props.onPress(newEvent);
161
- }
162
-
163
- render() {
164
- const props = {
165
- id: this.props.id,
166
- url: this.props.url,
167
- tileUrlTemplates: this.props.tileUrlTemplates,
168
- minZoomLevel: this.props.minZoomLevel,
169
- maxZoomLevel: this.props.maxZoomLevel,
170
- tms: this.props.tms,
171
- attribution: this.props.attribution,
172
- hitbox: this.props.hitbox,
173
- hasPressListener: isFunction(this.props.onPress),
174
- onMapboxVectorSourcePress: this.onPress.bind(this),
175
- onPress: undefined,
176
- ref: nativeRef => this._setNativeRef(nativeRef),
177
- onAndroidCallback: isAndroid() ? this._onAndroidCallback : undefined,
178
- };
179
- return (
180
- <RCTMGLVectorSource ref="nativeSource" {...props}>
181
- {cloneReactChildrenWithProps(this.props.children, {
182
- sourceID: this.props.id,
183
- })}
184
- </RCTMGLVectorSource>
185
- );
186
- }
187
- }
188
-
189
- const RCTMGLVectorSource = requireNativeComponent(
190
- NATIVE_MODULE_NAME,
191
- VectorSource,
192
- {
193
- nativeOnly: {
194
- hasPressListener: true,
195
- onMapboxVectorSourcePress: true,
196
- },
197
- },
198
- );
199
-
200
- export default VectorSource;
@@ -1,122 +0,0 @@
1
- import SymbolLayer from '../SymbolLayer';
2
- import Animated from '../../utils/animated/Animated';
3
- import AnimatedMapPoint from '../../utils/animated/AnimatedPoint';
4
-
5
- import PropTypes from 'prop-types';
6
- import React from 'react';
7
- import {Easing} from 'react-native';
8
-
9
- class Annotation extends React.Component {
10
- static propTypes = {
11
- id: PropTypes.string.isRequired,
12
- animated: PropTypes.bool,
13
- animationDuration: PropTypes.number,
14
- animationEasingFunction: PropTypes.func,
15
- coordinates: PropTypes.arrayOf(PropTypes.number),
16
- onPress: PropTypes.func,
17
- children: PropTypes.any,
18
- style: PropTypes.any,
19
- icon: PropTypes.oneOfType([
20
- PropTypes.string,
21
- PropTypes.number,
22
- PropTypes.object,
23
- ]),
24
- };
25
-
26
- static defaultProps = {
27
- animated: false,
28
- animationDuration: 1000,
29
- animationEasingFunction: Easing.linear,
30
- };
31
-
32
- constructor(props) {
33
- super(props);
34
-
35
- const shape = this._getShapeFromProps(props);
36
-
37
- this.state = {
38
- shape: props.animated ? new AnimatedMapPoint(shape) : shape,
39
- };
40
-
41
- this.onPress = this.onPress.bind(this);
42
- }
43
-
44
- componentDidUpdate(prevProps) {
45
- if (!Array.isArray(this.props.coordinates)) {
46
- this.setState({shape: null});
47
- return;
48
- }
49
-
50
- const hasCoordChanged =
51
- prevProps.coordinates[0] !== this.props.coordinates[0] ||
52
- prevProps.coordinates[1] !== this.props.coordinates[1];
53
-
54
- if (!hasCoordChanged) {
55
- return;
56
- }
57
-
58
- if (this.props.animated && this.state.shape) {
59
- // flush current animations
60
- this.state.shape.stopAnimation();
61
-
62
- this.state.shape
63
- .timing({
64
- coordinates: this.props.coordinates,
65
- easing: this.props.animationEasingFunction,
66
- duration: this.props.animationDuration,
67
- })
68
- .start();
69
- } else if (!this.state.shape || !this.props.animated) {
70
- const shape = this._getShapeFromProps(this.props);
71
-
72
- this.setState({
73
- shape: this.props.animated ? new AnimatedMapPoint(shape) : shape,
74
- });
75
- }
76
- }
77
-
78
- onPress() {
79
- if (this.props.onPress) {
80
- this.props.onPress();
81
- }
82
- }
83
-
84
- _getShapeFromProps(props = {}) {
85
- const lng = props.coordinates[0] || 0;
86
- const lat = props.coordinates[1] || 0;
87
- return {type: 'Point', coordinates: [lng, lat]};
88
- }
89
-
90
- get symbolStyle() {
91
- if (!this.props.icon) {
92
- return undefined;
93
- }
94
- return Object.assign({}, this.props.style, {
95
- iconImage: this.props.icon,
96
- });
97
- }
98
-
99
- render() {
100
- if (!this.props.coordinates) {
101
- return null;
102
- }
103
-
104
- return (
105
- <Animated.ShapeSource
106
- id={this.props.id}
107
- ref="source"
108
- onPress={this.onPress}
109
- shape={this.state.shape}>
110
- {this.symbolStyle && (
111
- <SymbolLayer
112
- id={`${this.props.id}-symbol`}
113
- style={this.symbolStyle}
114
- />
115
- )}
116
- {this.props.children}
117
- </Animated.ShapeSource>
118
- );
119
- }
120
- }
121
-
122
- export default Annotation;
@@ -1,149 +0,0 @@
1
- import {isAndroid} from './utils';
2
- import MapView from './components/MapView';
3
- import Light from './components/Light';
4
- import PointAnnotation from './components/PointAnnotation';
5
- import Annotation from './components/annotations/Annotation';
6
- import Callout from './components/Callout';
7
- import UserLocation from './components/UserLocation';
8
- import Camera from './components/Camera';
9
- import VectorSource from './components/VectorSource';
10
- import ShapeSource from './components/ShapeSource';
11
- import RasterSource from './components/RasterSource';
12
- import ImageSource from './components/ImageSource';
13
- import Images from './components/Images';
14
- import FillLayer from './components/FillLayer';
15
- import FillExtrusionLayer from './components/FillExtrusionLayer';
16
- import HeatmapLayer from './components/HeatmapLayer';
17
- import LineLayer from './components/LineLayer';
18
- import CircleLayer from './components/CircleLayer';
19
- import SymbolLayer from './components/SymbolLayer';
20
- import RasterLayer from './components/RasterLayer';
21
- import BackgroundLayer from './components/BackgroundLayer';
22
- import locationManager from './modules/location/locationManager';
23
- import offlineManager from './modules/offline/offlineManager';
24
- import snapshotManager from './modules/snapshot/snapshotManager';
25
- import MarkerView from './components/MarkerView';
26
- import Animated from './utils/animated/Animated';
27
- import AnimatedMapPoint from './utils/animated/AnimatedPoint';
28
- import AnimatedShape from './utils/animated/AnimatedShape';
29
- import AnimatedCoordinatesArray from './utils/animated/AnimatedCoordinatesArray';
30
- import AnimatedExtractCoordinateFromArray from './utils/animated/AnimatedExtractCoordinateFromArray';
31
- import AnimatedRouteCoordinatesArray from './utils/animated/AnimatedRouteCoordinatesArray';
32
- import Style from './components/Style';
33
- import Logger from './utils/Logger';
34
-
35
- import {NativeModules, PermissionsAndroid} from 'react-native';
36
-
37
- const MapLibreGL = {...NativeModules.MGLModule};
38
-
39
- // static methods
40
- MapLibreGL.requestAndroidLocationPermissions = async function () {
41
- if (isAndroid()) {
42
- const res = await PermissionsAndroid.requestMultiple([
43
- PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION,
44
- PermissionsAndroid.PERMISSIONS.ACCESS_COARSE_LOCATION,
45
- ]);
46
-
47
- if (!res) {
48
- return false;
49
- }
50
-
51
- const permissions = Object.keys(res);
52
- for (const permission of permissions) {
53
- if (res[permission] === PermissionsAndroid.RESULTS.GRANTED) {
54
- return true;
55
- }
56
- }
57
-
58
- return false;
59
- }
60
-
61
- throw new Error('You should only call this method on Android!');
62
- };
63
-
64
- MapLibreGL.UserTrackingModes = Camera.UserTrackingModes;
65
-
66
- // components
67
- MapLibreGL.MapView = MapView;
68
- MapLibreGL.Light = Light;
69
- MapLibreGL.PointAnnotation = PointAnnotation;
70
- MapLibreGL.Callout = Callout;
71
- MapLibreGL.UserLocation = UserLocation;
72
- MapLibreGL.Camera = Camera;
73
- MapLibreGL.Style = Style;
74
-
75
- // annotations
76
- MapLibreGL.Annotation = Annotation;
77
- MapLibreGL.MarkerView = MarkerView;
78
-
79
- // sources
80
- MapLibreGL.VectorSource = VectorSource;
81
- MapLibreGL.ShapeSource = ShapeSource;
82
- MapLibreGL.RasterSource = RasterSource;
83
- MapLibreGL.ImageSource = ImageSource;
84
- MapLibreGL.Images = Images;
85
-
86
- // layers
87
- MapLibreGL.FillLayer = FillLayer;
88
- MapLibreGL.FillExtrusionLayer = FillExtrusionLayer;
89
- MapLibreGL.HeatmapLayer = HeatmapLayer;
90
- MapLibreGL.LineLayer = LineLayer;
91
- MapLibreGL.CircleLayer = CircleLayer;
92
- MapLibreGL.SymbolLayer = SymbolLayer;
93
- MapLibreGL.RasterLayer = RasterLayer;
94
- MapLibreGL.BackgroundLayer = BackgroundLayer;
95
-
96
- // modules
97
- MapLibreGL.locationManager = locationManager;
98
- MapLibreGL.offlineManager = offlineManager;
99
- MapLibreGL.snapshotManager = snapshotManager;
100
-
101
- // animated
102
- MapLibreGL.Animated = Animated;
103
-
104
- // utils
105
- MapLibreGL.AnimatedPoint = AnimatedMapPoint;
106
- MapLibreGL.AnimatedCoordinatesArray = AnimatedCoordinatesArray;
107
- MapLibreGL.AnimatedExtractCoordinateFromArray =
108
- AnimatedExtractCoordinateFromArray;
109
- MapLibreGL.AnimatedRouteCoordinatesArray = AnimatedRouteCoordinatesArray;
110
- MapLibreGL.AnimatedShape = AnimatedShape;
111
- MapLibreGL.Logger = Logger;
112
-
113
- const {LineJoin} = MapLibreGL;
114
-
115
- export {
116
- MapView,
117
- Light,
118
- PointAnnotation,
119
- Callout,
120
- UserLocation,
121
- Camera,
122
- Annotation,
123
- MarkerView,
124
- VectorSource,
125
- ShapeSource,
126
- RasterSource,
127
- ImageSource,
128
- Images,
129
- FillLayer,
130
- FillExtrusionLayer,
131
- HeatmapLayer,
132
- LineLayer,
133
- CircleLayer,
134
- SymbolLayer,
135
- RasterLayer,
136
- BackgroundLayer,
137
- locationManager,
138
- offlineManager,
139
- snapshotManager,
140
- AnimatedMapPoint,
141
- AnimatedCoordinatesArray,
142
- AnimatedShape,
143
- Animated,
144
- LineJoin,
145
- Logger,
146
- Style,
147
- };
148
-
149
- export default MapLibreGL;
@@ -1,81 +0,0 @@
1
- import {isBoolean, isNumber, isString} from './index';
2
-
3
- const Types = {
4
- Array: 'array',
5
- Bool: 'boolean',
6
- Number: 'number',
7
- String: 'string',
8
- HashMap: 'hashmap',
9
- };
10
-
11
- export default class BridgeValue {
12
- constructor(rawValue) {
13
- this.rawValue = rawValue;
14
- }
15
-
16
- get type() {
17
- if (Array.isArray(this.rawValue)) {
18
- return Types.Array;
19
- }
20
- if (isBoolean(this.rawValue)) {
21
- return Types.Bool;
22
- }
23
- if (isNumber(this.rawValue)) {
24
- return Types.Number;
25
- }
26
- if (isString(this.rawValue)) {
27
- return Types.String;
28
- }
29
- if (this.rawValue && typeof this.rawValue === 'object') {
30
- return Types.HashMap;
31
- }
32
- throw new Error(
33
- `[type - ${this.rawValue}] BridgeValue must be a primitive/array/object`,
34
- );
35
- }
36
-
37
- get value() {
38
- const {type} = this;
39
-
40
- let value;
41
-
42
- if (type === Types.Array) {
43
- value = [];
44
-
45
- for (const innerRawValue of this.rawValue) {
46
- const bridgeValue = new BridgeValue(innerRawValue);
47
- value.push(bridgeValue.toJSON());
48
- }
49
- } else if (type === Types.HashMap) {
50
- value = [];
51
-
52
- const stringKeys = Object.keys(this.rawValue);
53
- for (const stringKey of stringKeys) {
54
- value.push([
55
- new BridgeValue(stringKey).toJSON(),
56
- new BridgeValue(this.rawValue[stringKey]).toJSON(),
57
- ]);
58
- }
59
- } else if (
60
- type === Types.Bool ||
61
- type === Types.Number ||
62
- type === Types.String
63
- ) {
64
- value = this.rawValue;
65
- } else {
66
- throw new Error(
67
- `[value - ${this.rawValue}] BridgeValue must be a primitive/array/object`,
68
- );
69
- }
70
-
71
- return value;
72
- }
73
-
74
- toJSON(formatter) {
75
- return {
76
- type: this.type,
77
- value:
78
- typeof formatter === 'function' ? formatter(this.value) : this.value,
79
- };
80
- }
81
- }