@maplibre/maplibre-react-native 9.0.1 → 10.0.0-alpha.1

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 (146) 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 +15 -1
  18. package/android/build.gradle +2 -2
  19. package/android/rctmgl/build.gradle +2 -4
  20. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.java +14 -0
  21. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.java +26 -0
  22. package/android/rctmgl/src/main/java/com/mapbox/rctmgl/utils/ClusterPropertyEntry.java +13 -0
  23. package/docs/Annotation.md +8 -9
  24. package/docs/BackgroundLayer.md +2 -10
  25. package/docs/Callout.md +5 -5
  26. package/docs/Camera.md +18 -47
  27. package/docs/CircleLayer.md +2 -10
  28. package/docs/FillExtrusionLayer.md +2 -10
  29. package/docs/FillLayer.md +2 -10
  30. package/docs/HeatmapLayer.md +2 -10
  31. package/docs/ImageSource.md +3 -2
  32. package/docs/Images.md +5 -3
  33. package/docs/Light.md +1 -1
  34. package/docs/LineLayer.md +2 -10
  35. package/docs/MapView.md +53 -37
  36. package/docs/MarkerView.md +4 -2
  37. package/docs/NativeUserLocation.md +2 -2
  38. package/docs/PointAnnotation.md +5 -8
  39. package/docs/RasterLayer.md +2 -10
  40. package/docs/RasterSource.md +3 -2
  41. package/docs/ShapeSource.md +12 -6
  42. package/docs/Style.md +1 -1
  43. package/docs/SymbolLayer.md +3 -10
  44. package/docs/UserLocation.md +8 -10
  45. package/docs/VectorSource.md +6 -5
  46. package/docs/coordinates.md +6 -0
  47. package/docs/docs.json +561 -1308
  48. package/docs/location.md +6 -0
  49. package/docs/snapshotManager.md +3 -3
  50. package/ios/RCTMGL/RCTMGLShapeSource.h +1 -0
  51. package/ios/RCTMGL/RCTMGLShapeSource.m +14 -0
  52. package/ios/RCTMGL/RCTMGLShapeSourceManager.m +1 -0
  53. package/ios/RCTMGL.xcodeproj/project.pbxproj +1 -0
  54. package/javascript/@types/assets.d.ts +4 -0
  55. package/javascript/MGLModule.ts +37 -0
  56. package/javascript/Maplibre.ts +65 -0
  57. package/javascript/components/AbstractLayer.tsx +107 -0
  58. package/javascript/components/AbstractSource.tsx +27 -0
  59. package/javascript/components/BackgroundLayer.tsx +43 -0
  60. package/javascript/components/{Callout.js → Callout.tsx} +67 -65
  61. package/javascript/components/{Camera.js → Camera.tsx} +266 -251
  62. package/javascript/components/CircleLayer.tsx +46 -0
  63. package/javascript/components/FillExtrusionLayer.tsx +47 -0
  64. package/javascript/components/FillLayer.tsx +41 -0
  65. package/javascript/components/{HeadingIndicator.js → HeadingIndicator.tsx} +8 -8
  66. package/javascript/components/HeatmapLayer.tsx +44 -0
  67. package/javascript/components/ImageSource.tsx +78 -0
  68. package/javascript/components/Images.tsx +134 -0
  69. package/javascript/components/Light.tsx +67 -0
  70. package/javascript/components/LineLayer.tsx +42 -0
  71. package/javascript/components/{MapView.js → MapView.tsx} +365 -354
  72. package/javascript/components/MarkerView.tsx +104 -0
  73. package/javascript/components/{NativeBridgeComponent.js → NativeBridgeComponent.tsx} +44 -13
  74. package/javascript/components/NativeUserLocation.tsx +33 -0
  75. package/javascript/components/PointAnnotation.tsx +221 -0
  76. package/javascript/components/RasterLayer.tsx +41 -0
  77. package/javascript/components/RasterSource.tsx +117 -0
  78. package/javascript/components/ShapeSource.tsx +383 -0
  79. package/javascript/components/{Style.js → Style.tsx} +132 -38
  80. package/javascript/components/SymbolLayer.tsx +72 -0
  81. package/javascript/components/{UserLocation.js → UserLocation.tsx} +111 -110
  82. package/javascript/components/VectorSource.tsx +207 -0
  83. package/javascript/components/annotations/Annotation.tsx +134 -0
  84. package/javascript/index.ts +4 -0
  85. package/javascript/modules/location/{locationManager.js → locationManager.ts} +71 -10
  86. package/javascript/modules/offline/{OfflineCreatePackOptions.js → OfflineCreatePackOptions.ts} +20 -4
  87. package/javascript/modules/offline/{OfflinePack.js → OfflinePack.ts} +23 -7
  88. package/javascript/modules/offline/{offlineManager.js → offlineManager.ts} +81 -24
  89. package/javascript/modules/snapshot/{SnapshotOptions.js → SnapshotOptions.ts} +43 -6
  90. package/javascript/modules/snapshot/{snapshotManager.js → snapshotManager.ts} +5 -5
  91. package/javascript/requestAndroidLocationPermissions.ts +29 -0
  92. package/javascript/types/BaseProps.ts +5 -0
  93. package/javascript/types/OnPressEvent.ts +13 -0
  94. package/javascript/types/index.ts +7 -0
  95. package/javascript/utils/BridgeValue.ts +90 -0
  96. package/javascript/utils/{Logger.js → Logger.ts} +37 -18
  97. package/javascript/utils/MaplibreStyles.d.ts +1486 -0
  98. package/javascript/utils/StyleValue.ts +49 -0
  99. package/javascript/utils/animated/AbstractAnimatedCoordinates.ts +134 -0
  100. package/javascript/utils/animated/AnimatedCoordinatesArray.ts +112 -0
  101. package/javascript/utils/animated/{AnimatedExtractCoordinateFromArray.js → AnimatedExtractCoordinateFromArray.ts} +5 -5
  102. package/javascript/utils/animated/{AnimatedPoint.js → AnimatedPoint.ts} +20 -12
  103. package/javascript/utils/animated/{AnimatedRouteCoordinatesArray.js → AnimatedRouteCoordinatesArray.ts} +39 -14
  104. package/javascript/utils/animated/{AnimatedShape.js → AnimatedShape.ts} +31 -10
  105. package/javascript/utils/{deprecation.js → deprecation.ts} +9 -6
  106. package/javascript/utils/filterUtils.ts +9 -0
  107. package/javascript/utils/geoUtils.ts +79 -0
  108. package/javascript/utils/{index.js → index.ts} +44 -24
  109. package/javascript/utils/styleMap.ts +264 -0
  110. package/package.json +43 -34
  111. package/plugin/build/withMapLibre.js +3 -2
  112. package/scripts/autogenHelpers/globals.js +1 -1
  113. package/scripts/autogenerate.js +14 -6
  114. package/scripts/templates/MaplibreStyles.ts.ejs +99 -0
  115. package/scripts/templates/index.d.ts.ejs +71 -42
  116. package/scripts/templates/{styleMap.js.ejs → styleMap.ts.ejs} +3 -33
  117. package/setup-jest.js +3 -10
  118. package/tsconfig.json +20 -61
  119. package/index.d.ts +0 -954
  120. package/javascript/components/AbstractLayer.js +0 -75
  121. package/javascript/components/AbstractSource.js +0 -15
  122. package/javascript/components/BackgroundLayer.js +0 -97
  123. package/javascript/components/CircleLayer.js +0 -101
  124. package/javascript/components/FillExtrusionLayer.js +0 -98
  125. package/javascript/components/FillLayer.js +0 -94
  126. package/javascript/components/HeatmapLayer.js +0 -99
  127. package/javascript/components/ImageSource.js +0 -82
  128. package/javascript/components/Images.js +0 -119
  129. package/javascript/components/Light.js +0 -47
  130. package/javascript/components/LineLayer.js +0 -94
  131. package/javascript/components/MarkerView.js +0 -87
  132. package/javascript/components/NativeUserLocation.js +0 -41
  133. package/javascript/components/PointAnnotation.js +0 -216
  134. package/javascript/components/RasterLayer.js +0 -95
  135. package/javascript/components/RasterSource.js +0 -124
  136. package/javascript/components/ShapeSource.js +0 -357
  137. package/javascript/components/SymbolLayer.js +0 -120
  138. package/javascript/components/VectorSource.js +0 -200
  139. package/javascript/components/annotations/Annotation.js +0 -122
  140. package/javascript/index.js +0 -149
  141. package/javascript/utils/BridgeValue.js +0 -81
  142. package/javascript/utils/animated/AnimatedCoordinatesArray.js +0 -191
  143. package/javascript/utils/filterUtils.js +0 -7
  144. package/javascript/utils/geoUtils.js +0 -73
  145. package/javascript/utils/styleMap.js +0 -1932
  146. /package/javascript/utils/animated/{Animated.js → Animated.ts} +0 -0
