@rnmapbox/maps 10.0.0-beta.76 → 10.0.0-beta.77

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 (202) hide show
  1. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyle.kt +7 -1
  2. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/RCTMGLStyleFactory.java +5 -5
  3. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTLayer.kt +37 -10
  4. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.kt +21 -0
  5. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.kt +65 -0
  6. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.kt +40 -0
  7. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayerManager.kt +76 -0
  8. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.kt +43 -0
  9. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayerManager.kt +76 -0
  10. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.kt +40 -0
  11. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayerManager.kt +76 -0
  12. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.kt +40 -0
  13. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayerManager.kt +76 -0
  14. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.kt +40 -0
  15. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayerManager.kt +76 -0
  16. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.kt +18 -0
  17. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.kt +65 -0
  18. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSkyLayerManager.kt +76 -0
  19. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.kt +40 -0
  20. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayerManager.kt +76 -0
  21. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.kt +69 -0
  22. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.kt +54 -0
  23. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSource.kt +82 -0
  24. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSourceManager.kt +30 -0
  25. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.kt +37 -0
  26. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSourceManager.kt +32 -0
  27. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSource.kt +5 -0
  28. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLShapeSourceManager.kt +10 -4
  29. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSource.kt +44 -0
  30. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSourceManager.kt +69 -0
  31. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.kt +78 -0
  32. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSourceManager.kt +69 -0
  33. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTSource.kt +101 -85
  34. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/events/PointAnnotationDragEvent.java +4 -2
  35. package/ios/RCTMGL-v10/RCTMGLCamera.swift +11 -31
  36. package/ios/RCTMGL-v10/RCTMGLInteractiveElement.swift +13 -1
  37. package/ios/RCTMGL-v10/RCTMGLLayer.swift +35 -6
  38. package/ios/RCTMGL-v10/RCTMGLLocationModule.swift +27 -4
  39. package/ios/RCTMGL-v10/RCTMGLMapView.swift +4 -2
  40. package/ios/RCTMGL-v10/RCTMGLSource.swift +35 -17
  41. package/javascript/Mapbox.ts +4 -1
  42. package/javascript/components/AbstractLayer.tsx +2 -1
  43. package/javascript/components/BackgroundLayer.tsx +6 -1
  44. package/javascript/components/{Callout.js → Callout.tsx} +53 -45
  45. package/javascript/components/CircleLayer.tsx +5 -0
  46. package/javascript/components/FillExtrusionLayer.tsx +6 -1
  47. package/javascript/components/FillLayer.tsx +5 -0
  48. package/javascript/components/HeadingIndicator.tsx +24 -13
  49. package/javascript/components/HeatmapLayer.tsx +6 -1
  50. package/javascript/components/ImageSource.tsx +5 -0
  51. package/javascript/components/LineLayer.tsx +5 -0
  52. package/javascript/components/PointAnnotation.tsx +8 -4
  53. package/javascript/components/RasterDemSource.tsx +5 -0
  54. package/javascript/components/RasterLayer.tsx +6 -1
  55. package/javascript/components/RasterSource.tsx +5 -0
  56. package/javascript/components/ShapeSource.tsx +5 -0
  57. package/javascript/components/SkyLayer.tsx +5 -0
  58. package/javascript/components/SymbolLayer.tsx +6 -1
  59. package/javascript/components/UserLocation.tsx +1 -1
  60. package/javascript/components/VectorSource.tsx +5 -0
  61. package/javascript/types/BaseProps.ts +1 -0
  62. package/javascript/utils/index.ts +0 -8
  63. package/javascript/utils/styleMap.ts +0 -1598
  64. package/lib/commonjs/Mapbox.js +8 -1
  65. package/lib/commonjs/Mapbox.js.map +1 -1
  66. package/lib/commonjs/components/AbstractLayer.js +1 -2
  67. package/lib/commonjs/components/AbstractLayer.js.map +1 -1
  68. package/lib/commonjs/components/BackgroundLayer.js.map +1 -1
  69. package/lib/commonjs/components/Callout.js +7 -33
  70. package/lib/commonjs/components/Callout.js.map +1 -1
  71. package/lib/commonjs/components/CircleLayer.js.map +1 -1
  72. package/lib/commonjs/components/FillExtrusionLayer.js.map +1 -1
  73. package/lib/commonjs/components/FillLayer.js.map +1 -1
  74. package/lib/commonjs/components/HeadingIndicator.js +12 -3
  75. package/lib/commonjs/components/HeadingIndicator.js.map +1 -1
  76. package/lib/commonjs/components/HeatmapLayer.js.map +1 -1
  77. package/lib/commonjs/components/ImageSource.js.map +1 -1
  78. package/lib/commonjs/components/LineLayer.js.map +1 -1
  79. package/lib/commonjs/components/PointAnnotation.js.map +1 -1
  80. package/lib/commonjs/components/RasterDemSource.js.map +1 -1
  81. package/lib/commonjs/components/RasterLayer.js.map +1 -1
  82. package/lib/commonjs/components/RasterSource.js.map +1 -1
  83. package/lib/commonjs/components/ShapeSource.js.map +1 -1
  84. package/lib/commonjs/components/SkyLayer.js.map +1 -1
  85. package/lib/commonjs/components/SymbolLayer.js.map +1 -1
  86. package/lib/commonjs/components/UserLocation.js +2 -1
  87. package/lib/commonjs/components/UserLocation.js.map +1 -1
  88. package/lib/commonjs/components/VectorSource.js.map +1 -1
  89. package/lib/commonjs/utils/index.js +0 -16
  90. package/lib/commonjs/utils/index.js.map +1 -1
  91. package/lib/commonjs/utils/styleMap.js +1 -1217
  92. package/lib/commonjs/utils/styleMap.js.map +1 -1
  93. package/lib/module/Mapbox.js +1 -1
  94. package/lib/module/Mapbox.js.map +1 -1
  95. package/lib/module/components/AbstractLayer.js +1 -1
  96. package/lib/module/components/AbstractLayer.js.map +1 -1
  97. package/lib/module/components/BackgroundLayer.js.map +1 -1
  98. package/lib/module/components/Callout.js +7 -33
  99. package/lib/module/components/Callout.js.map +1 -1
  100. package/lib/module/components/CircleLayer.js.map +1 -1
  101. package/lib/module/components/FillExtrusionLayer.js.map +1 -1
  102. package/lib/module/components/FillLayer.js.map +1 -1
  103. package/lib/module/components/HeadingIndicator.js +12 -3
  104. package/lib/module/components/HeadingIndicator.js.map +1 -1
  105. package/lib/module/components/HeatmapLayer.js.map +1 -1
  106. package/lib/module/components/ImageSource.js.map +1 -1
  107. package/lib/module/components/LineLayer.js.map +1 -1
  108. package/lib/module/components/PointAnnotation.js.map +1 -1
  109. package/lib/module/components/RasterDemSource.js.map +1 -1
  110. package/lib/module/components/RasterLayer.js.map +1 -1
  111. package/lib/module/components/RasterSource.js.map +1 -1
  112. package/lib/module/components/ShapeSource.js.map +1 -1
  113. package/lib/module/components/SkyLayer.js.map +1 -1
  114. package/lib/module/components/SymbolLayer.js.map +1 -1
  115. package/lib/module/components/UserLocation.js +2 -1
  116. package/lib/module/components/UserLocation.js.map +1 -1
  117. package/lib/module/components/VectorSource.js.map +1 -1
  118. package/lib/module/utils/index.js +0 -14
  119. package/lib/module/utils/index.js.map +1 -1
  120. package/lib/module/utils/styleMap.js +0 -1201
  121. package/lib/module/utils/styleMap.js.map +1 -1
  122. package/lib/typescript/Mapbox.d.ts +1 -1
  123. package/lib/typescript/Mapbox.d.ts.map +1 -1
  124. package/lib/typescript/components/AbstractLayer.d.ts +1 -0
  125. package/lib/typescript/components/AbstractLayer.d.ts.map +1 -1
  126. package/lib/typescript/components/BackgroundLayer.d.ts +5 -1
  127. package/lib/typescript/components/BackgroundLayer.d.ts.map +1 -1
  128. package/lib/typescript/components/Callout.d.ts +41 -0
  129. package/lib/typescript/components/Callout.d.ts.map +1 -0
  130. package/lib/typescript/components/CircleLayer.d.ts +4 -0
  131. package/lib/typescript/components/CircleLayer.d.ts.map +1 -1
  132. package/lib/typescript/components/FillExtrusionLayer.d.ts +5 -1
  133. package/lib/typescript/components/FillExtrusionLayer.d.ts.map +1 -1
  134. package/lib/typescript/components/FillLayer.d.ts +4 -0
  135. package/lib/typescript/components/FillLayer.d.ts.map +1 -1
  136. package/lib/typescript/components/HeadingIndicator.d.ts +2 -1
  137. package/lib/typescript/components/HeadingIndicator.d.ts.map +1 -1
  138. package/lib/typescript/components/HeatmapLayer.d.ts +5 -1
  139. package/lib/typescript/components/HeatmapLayer.d.ts.map +1 -1
  140. package/lib/typescript/components/ImageSource.d.ts +4 -0
  141. package/lib/typescript/components/ImageSource.d.ts.map +1 -1
  142. package/lib/typescript/components/LineLayer.d.ts +4 -0
  143. package/lib/typescript/components/LineLayer.d.ts.map +1 -1
  144. package/lib/typescript/components/PointAnnotation.d.ts +5 -9
  145. package/lib/typescript/components/PointAnnotation.d.ts.map +1 -1
  146. package/lib/typescript/components/RasterDemSource.d.ts +4 -0
  147. package/lib/typescript/components/RasterDemSource.d.ts.map +1 -1
  148. package/lib/typescript/components/RasterLayer.d.ts +5 -1
  149. package/lib/typescript/components/RasterLayer.d.ts.map +1 -1
  150. package/lib/typescript/components/RasterSource.d.ts +4 -0
  151. package/lib/typescript/components/RasterSource.d.ts.map +1 -1
  152. package/lib/typescript/components/ShapeSource.d.ts +4 -0
  153. package/lib/typescript/components/ShapeSource.d.ts.map +1 -1
  154. package/lib/typescript/components/SkyLayer.d.ts +4 -0
  155. package/lib/typescript/components/SkyLayer.d.ts.map +1 -1
  156. package/lib/typescript/components/SymbolLayer.d.ts +5 -1
  157. package/lib/typescript/components/SymbolLayer.d.ts.map +1 -1
  158. package/lib/typescript/components/VectorSource.d.ts +4 -0
  159. package/lib/typescript/components/VectorSource.d.ts.map +1 -1
  160. package/lib/typescript/types/BaseProps.d.ts +1 -0
  161. package/lib/typescript/types/BaseProps.d.ts.map +1 -1
  162. package/lib/typescript/utils/index.d.ts +0 -14
  163. package/lib/typescript/utils/index.d.ts.map +1 -1
  164. package/lib/typescript/utils/styleMap.d.ts +0 -1406
  165. package/lib/typescript/utils/styleMap.d.ts.map +1 -1
  166. package/package.json +35 -37
  167. package/plugin/build/withMapbox.d.ts +10 -6
  168. package/plugin/build/withMapbox.js +119 -137
  169. package/plugin/install.md +21 -0
  170. package/plugin/src/withMapbox.ts +166 -138
  171. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayer.java +0 -23
  172. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLBackgroundLayerManager.java +0 -60
  173. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayer.java +0 -53
  174. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLCircleLayerManager.java +0 -73
  175. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayer.java +0 -51
  176. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillExtrusionLayerManager.java +0 -76
  177. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayer.java +0 -51
  178. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLFillLayerManager.java +0 -77
  179. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayer.java +0 -51
  180. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLHeatmapLayerManager.java +0 -73
  181. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayer.java +0 -51
  182. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLLineLayerManager.java +0 -75
  183. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayer.java +0 -24
  184. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLRasterLayerManager.java +0 -60
  185. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSkyLayerManager.java +0 -73
  186. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.java +0 -51
  187. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayerManager.java +0 -71
  188. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSource.java +0 -76
  189. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLImageSourceManager.java +0 -68
  190. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSource.java +0 -122
  191. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterDemSourceManager.java +0 -64
  192. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSource.java +0 -43
  193. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLRasterSourceManager.java +0 -39
  194. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSource.java +0 -103
  195. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLTileSourceManager.java +0 -80
  196. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSource.java +0 -100
  197. package/android/rctmgl/src/main/java-v10/com/mapbox/rctmgl/components/styles/sources/RCTMGLVectorSourceManager.java +0 -80
  198. package/javascript/components/Callout.d.ts +0 -35
  199. package/lib/commonjs/components/Callout.d.js +0 -9
  200. package/lib/commonjs/components/Callout.d.js.map +0 -1
  201. package/lib/module/components/Callout.d.js +0 -2
  202. package/lib/module/components/Callout.d.js.map +0 -1
