@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,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
- }