@@ -1,191 +0,0 @@
1
- import {Animated} from 'react-native';
2
-
3
- // see
4
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
5
- const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
6
- if (__DEV__) {
7
- if (AnimatedWithChildren.name !== 'AnimatedWithChildren') {
8
- console.error(
9
- 'AnimatedCoordinatesArray could not obtain AnimatedWithChildren base class',
10
- );
11
- }
12
- }
13
-
14
- const defaultConfig = {
15
- useNativeDriver: false,
16
- };
17
-
18
- class AnimatedCoordinatesArray extends AnimatedWithChildren {
19
- constructor(...args) {
20
- super();
21
-
22
- this.state = this.onInitialState(...args);
23
- }
24
-
25
- /**
26
- * Subclasses can override to calculate initial state
27
- *
28
- * @param {*} args - to value from animate
29
- * @returns {object} - the state object
30
- */
31
- onInitialState(coordinatesArray) {
32
- return {coords: coordinatesArray.map(coord => [coord[0], coord[1]])};
33
- }
34
-
35
- /**
36
- * Subclasses can override getValue to calculate value from state.
37
- * Value is typically coordinates array, but can be anything
38
- *
39
- * @param {object} state - either state from initialState and/or from calculate
40
- * @returns {object}
41
- */
42
- onGetValue(state) {
43
- return state.coords;
44
- }
45
-
46
- /**
47
- * Calculates state based on startingState and progress, returns a new state
48
- *
49
- * @param {object} state - state object from initialState and/or from calculate
50
- * @param {number} progress - value between 0 and 1
51
- * @returns {object} next state
52
- */
53
- onCalculate(state, progress) {
54
- const {coords, targetCoords} = state;
55
- const newF = progress;
56
- const origF = 1.0 - newF;
57
-
58
- // common
59
- const commonLen = Math.min(coords.length, targetCoords.length);
60
- const common = coords
61
- .slice(0, commonLen)
62
- .map((origCoord, i) => [
63
- origCoord[0] * origF + targetCoords[i][0] * newF,
64
- origCoord[1] * origF + targetCoords[i][1] * newF,
65
- ]);
66
-
67
- if (targetCoords.length > coords.length) {
68
- // only in new (adding)
69
- const addingOrig =
70
- coords.length > 0 ? coords[coords.length - 1] : targetCoords[0];
71
- const adding = targetCoords
72
- .slice(commonLen, targetCoords.length)
73
- .map(newCoord => [
74
- addingOrig[0] * origF + newCoord[0] * newF,
75
- addingOrig[1] * origF + newCoord[1] * newF,
76
- ]);
77
- return {coords: [...common, ...adding], targetCoords};
78
- }
79
-
80
- if (coords.length > targetCoords.length) {
81
- // only in orig (dissapearing)
82
- const dissapearingNew =
83
- targetCoords.length > 0
84
- ? targetCoords[targetCoords.length - 1]
85
- : coords[0];
86
- const dissapearing = coords
87
- .slice(commonLen, coords.length)
88
- .map(origCoord => [
89
- origCoord[0] * origF + dissapearingNew[0] * newF,
90
- origCoord[1] * origF + dissapearingNew[1] * newF,
91
- ]);
92
- return {coords: [...common, ...dissapearing], targetCoords};
93
- }
94
-
95
- return {coords: common, targetCoords};
96
- }
97
-
98
- /**
99
- * Subclasses can override to start a new animation
100
- *
101
- * @param {*} toValue - to value from animate
102
- * @param {*} actCoords - the current coordinates array to start from
103
- * @returns {object} The state
104
- */
105
- onStart(state, toValue) {
106
- const targetCoords = toValue.map(coord => [coord[0], coord[1]]);
107
- return {
108
- ...state,
109
- targetCoords,
110
- };
111
- }
112
-
113
- animate(progressValue, progressAnimation, config) {
114
- const {toValue} = config;
115
-
116
- const onAnimationStart = animation => {
117
- if (this.animation) {
118
- // there was a started but not finsihed animation
119
- const actProgress = this.progressValue.__getValue();
120
- this.animation.stop();
121
- this.state = this.onCalculate(this.state, actProgress);
122
- this.progressValue.__removeChild(this);
123
- this.progressValue = null;
124
- this.animation = null;
125
- }
126
-
127
- this.progressValue = progressValue;
128
- this.progressValue.__addChild(this);
129
- this.animation = animation;
130
- this.state = this.onStart(this.state, toValue);
131
- };
132
-
133
- const origAnimationStart = progressAnimation.start;
134
- const newAnimation = progressAnimation;
135
- newAnimation.start = function start(...args) {
136
- onAnimationStart(progressAnimation);
137
- origAnimationStart(...args);
138
- };
139
- return newAnimation;
140
- }
141
-
142
- timing(config) {
143
- const progressValue = new Animated.Value(0.0);
144
- return this.animate(
145
- progressValue,
146
- Animated.timing(progressValue, {
147
- ...defaultConfig,
148
- ...config,
149
- toValue: 1.0,
150
- }),
151
- config,
152
- );
153
- }
154
-
155
- spring(config) {
156
- const progressValue = new Animated.Value(0.0);
157
- return this.animate(
158
- progressValue,
159
- Animated.spring(progressValue, {
160
- ...defaultConfig,
161
- ...config,
162
- toValue: 1.0,
163
- }),
164
- config,
165
- );
166
- }
167
-
168
- decay(config) {
169
- const progressValue = new Animated.Value(0.0);
170
- return this.animate(
171
- progressValue,
172
- Animated.decay(this.progressValue, {
173
- ...defaultConfig,
174
- ...config,
175
- toValue: 1.0,
176
- }),
177
- config,
178
- );
179
- }
180
-
181
- __getValue() {
182
- if (!this.progressValue) {
183
- return this.onGetValue(this.state);
184
- }
185
- return this.onGetValue(
186
- this.onCalculate(this.state, this.progressValue.__getValue()),
187
- );
188
- }
189
- }
190
-
191
- export default AnimatedCoordinatesArray;
@@ -1,7 +0,0 @@
1
- export function getFilter(filter) {
2
- if (!Array.isArray(filter) || filter.length === 0) {
3
- return [];
4
- }
5
-
6
- return filter;
7
- }
@@ -1,73 +0,0 @@
1
- import {featureCollection, point, feature, lineString} from '@turf/helpers';
2
- import distance from '@turf/distance';
3
- import along from '@turf/along';
4
- import geoViewport from '@mapbox/geo-viewport';
5
-
6
- const VECTOR_TILE_SIZE = 512;
7
-
8
- export function makePoint(coordinates, properties, options) {
9
- return point(coordinates, properties, options);
10
- }
11
-
12
- export function makeLineString(coordinates, properties, options) {
13
- return lineString(coordinates, properties, options);
14
- }
15
-
16
- export function makeLatLngBounds(northEastCoordinates, southWestCoordinates) {
17
- return featureCollection([
18
- point(northEastCoordinates),
19
- point(southWestCoordinates),
20
- ]);
21
- }
22
-
23
- export function makeFeature(geometry, properties) {
24
- return feature(geometry, properties);
25
- }
26
-
27
- export function makeFeatureCollection(features = [], options) {
28
- return featureCollection(features, options);
29
- }
30
-
31
- export function addToFeatureCollection(newFeatureCollection, newFeature) {
32
- return {
33
- ...newFeatureCollection,
34
- features: [...newFeatureCollection.features, newFeature],
35
- };
36
- }
37
-
38
- export function calculateDistance(origin, dest, options) {
39
- return distance(origin, dest, options);
40
- }
41
-
42
- export function pointAlongLine(newLineString, distAlong, options) {
43
- return along(newLineString, distAlong, options);
44
- }
45
-
46
- export function getOrCalculateVisibleRegion(
47
- coord,
48
- zoomLevel,
49
- width,
50
- height,
51
- nativeRegion,
52
- ) {
53
- const region = {
54
- ne: [0, 0],
55
- sw: [0, 0],
56
- };
57
-
58
- if (!nativeRegion || !Array.isArray(nativeRegion.visibleBounds)) {
59
- const bounds = geoViewport.bounds(
60
- coord,
61
- zoomLevel,
62
- [width, height],
63
- VECTOR_TILE_SIZE,
64
- );
65
- region.ne = [bounds[3], bounds[2]];
66
- region.sw = [bounds[1], bounds[0]];
67
- } else {
68
- region.ne = nativeRegion.properties.visibleBounds[0];
69
- region.sw = nativeRegion.properties.visibleBounds[1];
70
- }
71
-
72
- return region;
73
- }