@@ -33,65 +33,57 @@ type InstallerBlockName = 'pre' | 'post';
33
33
 
34
34
  export type MapboxPlugProps = {
35
35
  RNMapboxMapsImpl?: string;
36
+
37
+ /**
38
+ * @platform ios
39
+ */
40
+ RNMapboxMapsVersion?: string;
41
+
36
42
  RNMapboxMapsDownloadToken?: string;
37
43
  };
38
44
 
39
- /**
40
- * Dangerously adds the custom installer hooks to the Podfile.
41
- * In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
42
- *
43
- * https://github.com/rnmapbox/maps/blob/main/ios/install.md#react-native--0600
44
- * @param config
45
- * @returns
46
- */
47
- const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
48
- c,
49
- { RNMapboxMapsImpl, RNMapboxMapsDownloadToken },
50
- ) => {
51
- return withDangerousMod(c, [
52
- 'ios',
53
- async (config) => {
54
- const file = path.join(config.modRequest.platformProjectRoot, 'Podfile');
45
+ export const addInstallerBlock = (
46
+ src: string,
47
+ blockName: InstallerBlockName,
48
+ ): string => {
49
+ const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
50
+ const tag = `${blockName}_installer`;
55
51
 
56
- const contents = await promises.readFile(file, 'utf8');
52
+ for (const line of src.split('\n')) {
53
+ const contents = line.trim();
54
+ // Ignore comments
55
+ if (!contents.startsWith('#')) {
56
+ // Prevent adding the block if it exists outside of comments.
57
+ if (contents.match(matchBlock)) {
58
+ // This helps to still allow revisions, since we enabled the block previously.
59
+ // Only continue if the generated block exists...
60
+ const modified = removeGeneratedContents(src, tag);
61
+ if (!modified) {
62
+ return src;
63
+ }
64
+ }
65
+ }
66
+ }
57
67
 
58
- await promises.writeFile(
59
- file,
60
- applyCocoaPodsModifications(contents, {
61
- RNMapboxMapsImpl,
62
- RNMapboxMapsDownloadToken,
63
- }),
64
- 'utf-8',
65
- );
66
- return config;
67
- },
68
- ]);
68
+ return mergeContents({
69
+ tag,
70
+ src,
71
+ newSrc: [` ${blockName}_install do |installer|`, ' end'].join('\n'),
72
+ anchor: /use_react_native/,
73
+ // We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
74
+ offset: 0,
75
+ comment: '#',
76
+ }).contents;
69
77
  };
70
78
 
71
- // Only the preinstaller block is required, the post installer block is
72
- // used for spm (swift package manager) which Expo doesn't currently support.
73
- export function applyCocoaPodsModifications(
74
- contents: string,
75
- { RNMapboxMapsImpl, RNMapboxMapsDownloadToken }: MapboxPlugProps,
76
- ): string {
77
- // Ensure installer blocks exist
78
- let src = addConstantBlock(
79
- contents,
79
+ export const addConstantBlock = (
80
+ src: string,
81
+ {
80
82
  RNMapboxMapsImpl,
83
+ RNMapboxMapsVersion,
81
84
  RNMapboxMapsDownloadToken,
82
- );
83
- src = addInstallerBlock(src, 'pre');
84
- src = addInstallerBlock(src, 'post');
85
- src = addMapboxInstallerBlock(src, 'pre');
86
- src = addMapboxInstallerBlock(src, 'post');
87
- return src;
88
- }
89
-
90
- export function addConstantBlock(
91
- src: string,
92
- RNMapboxMapsImpl?: string,
93
- RNMapboxMapsDownloadToken?: string,
94
- ): string {
85
+ }: MapboxPlugProps,
86
+ ): string => {
95
87
  const tag = `@rnmapbox/maps-rnmapboxmapsimpl`;
96
88
 
97
89
  if (RNMapboxMapsImpl == null) {
@@ -108,6 +100,7 @@ export function addConstantBlock(
108
100
  src,
109
101
  newSrc: [
110
102
  `$RNMapboxMapsImpl = '${RNMapboxMapsImpl}'`,
103
+ `$RNMapboxMapsVersion = '${RNMapboxMapsVersion}'`,
111
104
  `$RNMapboxMapsDownloadToken = '${RNMapboxMapsDownloadToken}'`,
112
105
  ].join('\n'),
113
106
  anchor: /target .+ do/,
@@ -115,46 +108,37 @@ export function addConstantBlock(
115
108
  offset: 0,
116
109
  comment: '#',
117
110
  }).contents;
118
- }
111
+ };
119
112
 
120
- export function addInstallerBlock(
121
- src: string,
122
- blockName: InstallerBlockName,
123
- ): string {
124
- const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
125
- const tag = `${blockName}_installer`;
126
- for (const line of src.split('\n')) {
127
- const contents = line.trim();
128
- // Ignore comments
129
- if (!contents.startsWith('#')) {
130
- // Prevent adding the block if it exists outside of comments.
131
- if (contents.match(matchBlock)) {
132
- // This helps to still allow revisions, since we enabled the block previously.
133
- // Only continue if the generated block exists...
134
- const modified = removeGeneratedContents(src, tag);
135
- if (!modified) {
136
- return src;
137
- }
138
- }
139
- }
140
- }
113
+ // Only the preinstaller block is required, the post installer block is
114
+ // used for spm (swift package manager) which Expo doesn't currently support.
115
+ export const applyCocoaPodsModifications = (
116
+ contents: string,
117
+ {
118
+ RNMapboxMapsImpl,
119
+ RNMapboxMapsVersion,
120
+ RNMapboxMapsDownloadToken,
121
+ }: MapboxPlugProps,
122
+ ): string => {
123
+ // Ensure installer blocks exist
124
+ let src = addConstantBlock(contents, {
125
+ RNMapboxMapsImpl,
126
+ RNMapboxMapsVersion,
127
+ RNMapboxMapsDownloadToken,
128
+ });
129
+ src = addInstallerBlock(src, 'pre');
130
+ src = addInstallerBlock(src, 'post');
131
+ src = addMapboxInstallerBlock(src, 'pre');
132
+ src = addMapboxInstallerBlock(src, 'post');
141
133
 
142
- return mergeContents({
143
- tag,
144
- src,
145
- newSrc: [` ${blockName}_install do |installer|`, ' end'].join('\n'),
146
- anchor: /use_react_native/,
147
- // We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
148
- offset: 0,
149
- comment: '#',
150
- }).contents;
151
- }
134
+ return src;
135
+ };
152
136
 
153
- export function addMapboxInstallerBlock(
137
+ export const addMapboxInstallerBlock = (
154
138
  src: string,
155
139
  blockName: InstallerBlockName,
156
- ): string {
157
- return mergeContents({
140
+ ): string =>
141
+ mergeContents({
158
142
  tag: `@rnmapbox/maps-${blockName}_installer`,
159
143
  src,
160
144
  newSrc: ` $RNMapboxMaps.${blockName}_install(installer)`,
@@ -162,16 +146,49 @@ export function addMapboxInstallerBlock(
162
146
  offset: 1,
163
147
  comment: '#',
164
148
  }).contents;
165
- }
149
+
150
+ /**
151
+ * Dangerously adds the custom installer hooks to the Podfile.
152
+ * In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
153
+ *
154
+ * https://github.com/rnmapbox/maps/blob/main/ios/install.md#react-native--0600
155
+ */
156
+ const withCocoaPodsInstallerBlocks: ConfigPlugin<MapboxPlugProps> = (
157
+ config,
158
+ { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken },
159
+ ) =>
160
+ withDangerousMod(config, [
161
+ 'ios',
162
+ async (exportedConfig) => {
163
+ const file = path.join(
164
+ exportedConfig.modRequest.platformProjectRoot,
165
+ 'Podfile',
166
+ );
167
+
168
+ const contents = await promises.readFile(file, 'utf8');
169
+ await promises.writeFile(
170
+ file,
171
+ applyCocoaPodsModifications(contents, {
172
+ RNMapboxMapsImpl,
173
+ RNMapboxMapsVersion,
174
+ RNMapboxMapsDownloadToken,
175
+ }),
176
+ 'utf-8',
177
+ );
178
+
179
+ return exportedConfig;
180
+ },
181
+ ]);
166
182
 
167
183
  /**
168
184
  * Exclude building for arm64 on simulator devices in the pbxproj project.
169
185
  * Without this, production builds targeting simulators will fail.
170
186
  */
171
- export function setExcludedArchitectures(project: XcodeProject): XcodeProject {
172
- const configurations = project.pbxXCBuildConfigurationSection();
173
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
174
- // @ts-ignore
187
+ export const setExcludedArchitectures: (
188
+ project: XcodeProject,
189
+ ) => XcodeProject = (project: XcodeProject): XcodeProject => {
190
+ const configurations: { buildSettings: Record<string, string> }[] =
191
+ project.pbxXCBuildConfigurationSection();
175
192
  for (const { buildSettings } of Object.values(configurations || {})) {
176
193
  // Guessing that this is the best way to emulate Xcode.
177
194
  // Using `project.addToBuildSettings` modifies too many targets.
@@ -181,39 +198,39 @@ export function setExcludedArchitectures(project: XcodeProject): XcodeProject {
181
198
  }
182
199
 
183
200
  return project;
184
- }
201
+ };
185
202
 
186
- const withExcludedSimulatorArchitectures: ConfigPlugin = (c) => {
187
- return withXcodeProject(c, (config) => {
188
- config.modResults = setExcludedArchitectures(config.modResults);
189
- return config;
203
+ const withExcludedSimulatorArchitectures: ConfigPlugin = (config) =>
204
+ withXcodeProject(config, (exportedConfig) => {
205
+ exportedConfig.modResults = setExcludedArchitectures(
206
+ exportedConfig.modResults,
207
+ );
208
+
209
+ return exportedConfig;
190
210
  });
191
- };
192
211
 
193
212
  const withAndroidPropertiesDownloadToken: ConfigPlugin<MapboxPlugProps> = (
194
213
  config,
195
214
  { RNMapboxMapsDownloadToken },
196
215
  ) => {
197
216
  const key = 'MAPBOX_DOWNLOADS_TOKEN';
217
+
198
218
  if (RNMapboxMapsDownloadToken) {
199
- return withGradleProperties(config, (config) => {
200
- config.modResults = config.modResults.filter((item) => {
201
- if (item.type === 'property' && item.key === key) {
202
- return false;
203
- }
204
- return true;
205
- });
206
- config.modResults.push({
219
+ return withGradleProperties(config, (exportedConfig) => {
220
+ exportedConfig.modResults = exportedConfig.modResults.filter(
221
+ (item) => !(item.type === 'property' && item.key === key),
222
+ );
223
+ exportedConfig.modResults.push({
207
224
  type: 'property',
208
225
  key,
209
226
  value: RNMapboxMapsDownloadToken,
210
227
  });
211
228
 
212
- return config;
229
+ return exportedConfig;
213
230
  });
214
- } else {
215
- return config;
216
231
  }
232
+
233
+ return config;
217
234
  };
218
235
 
219
236
  const withAndroidPropertiesImpl2: ConfigPlugin<MapboxPlugProps> = (
@@ -221,25 +238,23 @@ const withAndroidPropertiesImpl2: ConfigPlugin<MapboxPlugProps> = (
221
238
  { RNMapboxMapsImpl },
222
239
  ) => {
223
240
  const key = 'expoRNMapboxMapsImpl';
241
+
224
242
  if (RNMapboxMapsImpl) {
225
- return withGradleProperties(config, (config) => {
226
- config.modResults = config.modResults.filter((item) => {
227
- if (item.type === 'property' && item.key === key) {
228
- return false;
229
- }
230
- return true;
231
- });
232
- config.modResults.push({
243
+ return withGradleProperties(config, (exportedConfig) => {
244
+ exportedConfig.modResults = exportedConfig.modResults.filter(
245
+ (item) => !(item.type === 'property' && item.key === key),
246
+ );
247
+ exportedConfig.modResults.push({
233
248
  type: 'property',
234
249
  key: key,
235
250
  value: RNMapboxMapsImpl,
236
251
  });
237
252
 
238
- return config;
253
+ return exportedConfig;
239
254
  });
240
- } else {
241
- return config;
242
255
  }
256
+
257
+ return config;
243
258
  };
244
259
 
245
260
  const withAndroidProperties: ConfigPlugin<MapboxPlugProps> = (
@@ -249,13 +264,18 @@ const withAndroidProperties: ConfigPlugin<MapboxPlugProps> = (
249
264
  config = withAndroidPropertiesDownloadToken(config, {
250
265
  RNMapboxMapsDownloadToken,
251
266
  });
252
- config = withAndroidPropertiesImpl2(config, { RNMapboxMapsImpl });
267
+ config = withAndroidPropertiesImpl2(config, {
268
+ RNMapboxMapsImpl,
269
+ });
270
+
253
271
  return config;
254
272
  };
255
273
 
256
274
  const addLibCppFilter = (appBuildGradle: string): string => {
257
- if (appBuildGradle.includes("pickFirst 'lib/x86/libc++_shared.so'"))
275
+ if (appBuildGradle.includes("pickFirst 'lib/x86/libc++_shared.so'")) {
258
276
  return appBuildGradle;
277
+ }
278
+
259
279
  return mergeContents({
260
280
  tag: `@rnmapbox/maps-libcpp`,
261
281
  src: appBuildGradle,
@@ -290,7 +310,7 @@ allprojects {
290
310
  `;
291
311
 
292
312
  // Fork of config-plugins mergeContents, but appends the contents to the end of the file.
293
- function appendContents({
313
+ const appendContents = ({
294
314
  src,
295
315
  newSrc,
296
316
  tag,
@@ -300,8 +320,9 @@ function appendContents({
300
320
  newSrc: string;
301
321
  tag: string;
302
322
  comment: string;
303
- }): MergeResults {
323
+ }): MergeResults => {
304
324
  const header = createGeneratedHeaderComment(newSrc, tag, comment);
325
+
305
326
  if (!src.includes(header)) {
306
327
  // Ensure the old generated contents are removed.
307
328
  const sanitizedTarget = removeGeneratedContents(src, tag);
@@ -320,47 +341,49 @@ function appendContents({
320
341
  didClear: !!sanitizedTarget,
321
342
  };
322
343
  }
344
+
323
345
  return { contents: src, didClear: false, didMerge: false };
324
- }
346
+ };
325
347
 
326
- export function addMapboxMavenRepo(src: string): string {
327
- return appendContents({
348
+ export const addMapboxMavenRepo = (src: string): string =>
349
+ appendContents({
328
350
  tag: '@rnmapbox/maps-v2-maven',
329
351
  src,
330
352
  newSrc: gradleMaven,
331
353
  comment: '//',
332
354
  }).contents;
333
- }
334
355
 
335
- const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) => {
336
- return withAppBuildGradle(config, ({ modResults, ...config }) => {
356
+ const withAndroidAppGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
357
+ withAppBuildGradle(config, ({ modResults, ...exportedConfig }) => {
337
358
  if (modResults.language !== 'groovy') {
338
359
  WarningAggregator.addWarningAndroid(
339
360
  'withMapbox',
340
361
  `Cannot automatically configure app build.gradle if it's not groovy`,
341
362
  );
342
- return { modResults, ...config };
363
+
364
+ return { modResults, ...exportedConfig };
343
365
  }
344
366
 
345
367
  modResults.contents = addLibCppFilter(modResults.contents);
346
- return { modResults, ...config };
368
+
369
+ return { modResults, ...exportedConfig };
347
370
  });
348
- };
349
371
 
350
- const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config) => {
351
- return withProjectBuildGradle(config, ({ modResults, ...config }) => {
372
+ const withAndroidProjectGradle: ConfigPlugin<MapboxPlugProps> = (config) =>
373
+ withProjectBuildGradle(config, ({ modResults, ...exportedConfig }) => {
352
374
  if (modResults.language !== 'groovy') {
353
375
  WarningAggregator.addWarningAndroid(
354
376
  'withMapbox',
355
377
  `Cannot automatically configure app build.gradle if it's not groovy`,
356
378
  );
357
- return { modResults, ...config };
379
+
380
+ return { modResults, ...exportedConfig };
358
381
  }
359
382
 
360
383
  modResults.contents = addMapboxMavenRepo(modResults.contents);
361
- return { modResults, ...config };
384
+
385
+ return { modResults, ...exportedConfig };
362
386
  });
363
- };
364
387
 
365
388
  const withMapboxAndroid: ConfigPlugin<MapboxPlugProps> = (
366
389
  config,
@@ -372,22 +395,27 @@ const withMapboxAndroid: ConfigPlugin<MapboxPlugProps> = (
372
395
  });
373
396
  config = withAndroidProjectGradle(config, { RNMapboxMapsImpl });
374
397
  config = withAndroidAppGradle(config, { RNMapboxMapsImpl });
398
+
375
399
  return config;
376
400
  };
377
401
 
378
402
  const withMapbox: ConfigPlugin<MapboxPlugProps> = (
379
403
  config,
380
- { RNMapboxMapsImpl, RNMapboxMapsDownloadToken },
404
+ { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken },
381
405
  ) => {
382
406
  config = withExcludedSimulatorArchitectures(config);
383
407
  config = withMapboxAndroid(config, {
384
408
  RNMapboxMapsImpl,
409
+ RNMapboxMapsVersion,
385
410
  RNMapboxMapsDownloadToken,
386
411
  });
387
- return withCocoaPodsInstallerBlocks(config, {
412
+ config = withCocoaPodsInstallerBlocks(config, {
388
413
  RNMapboxMapsImpl,
414
+ RNMapboxMapsVersion,
389
415
  RNMapboxMapsDownloadToken,
390
416
  });
417
+
418
+ return config;
391
419
  };
392
420
 
393
421
  export default createRunOncePlugin(withMapbox, pkg.name, pkg.version);
@@ -1,23 +0,0 @@
1
- package com.mapbox.rctmgl.components.styles.layers;
2
-
3
- import android.content.Context;
4
-
5
- import com.mapbox.maps.extension.style.layers.generated.BackgroundLayer;
6
- import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
7
- import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
8
-
9
- public class RCTMGLBackgroundLayer extends RCTLayer<BackgroundLayer> {
10
- public RCTMGLBackgroundLayer(Context context) {
11
- super(context);
12
- }
13
-
14
- @Override
15
- public BackgroundLayer makeLayer() {
16
- return new BackgroundLayer(getID());
17
- }
18
-
19
- @Override
20
- public void addStyles() {
21
- RCTMGLStyleFactory.setBackgroundLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
22
- }
23
- }
@@ -1,60 +0,0 @@
1
- package com.mapbox.rctmgl.components.styles.layers;
2
-
3
- import com.facebook.react.bridge.ReadableMap;
4
- import com.facebook.react.uimanager.ThemedReactContext;
5
- import com.facebook.react.uimanager.ViewGroupManager;
6
- import com.facebook.react.uimanager.annotations.ReactProp;
7
-
8
- public class RCTMGLBackgroundLayerManager extends ViewGroupManager<RCTMGLBackgroundLayer> {
9
- public static final String REACT_CLASS = "RCTMGLBackgroundLayer";
10
-
11
- @Override
12
- public String getName() {
13
- return REACT_CLASS;
14
- }
15
-
16
- @Override
17
- protected RCTMGLBackgroundLayer createViewInstance(ThemedReactContext reactContext) {
18
- return new RCTMGLBackgroundLayer(reactContext);
19
- }
20
-
21
- @ReactProp(name="id")
22
- public void setId(RCTMGLBackgroundLayer layer, String id) {
23
- layer.setID(id);
24
- }
25
-
26
- @ReactProp(name="sourceID")
27
- public void setSourceID(RCTMGLBackgroundLayer layer, String sourceID) {
28
- layer.setSourceID(sourceID);
29
- }
30
-
31
- @ReactProp(name="aboveLayerID")
32
- public void setAboveLayerID(RCTMGLBackgroundLayer layer, String aboveLayerID) {
33
- layer.setAboveLayerID(aboveLayerID);
34
- }
35
-
36
- @ReactProp(name="belowLayerID")
37
- public void setBelowLayerID(RCTMGLBackgroundLayer layer, String belowLayerID) {
38
- layer.setBelowLayerID(belowLayerID);
39
- }
40
-
41
- @ReactProp(name="layerIndex")
42
- public void setLayerIndex(RCTMGLBackgroundLayer layer, int layerIndex){
43
- layer.setLayerIndex(layerIndex);
44
- }
45
-
46
- @ReactProp(name="minZoomLevel")
47
- public void setMinZoomLevel(RCTMGLBackgroundLayer layer, double minZoomLevel) {
48
- layer.setMinZoomLevel(minZoomLevel);
49
- }
50
-
51
- @ReactProp(name="maxZoomLevel")
52
- public void setMaxZoomLevel(RCTMGLBackgroundLayer layer, double maxZoomLevel) {
53
- layer.setMaxZoomLevel(maxZoomLevel);
54
- }
55
-
56
- @ReactProp(name="reactStyle")
57
- public void setReactStyle(RCTMGLBackgroundLayer layer, ReadableMap style) {
58
- layer.setReactStyle(style);
59
- }
60
- }
@@ -1,53 +0,0 @@
1
- package com.mapbox.rctmgl.components.styles.layers;
2
-
3
- import android.content.Context;
4
-
5
- import com.mapbox.maps.extension.style.expressions.generated.Expression;
6
- import com.mapbox.maps.extension.style.layers.generated.CircleLayer;
7
- import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
8
- import com.mapbox.rctmgl.components.styles.RCTMGLStyle;
9
- import com.mapbox.rctmgl.components.styles.RCTMGLStyleFactory;
10
- import com.mapbox.rctmgl.utils.Logger;
11
-
12
- public class RCTMGLCircleLayer extends RCTLayer<CircleLayer> {
13
- private String mSourceLayerID;
14
-
15
- public RCTMGLCircleLayer(Context context) {
16
- super(context);
17
- }
18
-
19
- @Override
20
- protected void updateFilter(Expression expression) {
21
- mLayer.filter(expression);
22
- }
23
-
24
- @Override
25
- public void addToMap(RCTMGLMapView mapView) {
26
- super.addToMap(mapView);
27
- }
28
-
29
- @Override
30
- public CircleLayer makeLayer() {
31
- CircleLayer layer = new CircleLayer(getID(), mSourceID);
32
-
33
- if (mSourceLayerID != null) {
34
- layer.sourceLayer(mSourceLayerID);
35
-
36
- }
37
-
38
- return layer;
39
- }
40
-
41
- @Override
42
- public void addStyles() {
43
- RCTMGLStyleFactory.setCircleLayerStyle(mLayer, new RCTMGLStyle(getContext(), mReactStyle, mMap));
44
- }
45
-
46
- public void setSourceLayerID(String sourceLayerID) {
47
- mSourceLayerID = sourceLayerID;
48
-
49
- if (mLayer != null) {
50
- mLayer.sourceLayer(sourceLayerID);
51
- }
52
- }
53
- }
@@ -1,73 +0,0 @@
1
- package com.mapbox.rctmgl.components.styles.layers;
2
-
3
- import com.facebook.react.bridge.ReadableArray;
4
- import com.facebook.react.bridge.ReadableMap;
5
- import com.facebook.react.uimanager.ThemedReactContext;
6
- import com.facebook.react.uimanager.ViewGroupManager;
7
- import com.facebook.react.uimanager.annotations.ReactProp;
8
-
9
- import java.util.ArrayList;
10
-
11
- public class RCTMGLCircleLayerManager extends ViewGroupManager<RCTMGLCircleLayer> {
12
- public static final String REACT_CLASS = "RCTMGLCircleLayer";
13
-
14
- @Override
15
- public String getName() {
16
- return REACT_CLASS;
17
- }
18
-
19
- @Override
20
- protected RCTMGLCircleLayer createViewInstance(ThemedReactContext reactContext) {
21
- return new RCTMGLCircleLayer(reactContext);
22
- }
23
-
24
- @ReactProp(name="id")
25
- public void setId(RCTMGLCircleLayer layer, String id) {
26
- layer.setID(id);
27
- }
28
-
29
- @ReactProp(name="sourceID")
30
- public void setSourceID(RCTMGLCircleLayer layer, String sourceID) {
31
- layer.setSourceID(sourceID);
32
- }
33
-
34
- @ReactProp(name="aboveLayerID")
35
- public void setAboveLayerID(RCTMGLCircleLayer layer, String aboveLayerID) {
36
- layer.setAboveLayerID(aboveLayerID);
37
- }
38
-
39
- @ReactProp(name="belowLayerID")
40
- public void setBelowLayerID(RCTMGLCircleLayer layer, String belowLayerID) {
41
- layer.setBelowLayerID(belowLayerID);
42
- }
43
-
44
- @ReactProp(name="layerIndex")
45
- public void setLayerIndex(RCTMGLCircleLayer layer, int layerIndex){
46
- layer.setLayerIndex(layerIndex);
47
- }
48
-
49
- @ReactProp(name="minZoomLevel")
50
- public void setMinZoomLevel(RCTMGLCircleLayer layer, double minZoomLevel) {
51
- layer.setMinZoomLevel(minZoomLevel);
52
- }
53
-
54
- @ReactProp(name="maxZoomLevel")
55
- public void setMaxZoomLevel(RCTMGLCircleLayer layer, double maxZoomLevel) {
56
- layer.setMaxZoomLevel(maxZoomLevel);
57
- }
58
-
59
- @ReactProp(name="reactStyle")
60
- public void setReactStyle(RCTMGLCircleLayer layer, ReadableMap style) {
61
- layer.setReactStyle(style);
62
- }
63
-
64
- @ReactProp(name="sourceLayerID")
65
- public void setSourceLayerId(RCTMGLCircleLayer layer, String sourceLayerID) {
66
- layer.setSourceLayerID(sourceLayerID);
67
- }
68
-
69
- @ReactProp(name="filter")
70
- public void setFilter(RCTMGLCircleLayer layer, ReadableArray filterList) {
71
- layer.setFilter(filterList);
72
- }
73
- }