@maplibre/maplibre-react-native 10.1.1 → 10.1.3

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 (47) hide show
  1. package/ios/MLRN/CameraUpdateItem.m +7 -8
  2. package/lib/commonjs/components/ShapeSource.js +2 -1
  3. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  4. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  5. package/lib/commonjs/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  6. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -2
  7. package/lib/commonjs/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  8. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js +28 -38
  9. package/lib/commonjs/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  10. package/lib/commonjs/utils/animated/AnimatedShape.js +11 -7
  11. package/lib/commonjs/utils/animated/AnimatedShape.js.map +1 -1
  12. package/lib/module/components/ShapeSource.js +2 -1
  13. package/lib/module/components/ShapeSource.js.map +1 -1
  14. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js +8 -7
  15. package/lib/module/utils/animated/AbstractAnimatedCoordinates.js.map +1 -1
  16. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js +1 -3
  17. package/lib/module/utils/animated/AnimatedExtractCoordinateFromArray.js.map +1 -1
  18. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js +29 -39
  19. package/lib/module/utils/animated/AnimatedRouteCoordinatesArray.js.map +1 -1
  20. package/lib/module/utils/animated/AnimatedShape.js +11 -7
  21. package/lib/module/utils/animated/AnimatedShape.js.map +1 -1
  22. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts +1 -1
  23. package/lib/typescript/commonjs/src/components/ShapeSource.d.ts.map +1 -1
  24. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -12
  25. package/lib/typescript/commonjs/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -3
  27. package/lib/typescript/commonjs/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  28. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  29. package/lib/typescript/commonjs/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  30. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts +8 -4
  31. package/lib/typescript/commonjs/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  32. package/lib/typescript/module/src/components/ShapeSource.d.ts +1 -1
  33. package/lib/typescript/module/src/components/ShapeSource.d.ts.map +1 -1
  34. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts +12 -12
  35. package/lib/typescript/module/src/utils/animated/AbstractAnimatedCoordinates.d.ts.map +1 -1
  36. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts +5 -3
  37. package/lib/typescript/module/src/utils/animated/AnimatedExtractCoordinateFromArray.d.ts.map +1 -1
  38. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts +33 -21
  39. package/lib/typescript/module/src/utils/animated/AnimatedRouteCoordinatesArray.d.ts.map +1 -1
  40. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts +8 -4
  41. package/lib/typescript/module/src/utils/animated/AnimatedShape.d.ts.map +1 -1
  42. package/package.json +1 -1
  43. package/src/components/ShapeSource.tsx +58 -53
  44. package/src/utils/animated/AbstractAnimatedCoordinates.ts +26 -15
  45. package/src/utils/animated/AnimatedExtractCoordinateFromArray.ts +10 -6
  46. package/src/utils/animated/AnimatedRouteCoordinatesArray.ts +63 -51
  47. package/src/utils/animated/AnimatedShape.ts +22 -13
@@ -2,13 +2,13 @@
2
2
 
3
3
  import { Animated } from "react-native";
4
4
 
5
- import { AnimatedCoordinatesArray } from "./AnimatedCoordinatesArray";
5
+ import type { AnimatedCoordinatesArray } from "./AnimatedCoordinatesArray";
6
6
  import { AnimatedExtractCoordinateFromArray } from "./AnimatedExtractCoordinateFromArray";
7
7
  import { AnimatedRouteCoordinatesArray } from "./AnimatedRouteCoordinatesArray";
8
8
 
9
- // see
10
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedWithChildren.js
9
+ // https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedWithChildren.js
11
10
  const AnimatedWithChildren = Object.getPrototypeOf(Animated.ValueXY);
11
+
12
12
  if (__DEV__) {
13
13
  if (AnimatedWithChildren.name !== "AnimatedWithChildren") {
14
14
  console.error(
@@ -20,24 +20,23 @@ if (__DEV__) {
20
20
  type Shape =
21
21
  | {
22
22
  type: "Point";
23
- coordinates:
24
- | AnimatedExtractCoordinateFromArray
25
- | AnimatedRouteCoordinatesArray;
23
+ coordinates: AnimatedExtractCoordinateFromArray;
26
24
  }
27
25
  | {
28
26
  type: "LineString";
29
- coordinates: AnimatedCoordinatesArray;
27
+ coordinates: AnimatedCoordinatesArray | AnimatedRouteCoordinatesArray;
30
28
  };
31
29
 
32
30
  /**
33
31
  * AnimatedShape can be used to have animated properties inside the shape property
32
+ *
33
+ * Equivalent of AnimatedStyle for shapes
34
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Animated/nodes/AnimatedStyle.js
35
+ *
34
36
  * @example
35
37
  * <AnimatedShapeSource ... shape={new AnimatedShape({type:'LineString', coordinates: animatedCoords})} />
36
38
  */
37
39
  export class AnimatedShape extends AnimatedWithChildren {
38
- // equivalent of AnimatedStyle for shapes
39
- // https://github.com/facebook/react-native/blob/master/Libraries/Animated/src/nodes/AnimatedStyle.js
40
-
41
40
  constructor(shape: Shape) {
42
41
  super();
43
42
  this.shape = shape;
@@ -47,23 +46,33 @@ export class AnimatedShape extends AnimatedWithChildren {
47
46
  if (Array.isArray(value)) {
48
47
  return value.map((i) => this._walkShapeAndGetValues(i));
49
48
  }
49
+
50
50
  // @ts-expect-error Animated.Node is not exported
51
51
  if (value instanceof Animated.Node) {
52
52
  return (value as any).__getValue();
53
53
  }
54
+
54
55
  if (typeof value === "object") {
55
56
  const result: { [key: string]: any } = {};
57
+
56
58
  for (const key in value) {
57
59
  result[key] = this._walkShapeAndGetValues(value[key]);
58
60
  }
61
+
59
62
  return result;
60
63
  }
64
+
61
65
  return value;
62
66
  }
63
67
 
64
- __getValue(): any {
65
- const result = this._walkShapeAndGetValues(this.shape);
66
- return result;
68
+ __getValue(): GeoJSON.Point | GeoJSON.LineString {
69
+ const shape = this._walkShapeAndGetValues(this.shape);
70
+
71
+ if (shape.type === "LineString" && shape.coordinates.length === 1) {
72
+ shape.coordinates = [...shape.coordinates, ...shape.coordinates];
73
+ }
74
+
75
+ return shape;
67
76
  }
68
77
 
69
78
  // @ts-expect-error Animated.Node is not exported