@aguacerowx/react-native 0.0.9 → 0.0.13

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 (404) hide show
  1. package/README.md +60 -60
  2. package/android/build.gradle +83 -84
  3. package/android/src/main/AndroidManifest.xml +6 -6
  4. package/android/src/main/java/com/aguacerowx/reactnative/AguaceroPackage.java +33 -33
  5. package/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +611 -611
  6. package/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +299 -299
  7. package/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +117 -117
  8. package/android/src/main/java/com/aguacerowx/reactnative/InspectorModule.java +71 -71
  9. package/android/src/main/java/com/aguacerowx/reactnative/ShaderUtils.java +106 -106
  10. package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +151 -151
  11. package/android/src/main/java/com/facebook/react/viewmanagers/.gitkeep +0 -0
  12. package/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerDelegate.java +0 -0
  13. package/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerInterface.java +0 -0
  14. package/android/src/main/res/raw/debug_fragment_shader.glsl +12 -12
  15. package/android/src/main/res/raw/debug_vertex_shader.glsl +12 -12
  16. package/android/src/main/res/raw/fragment_shader.glsl +97 -97
  17. package/android/src/main/res/raw/vertex_shader.glsl +19 -19
  18. package/index.js +3 -2
  19. package/ios/AguaceroPackage.m +18 -18
  20. package/ios/FragmentUniforms.swift +13 -13
  21. package/ios/GridRenderLayer.swift +962 -962
  22. package/ios/GridRenderLayerBridge.swift +29 -29
  23. package/ios/GridRenderLayerManager.mm +145 -145
  24. package/ios/GridRenderLayerView.h +22 -22
  25. package/ios/GridRenderLayerView.m +199 -199
  26. package/ios/InspectorDataCache.swift +65 -65
  27. package/ios/InspectorModule.m +9 -9
  28. package/ios/InspectorModule.swift +63 -63
  29. package/ios/Shaders.metal +130 -130
  30. package/ios/WeatherFrameProcessorModule.m +15 -15
  31. package/ios/WeatherFrameProcessorModule.swift +103 -103
  32. package/ios/aguacerowx-react-native.podspec +36 -35
  33. package/ios/generated/.gitkeep +0 -0
  34. package/ios/generated/AguaceroWxReactNativeSpec-generated.mm +0 -0
  35. package/ios/generated/AguaceroWxReactNativeSpec.h +0 -0
  36. package/lib/commonjs/README.md +60 -60
  37. package/lib/commonjs/android/build.gradle +83 -84
  38. package/lib/commonjs/android/src/main/AndroidManifest.xml +6 -6
  39. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/AguaceroPackage.java +33 -33
  40. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +611 -611
  41. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +299 -299
  42. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +117 -117
  43. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/InspectorModule.java +71 -71
  44. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/ShaderUtils.java +106 -106
  45. package/lib/commonjs/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +151 -151
  46. package/lib/commonjs/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerDelegate.java +0 -0
  47. package/lib/commonjs/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerInterface.java +0 -0
  48. package/lib/commonjs/android/src/main/res/raw/debug_fragment_shader.glsl +12 -12
  49. package/lib/commonjs/android/src/main/res/raw/debug_vertex_shader.glsl +12 -12
  50. package/lib/commonjs/android/src/main/res/raw/fragment_shader.glsl +97 -97
  51. package/lib/commonjs/android/src/main/res/raw/vertex_shader.glsl +19 -19
  52. package/lib/commonjs/babel.config.js.map +1 -1
  53. package/lib/commonjs/index.js +8 -0
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/ios/AguaceroPackage.m +18 -18
  56. package/lib/commonjs/ios/FragmentUniforms.swift +13 -13
  57. package/lib/commonjs/ios/GridRenderLayer.swift +962 -962
  58. package/lib/commonjs/ios/GridRenderLayerBridge.swift +29 -29
  59. package/lib/commonjs/ios/GridRenderLayerManager.mm +145 -145
  60. package/lib/commonjs/ios/GridRenderLayerView.h +22 -22
  61. package/lib/commonjs/ios/GridRenderLayerView.m +199 -199
  62. package/lib/commonjs/ios/InspectorDataCache.swift +65 -65
  63. package/lib/commonjs/ios/InspectorModule.m +9 -9
  64. package/lib/commonjs/ios/InspectorModule.swift +63 -63
  65. package/lib/commonjs/ios/Shaders.metal +130 -130
  66. package/lib/commonjs/ios/WeatherFrameProcessorModule.m +15 -15
  67. package/lib/commonjs/ios/WeatherFrameProcessorModule.swift +103 -103
  68. package/lib/commonjs/ios/aguacerowx-react-native.podspec +36 -35
  69. package/lib/commonjs/ios/generated/AguaceroWxReactNativeSpec-generated.mm +0 -0
  70. package/lib/commonjs/ios/generated/AguaceroWxReactNativeSpec.h +0 -0
  71. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
  72. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/coordinate_configs.js.map +1 -1
  73. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
  74. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
  75. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/events.js.map +1 -1
  76. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/fill-layer-worker.js.map +1 -1
  77. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/getBundleId.js.map +1 -1
  78. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
  79. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/map-styles.js.map +1 -1
  80. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/unitConversions.js.map +1 -1
  81. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
  82. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
  83. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/coordinate_configs.js.map +1 -1
  84. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
  85. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
  86. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/events.js.map +1 -1
  87. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/fill-layer-worker.js.map +1 -1
  88. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/getBundleId.js.map +1 -1
  89. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/index.js.map +1 -1
  90. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/map-styles.js.map +1 -1
  91. package/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/unitConversions.js.map +1 -1
  92. package/lib/commonjs/package.json +71 -65
  93. package/lib/commonjs/react-native-builder-bob.config.js.map +1 -1
  94. package/lib/commonjs/src/AguaceroContext.js.map +1 -1
  95. package/lib/commonjs/src/GridRenderLayer.js.map +1 -1
  96. package/lib/commonjs/src/GridRenderLayerNativeComponent.js.map +1 -1
  97. package/lib/commonjs/src/MapManager.js.map +1 -1
  98. package/lib/commonjs/src/MapRegistry.js.map +1 -1
  99. package/lib/commonjs/src/StyleApplicator.js +6 -6
  100. package/lib/commonjs/src/StyleApplicator.js.map +1 -1
  101. package/lib/commonjs/src/WeatherLayerManager.js +2 -2
  102. package/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
  103. package/lib/commonjs/tsconfig.json +23 -23
  104. package/lib/module/README.md +60 -60
  105. package/lib/module/android/build.gradle +83 -84
  106. package/lib/module/android/src/main/AndroidManifest.xml +6 -6
  107. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/AguaceroPackage.java +33 -33
  108. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayer.java +611 -611
  109. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderLayerView.java +299 -299
  110. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/GridRenderManager.java +117 -117
  111. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/InspectorModule.java +71 -71
  112. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/ShaderUtils.java +106 -106
  113. package/lib/module/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +151 -151
  114. package/lib/module/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerDelegate.java +0 -0
  115. package/lib/module/android/src/main/java/com/facebook/react/viewmanagers/GridRenderLayerManagerInterface.java +0 -0
  116. package/lib/module/android/src/main/res/raw/debug_fragment_shader.glsl +12 -12
  117. package/lib/module/android/src/main/res/raw/debug_vertex_shader.glsl +12 -12
  118. package/lib/module/android/src/main/res/raw/fragment_shader.glsl +97 -97
  119. package/lib/module/android/src/main/res/raw/vertex_shader.glsl +19 -19
  120. package/lib/module/babel.config.js.map +1 -1
  121. package/lib/module/index.js +1 -0
  122. package/lib/module/index.js.map +1 -1
  123. package/lib/module/ios/AguaceroPackage.m +18 -18
  124. package/lib/module/ios/FragmentUniforms.swift +13 -13
  125. package/lib/module/ios/GridRenderLayer.swift +962 -962
  126. package/lib/module/ios/GridRenderLayerBridge.swift +29 -29
  127. package/lib/module/ios/GridRenderLayerManager.mm +145 -145
  128. package/lib/module/ios/GridRenderLayerView.h +22 -22
  129. package/lib/module/ios/GridRenderLayerView.m +199 -199
  130. package/lib/module/ios/InspectorDataCache.swift +65 -65
  131. package/lib/module/ios/InspectorModule.m +9 -9
  132. package/lib/module/ios/InspectorModule.swift +63 -63
  133. package/lib/module/ios/Shaders.metal +130 -130
  134. package/lib/module/ios/WeatherFrameProcessorModule.m +15 -15
  135. package/lib/module/ios/WeatherFrameProcessorModule.swift +103 -103
  136. package/lib/module/ios/aguacerowx-react-native.podspec +36 -35
  137. package/lib/module/ios/generated/AguaceroWxReactNativeSpec-generated.mm +0 -0
  138. package/lib/module/ios/generated/AguaceroWxReactNativeSpec.h +0 -0
  139. package/lib/module/lib/commonjs/README.md +60 -60
  140. package/lib/module/lib/commonjs/android/build.gradle +83 -84
  141. package/lib/module/lib/commonjs/android/src/main/AndroidManifest.xml +6 -6
  142. package/lib/module/lib/commonjs/babel.config.js.map +1 -1
  143. package/lib/module/lib/commonjs/index.js +12 -0
  144. package/lib/module/lib/commonjs/index.js.map +1 -1
  145. package/lib/module/lib/commonjs/ios/AguaceroPackage.m +18 -18
  146. package/lib/module/lib/commonjs/ios/FragmentUniforms.swift +13 -13
  147. package/lib/module/lib/commonjs/ios/GridRenderLayer.swift +962 -962
  148. package/lib/module/lib/commonjs/ios/GridRenderLayerBridge.swift +29 -29
  149. package/lib/module/lib/commonjs/ios/GridRenderLayerManager.mm +145 -145
  150. package/lib/module/lib/commonjs/ios/GridRenderLayerView.h +22 -22
  151. package/lib/module/lib/commonjs/ios/GridRenderLayerView.m +199 -199
  152. package/lib/module/lib/commonjs/ios/InspectorDataCache.swift +65 -65
  153. package/lib/module/lib/commonjs/ios/InspectorModule.m +9 -9
  154. package/lib/module/lib/commonjs/ios/InspectorModule.swift +63 -63
  155. package/lib/module/lib/commonjs/ios/Shaders.metal +130 -130
  156. package/lib/module/lib/commonjs/ios/WeatherFrameProcessorModule.m +15 -15
  157. package/lib/module/lib/commonjs/ios/WeatherFrameProcessorModule.swift +103 -103
  158. package/lib/module/lib/commonjs/ios/aguacerowx-react-native.podspec +36 -35
  159. package/lib/module/lib/commonjs/ios/generated/AguaceroWxReactNativeSpec-generated.mm +0 -0
  160. package/lib/module/lib/commonjs/ios/generated/AguaceroWxReactNativeSpec.h +0 -0
  161. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
  162. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/coordinate_configs.js.map +1 -1
  163. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
  164. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
  165. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/events.js.map +1 -1
  166. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/fill-layer-worker.js.map +1 -1
  167. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/getBundleId.js.map +1 -1
  168. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
  169. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/map-styles.js.map +1 -1
  170. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/dist/unitConversions.js.map +1 -1
  171. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
  172. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
  173. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/coordinate_configs.js.map +1 -1
  174. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
  175. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
  176. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/events.js.map +1 -1
  177. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/fill-layer-worker.js.map +1 -1
  178. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/getBundleId.js.map +1 -1
  179. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/index.js.map +1 -1
  180. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/map-styles.js.map +1 -1
  181. package/lib/module/lib/commonjs/node_modules/@aguacerowx/javascript-sdk/src/unitConversions.js.map +1 -1
  182. package/lib/module/lib/commonjs/package.json +71 -65
  183. package/lib/module/lib/commonjs/react-native-builder-bob.config.js.map +1 -1
  184. package/lib/module/lib/commonjs/src/AguaceroContext.js.map +1 -1
  185. package/lib/module/lib/commonjs/src/GridRenderLayer.js.map +1 -1
  186. package/lib/module/lib/commonjs/src/GridRenderLayerNativeComponent.js.map +1 -1
  187. package/lib/module/lib/commonjs/src/MapManager.js.map +1 -1
  188. package/lib/module/lib/commonjs/src/MapRegistry.js.map +1 -1
  189. package/lib/module/lib/commonjs/src/StyleApplicator.js +6 -6
  190. package/lib/module/lib/commonjs/src/StyleApplicator.js.map +1 -1
  191. package/lib/module/lib/commonjs/src/WeatherLayerManager.js +2 -2
  192. package/lib/module/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
  193. package/lib/module/lib/commonjs/tsconfig.json +23 -23
  194. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/AguaceroCore.js.map +1 -1
  195. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/coordinate_configs.js.map +1 -1
  196. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/default-colormaps.js.map +1 -1
  197. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/dictionaries.js.map +1 -1
  198. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/events.js.map +1 -1
  199. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/fill-layer-worker.js.map +1 -1
  200. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/getBundleId.js.map +1 -1
  201. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/index.js.map +1 -1
  202. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/map-styles.js.map +1 -1
  203. package/lib/module/node_modules/@aguacerowx/javascript-sdk/dist/unitConversions.js.map +1 -1
  204. package/lib/module/node_modules/@aguacerowx/javascript-sdk/package.json +1 -1
  205. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/AguaceroCore.js.map +1 -1
  206. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/coordinate_configs.js.map +1 -1
  207. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/default-colormaps.js.map +1 -1
  208. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/dictionaries.js.map +1 -1
  209. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/events.js.map +1 -1
  210. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/fill-layer-worker.js.map +1 -1
  211. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/getBundleId.js.map +1 -1
  212. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/index.js.map +1 -1
  213. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/map-styles.js.map +1 -1
  214. package/lib/module/node_modules/@aguacerowx/javascript-sdk/src/unitConversions.js.map +1 -1
  215. package/lib/module/package.json +71 -65
  216. package/lib/module/react-native-builder-bob.config.js.map +1 -1
  217. package/lib/module/src/AguaceroContext.js.map +1 -1
  218. package/lib/module/src/GridRenderLayer.js.map +1 -1
  219. package/lib/module/src/GridRenderLayerNativeComponent.js.map +1 -1
  220. package/lib/module/src/MapManager.js.map +1 -1
  221. package/lib/module/src/MapRegistry.js.map +1 -1
  222. package/lib/module/src/StyleApplicator.js +6 -6
  223. package/lib/module/src/StyleApplicator.js.map +1 -1
  224. package/lib/module/src/WeatherLayerManager.js +2 -2
  225. package/lib/module/src/WeatherLayerManager.js.map +1 -1
  226. package/lib/module/tsconfig.json +23 -23
  227. package/lib/typescript/index.d.ts +1 -0
  228. package/package.json +71 -65
  229. package/src/AguaceroContext.js +3 -3
  230. package/src/GridRenderLayer.js +204 -204
  231. package/src/GridRenderLayerNativeComponent.ts +15 -15
  232. package/src/MapManager.js +155 -155
  233. package/src/MapRegistry.js +34 -34
  234. package/src/StyleApplicator.js +240 -240
  235. package/src/WeatherLayerManager.js +872 -872
  236. package/android/build/.transforms/78b892a9dae44f36e51ff0649e9c6e36/results.bin +0 -1
  237. package/android/build/.transforms/78b892a9dae44f36e51ff0649e9c6e36/transformed/classes/classes_dex/classes.dex +0 -0
  238. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/results.bin +0 -1
  239. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/AguaceroPackage.dex +0 -0
  240. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/BuildConfig.dex +0 -0
  241. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.dex +0 -0
  242. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/GridRenderLayer.dex +0 -0
  243. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/GridRenderLayerView.dex +0 -0
  244. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/GridRenderManager.dex +0 -0
  245. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/InspectorModule.dex +0 -0
  246. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/ShaderUtils.dex +0 -0
  247. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/aguacerowx/reactnative/WeatherFrameProcessorModule.dex +0 -0
  248. package/android/build/.transforms/f4de14556a82e99f0d27ddcab762b219/transformed/bundleLibRuntimeToDirDebug/desugar_graph.bin +0 -0
  249. package/android/build/generated/source/buildConfig/debug/com/aguacerowx/reactnative/BuildConfig.java +0 -10
  250. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -8
  251. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  252. package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  253. package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  254. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  255. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  256. package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -4
  257. package/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_fragment_shader.glsl.flat +0 -0
  258. package/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_vertex_shader.glsl.flat +0 -0
  259. package/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
  260. package/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_vertex_shader.glsl.flat +0 -0
  261. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -5
  262. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  263. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
  264. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  265. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  266. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  267. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  268. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  269. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  270. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  271. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  272. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  273. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  274. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  275. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -6
  276. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -8
  277. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -8
  278. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  279. package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  280. package/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_fragment_shader.glsl +0 -13
  281. package/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_vertex_shader.glsl +0 -13
  282. package/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +0 -98
  283. package/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/vertex_shader.glsl +0 -20
  284. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  285. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  286. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  287. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  288. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  289. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  290. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  291. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  292. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  293. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  294. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -5
  295. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -17
  296. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AguaceroPackage.class.uniqueId1 +0 -0
  297. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderLayerView.class.uniqueId2 +0 -0
  298. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderManager.class.uniqueId3 +0 -0
  299. package/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/InspectorModule.class.uniqueId0 +0 -0
  300. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  301. package/lib/commonjs/android/build/generated/source/buildConfig/debug/com/aguacerowx/reactnative/BuildConfig.java +0 -10
  302. package/lib/commonjs/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -8
  303. package/lib/commonjs/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  304. package/lib/commonjs/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  305. package/lib/commonjs/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  306. package/lib/commonjs/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  307. package/lib/commonjs/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  308. package/lib/commonjs/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -4
  309. package/lib/commonjs/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_fragment_shader.glsl.flat +0 -0
  310. package/lib/commonjs/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_vertex_shader.glsl.flat +0 -0
  311. package/lib/commonjs/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
  312. package/lib/commonjs/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_vertex_shader.glsl.flat +0 -0
  313. package/lib/commonjs/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -5
  314. package/lib/commonjs/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  315. package/lib/commonjs/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
  316. package/lib/commonjs/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  317. package/lib/commonjs/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  318. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  319. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  320. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  321. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  322. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  323. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  324. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  325. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  326. package/lib/commonjs/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  327. package/lib/commonjs/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -6
  328. package/lib/commonjs/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -8
  329. package/lib/commonjs/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -8
  330. package/lib/commonjs/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  331. package/lib/commonjs/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  332. package/lib/commonjs/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_fragment_shader.glsl +0 -13
  333. package/lib/commonjs/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_vertex_shader.glsl +0 -13
  334. package/lib/commonjs/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +0 -98
  335. package/lib/commonjs/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/vertex_shader.glsl +0 -20
  336. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  337. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  338. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  339. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  340. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  341. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  342. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  343. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  344. package/lib/commonjs/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  345. package/lib/commonjs/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  346. package/lib/commonjs/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -5
  347. package/lib/commonjs/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -17
  348. package/lib/commonjs/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AguaceroPackage.class.uniqueId1 +0 -0
  349. package/lib/commonjs/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderLayerView.class.uniqueId2 +0 -0
  350. package/lib/commonjs/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderManager.class.uniqueId3 +0 -0
  351. package/lib/commonjs/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/InspectorModule.class.uniqueId0 +0 -0
  352. package/lib/commonjs/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  353. package/lib/module/android/build/generated/source/buildConfig/debug/com/aguacerowx/reactnative/BuildConfig.java +0 -10
  354. package/lib/module/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -8
  355. package/lib/module/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  356. package/lib/module/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  357. package/lib/module/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  358. package/lib/module/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  359. package/lib/module/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  360. package/lib/module/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -4
  361. package/lib/module/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_fragment_shader.glsl.flat +0 -0
  362. package/lib/module/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_debug_vertex_shader.glsl.flat +0 -0
  363. package/lib/module/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_fragment_shader.glsl.flat +0 -0
  364. package/lib/module/android/build/intermediates/compiled_local_resources/debug/compileDebugLibraryResources/out/raw_vertex_shader.glsl.flat +0 -0
  365. package/lib/module/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -5
  366. package/lib/module/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  367. package/lib/module/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
  368. package/lib/module/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  369. package/lib/module/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  370. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  371. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  372. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  373. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  374. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  375. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  376. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  377. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  378. package/lib/module/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  379. package/lib/module/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -6
  380. package/lib/module/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -8
  381. package/lib/module/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -8
  382. package/lib/module/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  383. package/lib/module/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  384. package/lib/module/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_fragment_shader.glsl +0 -13
  385. package/lib/module/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/debug_vertex_shader.glsl +0 -13
  386. package/lib/module/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/fragment_shader.glsl +0 -98
  387. package/lib/module/android/build/intermediates/packaged_res/debug/packageDebugResources/raw/vertex_shader.glsl +0 -20
  388. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/AguaceroPackage.class +0 -0
  389. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/BuildConfig.class +0 -0
  390. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer$VertexInfo.class +0 -0
  391. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayer.class +0 -0
  392. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderLayerView.class +0 -0
  393. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/GridRenderManager.class +0 -0
  394. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/InspectorModule.class +0 -0
  395. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/ShaderUtils.class +0 -0
  396. package/lib/module/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/aguacerowx/reactnative/WeatherFrameProcessorModule.class +0 -0
  397. package/lib/module/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  398. package/lib/module/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -5
  399. package/lib/module/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -17
  400. package/lib/module/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/AguaceroPackage.class.uniqueId1 +0 -0
  401. package/lib/module/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderLayerView.class.uniqueId2 +0 -0
  402. package/lib/module/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/GridRenderManager.class.uniqueId3 +0 -0
  403. package/lib/module/android/build/tmp/compileDebugJavaWithJavac/compileTransaction/stash-dir/InspectorModule.class.uniqueId0 +0 -0
  404. package/lib/module/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
@@ -1,873 +1,873 @@
1
- // packages/react-native/src/WeatherLayerManager.js
2
-
3
- import React, { useState, useRef, useContext, useEffect, forwardRef, useImperativeHandle, useMemo } from 'react';
4
- import { AguaceroCore, getUnitConversionFunction } from '@aguacerowx/javascript-sdk';
5
- import { AguaceroContext } from './AguaceroContext';
6
- import { GridRenderLayer } from './GridRenderLayer';
7
- import { fromByteArray } from 'base64-js';
8
- import { Platform, NativeModules } from 'react-native';
9
- import { mapRegistry } from './MapRegistry';
10
-
11
- console.log("--- Aguacero Native Module Initial State Check ---");
12
- console.log("All NativeModules:", Object.keys(NativeModules));
13
- console.log("WeatherFrameProcessorModule available?:", !!NativeModules.WeatherFrameProcessorModule);
14
- console.log("InspectorModule available?:", !!NativeModules.InspectorModule);
15
- console.log("GridRenderLayerManager available?:", !!NativeModules.GridRenderLayerManager);
16
- console.log("-------------------------------------------------");
17
-
18
- const { WeatherFrameProcessorModule, InspectorModule } = NativeModules;
19
-
20
- /**
21
- * A helper function to generate the raw RGBA byte buffer for the colormap texture.
22
- */
23
- const _generateColormapBytes = (colormap) => {
24
- const width = 256;
25
- const data = new Uint8Array(width * 4);
26
- const stops = colormap.reduce((acc, _, i) => (i % 2 === 0 ? [...acc, { value: colormap[i], color: colormap[i + 1] }] : acc), []);
27
-
28
- if (stops.length === 0) return data;
29
-
30
- const minVal = stops[0].value;
31
- const maxVal = stops[stops.length - 1].value;
32
-
33
- const hexToRgb = (hex) => {
34
- const r = parseInt(hex.slice(1, 3), 16);
35
- const g = parseInt(hex.slice(3, 5), 16);
36
- const b = parseInt(hex.slice(5, 7), 16);
37
- return [r, g, b];
38
- };
39
-
40
- for (let i = 0; i < width; i++) {
41
- const val = minVal + (i / (width - 1)) * (maxVal - minVal);
42
- let lower = stops[0];
43
- let upper = stops[stops.length - 1];
44
- for (let j = 0; j < stops.length - 1; j++) {
45
- if (val >= stops[j].value && val <= stops[j + 1].value) {
46
- lower = stops[j];
47
- upper = stops[j + 1];
48
- break;
49
- }
50
- }
51
- const t = (val - lower.value) / (upper.value - lower.value || 1);
52
- const lowerRgb = hexToRgb(lower.color);
53
- const upperRgb = hexToRgb(upper.color);
54
- const rgb = lowerRgb.map((c, idx) => c * (1 - t) + upperRgb[idx] * t);
55
-
56
- const offset = i * 4;
57
- data[offset + 0] = Math.round(rgb[0]);
58
- data[offset + 1] = Math.round(rgb[1]);
59
- data[offset + 2] = Math.round(rgb[2]);
60
- data[offset + 3] = 255;
61
- }
62
- return data;
63
- };
64
-
65
- AguaceroCore.prototype.setMapCenter = function(center) {
66
- this.emit('map:move', center);
67
- };
68
-
69
- export const WeatherLayerManager = forwardRef((props, ref) => {
70
- const { inspectorEnabled, onInspect, apiKey, customColormaps, ...restProps } = props;
71
- const context = useContext(AguaceroContext);
72
-
73
- // Create the core here instead of getting it from context
74
- const core = useMemo(() => new AguaceroCore({
75
- apiKey: apiKey,
76
- customColormaps: customColormaps
77
- }), [apiKey]);
78
-
79
- const gridLayerRef = useRef(null);
80
- const currentGridDataRef = useRef(null);
81
-
82
- // Cache for preloaded grid data - stores the processed data ready for GPU upload
83
- const preloadedDataCache = useRef(new Map());
84
-
85
- // Track what we're currently preloading to avoid duplicates
86
- const preloadingSet = useRef(new Set());
87
-
88
- // Store geometry and colormap that don't change with forecast hour
89
- const cachedGeometry = useRef(null);
90
- const cachedColormap = useRef(null);
91
- const cachedDataRange = useRef([0, 1]);
92
-
93
- // Track if we've done the initial load
94
- const hasInitialLoad = useRef(false);
95
- const hasPreloadedRef = useRef(false);
96
-
97
- // Track the last state we processed to avoid redundant updates
98
- const lastProcessedState = useRef(null);
99
- const previousStateRef = useRef(null);
100
-
101
- const [renderProps, setRenderProps] = useState({
102
- opacity: 1,
103
- dataRange: [0, 1]
104
- });
105
-
106
- useImperativeHandle(ref, () => {
107
- return {
108
- play: () => {
109
- core.play();
110
- },
111
- pause: () => {
112
- core.pause();
113
- },
114
- togglePlay: () => {
115
- core.togglePlay();
116
- },
117
- step: (direction) => {
118
- core.step(direction);
119
- },
120
- setPlaybackSpeed: (speed) => core.setPlaybackSpeed(speed),
121
- setOpacity: (opacity) => core.setOpacity(opacity),
122
- setUnits: (units) => core.setUnits(units),
123
- switchMode: (options) => core.switchMode(options),
124
- getAvailableVariables: (model) => core.getAvailableVariables(model),
125
- getVariableDisplayName: (code) => core.getVariableDisplayName(code),
126
- setRun: (runString) => core.setState({ run: runString.split(':')[1] }),
127
- setState: (newState) => core.setState(newState),
128
- setMRMSTimestamp: (timestamp) => core.setMRMSTimestamp(timestamp),
129
- setSmoothing: (enabled) => {
130
- if (gridLayerRef.current) {
131
- gridLayerRef.current.setSmoothing(enabled);
132
- }
133
- },
134
- };
135
- }, [core]);
136
-
137
- const preloadAllFramesToDisk = (state) => {
138
-
139
- if (hasPreloadedRef.current) {
140
- console.log('✅ [Preload] Gating preload; already initiated for this dataset.');
141
- return;
142
- }
143
- hasPreloadedRef.current = true;
144
- console.log('🚀 [Preload] Initiating parallel preload for new dataset...');
145
-
146
- const { isMRMS, model, date, run, variable, units, availableHours, availableTimestamps, forecastHour, mrmsTimestamp } = state;
147
-
148
- if (!cachedGeometry.current || !cachedColormap.current) {
149
- const gridModel = isMRMS ? 'mrms' : model;
150
- const { corners, gridDef } = core._getGridCornersAndDef(gridModel);
151
- gridLayerRef.current.updateGeometry(corners, gridDef);
152
- cachedGeometry.current = { model: gridModel, variable };
153
-
154
- const { colormap, baseUnit } = core._getColormapForVariable(variable);
155
- const toUnit = core._getTargetUnit(baseUnit, units);
156
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
157
- const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
158
- const colormapBytes = _generateColormapBytes(finalColormap);
159
- const colormapAsBase64 = fromByteArray(colormapBytes);
160
-
161
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
162
- cachedColormap.current = { key: `${variable}-${units}` };
163
- cachedDataRange.current = dataRange;
164
-
165
- setRenderProps({ opacity: state.opacity, dataRange: dataRange });
166
- hasInitialLoad.current = true;
167
- }
168
-
169
- const allFrames = isMRMS ? availableTimestamps : availableHours;
170
- if (!allFrames || allFrames.length === 0) {
171
- console.warn('🟡 [preloadAllFramesToDisk] No frames available to download.');
172
- return;
173
- }
174
-
175
- const currentFrame = isMRMS ? mrmsTimestamp : forecastHour;
176
- const prioritizedFrames = [
177
- currentFrame,
178
- ...allFrames.filter(frame => frame !== currentFrame)
179
- ];
180
- console.log(`[Preload] Prioritizing frame: ${currentFrame}. Total frames: ${prioritizedFrames.length}`);
181
-
182
- const { corners, gridDef } = core._getGridCornersAndDef(isMRMS ? 'mrms' : model);
183
- const { nx, ny } = gridDef.grid_params;
184
-
185
- prioritizedFrames.forEach((frame, index) => {
186
- const cacheKey = isMRMS ? `mrms-${frame}-${variable}` : `${model}-${date}-${run}-${frame}-${variable}`;
187
- if (preloadedDataCache.current.has(cacheKey)) {
188
- return; // Use 'return' here as it's a forEach loop
189
- }
190
-
191
- let resourcePath;
192
- if (isMRMS) {
193
- const frameDate = new Date(frame * 1000);
194
- const y = frameDate.getUTCFullYear();
195
- const m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0');
196
- const d = frameDate.getUTCDate().toString().padStart(2, '0');
197
- resourcePath = `/grids/mrms/${y}${m}${d}/${frame}/0/${variable}/0`;
198
- } else {
199
- resourcePath = `/grids/${model}/${date}/${run}/${frame}/${variable}/0`;
200
- }
201
-
202
- const url = `${core.baseGridUrl}${resourcePath}?apiKey=${core.apiKey}`;
203
- const options = { url, apiKey: core.apiKey, bundleId: core.bundleId };
204
-
205
- WeatherFrameProcessorModule.processFrame(options)
206
- .then(result => {
207
- if (!result || !result.filePath) {
208
- console.warn(`⚠️ [preloadAllFramesToDisk] Failed frame ${frame}: No filePath`);
209
- return;
210
- }
211
-
212
- const { baseUnit } = core._getColormapForVariable(variable);
213
- const toUnit = core._getTargetUnit(baseUnit, units);
214
-
215
- let dataScale = result.scale;
216
- let dataOffset = result.offset;
217
-
218
- // Calculate converted values for immediate use
219
- let convertedScale = dataScale;
220
- let convertedOffset = dataOffset;
221
-
222
- if (baseUnit !== toUnit) {
223
- const conversionFunc = getUnitConversionFunction(baseUnit, toUnit);
224
- if (conversionFunc) {
225
- if (result.scaleType === 'sqrt') {
226
- const physicalAtOffset = dataOffset * dataOffset;
227
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
228
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
229
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
230
- convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
231
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
232
- convertedScale = newOffsetPlusScale - convertedOffset;
233
- } else {
234
- convertedOffset = conversionFunc(dataOffset);
235
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
236
- convertedScale = convertedOffsetPlusScale - convertedOffset;
237
- }
238
- }
239
- }
240
-
241
- // Store with ORIGINAL values for unit conversion later
242
- const frameData = {
243
- filePath: result.filePath,
244
- nx, ny,
245
- scale: convertedScale, // Current converted values
246
- offset: convertedOffset,
247
- missing: result.missing,
248
- corners,
249
- gridDef,
250
- scaleType: result.scaleType,
251
- originalScale: result.scale, // CRITICAL: Always original
252
- originalOffset: result.offset // CRITICAL: Always original
253
- };
254
-
255
- preloadedDataCache.current.set(cacheKey, frameData);
256
-
257
- const isCurrentFrame = index === 0;
258
-
259
- if (isCurrentFrame) {
260
- console.log(`🎯 [Preload] Using FAST LANE to process and draw current frame (${frame}) immediately.`);
261
- gridLayerRef.current.updateDataTextureFromFile(
262
- frameData.filePath,
263
- frameData.nx, frameData.ny,
264
- frameData.scale, frameData.offset, frameData.missing,
265
- frameData.scaleType
266
- );
267
-
268
- currentGridDataRef.current = {
269
- nx: frameData.nx,
270
- ny: frameData.ny,
271
- scale: frameData.scale,
272
- offset: frameData.offset,
273
- missing: frameData.missing,
274
- gridDef: frameData.gridDef,
275
- variable: variable,
276
- units: units
277
- };
278
- } else {
279
- if (Platform.OS === 'ios' && gridLayerRef.current.primeGpuCache) {
280
- const frameInfoForGpu = {
281
- [cacheKey]: {
282
- filePath: frameData.filePath,
283
- nx: frameData.nx,
284
- ny: frameData.ny,
285
- scale: frameData.scale, // Current converted scale
286
- offset: frameData.offset, // Current converted offset
287
- missing: frameData.missing,
288
- scaleType: frameData.scaleType || 'linear',
289
- originalScale: frameData.originalScale, // ADD THIS
290
- originalOffset: frameData.originalOffset // ADD THIS
291
- }
292
- };
293
- gridLayerRef.current.primeGpuCache(frameInfoForGpu);
294
- }
295
- }
296
- })
297
- .catch(error => {
298
- console.warn(`⚠️ [preloadAllFramesToDisk] Failed frame ${frame}:`, error);
299
- });
300
- });
301
- };
302
-
303
- const updateGPUWithCachedData = (state) => {
304
- const { model, date, run, forecastHour, variable, units, isMRMS, mrmsTimestamp } = state;
305
-
306
- const cacheKey = isMRMS
307
- ? `mrms-${mrmsTimestamp}-${variable}`
308
- : `${model}-${date}-${run}-${forecastHour}-${variable}`;
309
-
310
- if (Platform.OS === 'ios' && gridLayerRef.current.setActiveFrame) {
311
- // Get the cached data BEFORE calling setActiveFrame
312
- const cachedData = preloadedDataCache.current.get(cacheKey);
313
-
314
- if (cachedData) {
315
- currentGridDataRef.current = {
316
- nx: cachedData.nx,
317
- ny: cachedData.ny,
318
- scale: cachedData.scale,
319
- offset: cachedData.offset,
320
- missing: cachedData.missing,
321
- gridDef: cachedData.gridDef,
322
- variable: variable,
323
- units: units,
324
- scaleType: cachedData.scaleType
325
- };
326
-
327
- console.log('📱 [iOS] Updated currentGridDataRef for inspector:', {
328
- scale: cachedData.scale,
329
- offset: cachedData.offset,
330
- scaleType: cachedData.scaleType // ADD THIS
331
- });
332
- }
333
-
334
- // Now call setActiveFrame (which will async update the native cache)
335
- gridLayerRef.current.setActiveFrame(cacheKey);
336
- return true;
337
- }
338
-
339
- const cachedData = preloadedDataCache.current.get(cacheKey);
340
-
341
- if (!cachedData) {
342
- const timeKey = isMRMS ? `timestamp ${mrmsTimestamp}` : `hour +${forecastHour}`;
343
- console.log(`⏳ [updateGPUWithCachedData] Frame not ready yet for ${timeKey}. Still preloading...`); // CHANGED
344
- return false;
345
- }
346
-
347
- if (!gridLayerRef.current) {
348
- console.warn(`⚠️ [updateGPUWithCachedData] GridLayer ref not available`); // CHANGED
349
- return false;
350
- }
351
-
352
- if (!cachedGeometry.current || cachedGeometry.current.model !== (isMRMS ? 'mrms' : model) || cachedGeometry.current.variable !== variable) {
353
- gridLayerRef.current.updateGeometry(cachedData.corners, cachedData.gridDef);
354
- cachedGeometry.current = { model: (isMRMS ? 'mrms' : model), variable };
355
- }
356
-
357
- const colormapKey = `${variable}-${units}`;
358
- if (!cachedColormap.current || cachedColormap.current.key !== colormapKey) {
359
- const { colormap, baseUnit } = core._getColormapForVariable(variable);
360
- const toUnit = core._getTargetUnit(baseUnit, units);
361
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
362
- const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
363
- const colormapBytes = _generateColormapBytes(finalColormap);
364
- const colormapAsBase64 = fromByteArray(colormapBytes);
365
-
366
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
367
- cachedColormap.current = { key: colormapKey };
368
- cachedDataRange.current = dataRange;
369
-
370
- setRenderProps(prev => ({ ...prev, dataRange }));
371
- }
372
-
373
- if (cachedData.filePath) {
374
- gridLayerRef.current.updateDataTextureFromFile(
375
- cachedData.filePath,
376
- cachedData.nx, cachedData.ny,
377
- cachedData.scale, cachedData.offset, cachedData.missing,
378
- cachedData.scaleType
379
- );
380
-
381
- // ADD THIS: Update inspector cache for file-based data too
382
- currentGridDataRef.current = {
383
- nx: cachedData.nx,
384
- ny: cachedData.ny,
385
- scale: cachedData.scale,
386
- offset: cachedData.offset,
387
- missing: cachedData.missing,
388
- gridDef: cachedData.gridDef,
389
- variable: variable,
390
- units: units
391
- };
392
- } else if (cachedData.dataAsBase64) {
393
- gridLayerRef.current.updateDataTexture(
394
- cachedData.dataAsBase64,
395
- cachedData.nx, cachedData.ny,
396
- cachedData.scale, cachedData.offset, cachedData.missing,
397
- cachedData.scaleType
398
- );
399
-
400
- // Update the inspector cache when using dataAsBase64
401
- const binaryString = atob(cachedData.dataAsBase64);
402
- const uint8Array = new Uint8Array(binaryString.length);
403
-
404
- for (let i = 0; i < binaryString.length; i++) {
405
- uint8Array[i] = binaryString.charCodeAt(i);
406
- }
407
-
408
- currentGridDataRef.current = {
409
- data: uint8Array,
410
- nx: cachedData.nx,
411
- ny: cachedData.ny,
412
- scale: cachedData.scale,
413
- offset: cachedData.offset,
414
- missing: cachedData.missing,
415
- gridDef: cachedData.gridDef,
416
- variable: variable,
417
- units: units
418
- };
419
- } else {
420
- console.error(`❌ [updateGPUWithCachedData] Cached data has no filePath or dataAsBase64!`);
421
- console.error('❌ [updateGPUWithCachedData] Cached data keys:', Object.keys(cachedData));
422
- return false;
423
- }
424
-
425
- // Update inspector parameters for file-based data too
426
- if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
427
- gridLayerRef.current.updateDataParameters(cachedData.scale, cachedData.offset, cachedData.missing);
428
- }
429
- return true;
430
- };
431
-
432
- const handleStateChangeRef = useRef(null);
433
- const debounceTimeoutRef = useRef(null);
434
-
435
- useEffect(() => {
436
- if (core && props.customColormaps) {
437
- core.customColormaps = props.customColormaps;
438
- // Trigger a re-render if we already have data loaded
439
- if (hasInitialLoad.current) {
440
- core._emitStateChange();
441
- }
442
- }
443
- }, [core, props.customColormaps]);
444
-
445
- const getValueAtPoint = async (lng, lat) => {
446
- if (!core) {
447
- console.warn('🔍 [Inspector] Core not available');
448
- return null;
449
- }
450
-
451
- // ADD THIS: Check if we have valid data before attempting inspection
452
- if (!currentGridDataRef.current) {
453
- console.log('🔍 [Inspector] No grid data available');
454
- return null;
455
- }
456
-
457
- try {
458
- const gridIndices = core._getGridIndexFromLngLat(lng, lat);
459
- if (!gridIndices) return null;
460
-
461
- const { i, j } = gridIndices;
462
-
463
- const value = await InspectorModule.getValueAtGridIndex(i, j);
464
-
465
- if (value === null) {
466
- return null;
467
- }
468
-
469
- const { colormap, baseUnit } = core._getColormapForVariable(core.state.variable);
470
- const displayUnit = core._getTargetUnit(baseUnit, core.state.units);
471
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, displayUnit);
472
- const minThreshold = finalColormap[0];
473
-
474
- if (value < minThreshold) {
475
- console.log('🔍 [Inspector] Rejected: below threshold'); // ADD THIS LOG
476
- return null;
477
- }
478
-
479
- // Filter out values below the minimum threshold (matching shader behavior)
480
- if (value < minThreshold) {
481
- return null;
482
- }
483
-
484
- // Also check if value is NaN or effectively missing
485
- if (!isFinite(value)) {
486
- return null;
487
- }
488
-
489
- return {
490
- value: value,
491
- unit: displayUnit,
492
- variable: {
493
- code: core.state.variable,
494
- name: core.getVariableDisplayName(core.state.variable)
495
- },
496
- lngLat: { lng, lat }
497
- };
498
- } catch (error) {
499
- console.error('🔍 [Inspector] Error:', error);
500
- return null;
501
- }
502
- };
503
-
504
- useEffect(() => {
505
- if (!core) {
506
- console.warn('⚠️ [useEffect] Core is not available yet');
507
- return;
508
- }
509
-
510
- const handleStateChange = async (newState) => {
511
- if (!previousStateRef.current) {
512
- previousStateRef.current = core.state;
513
- }
514
-
515
- const stateKey = `${newState.model}-${newState.variable}-${newState.date}-${newState.run}-${newState.forecastHour}-${newState.units}-${newState.mrmsTimestamp}`;
516
-
517
- const isOpacityOnlyChange =
518
- hasInitialLoad.current &&
519
- newState.opacity !== renderProps.opacity &&
520
- newState.variable === previousStateRef.current?.variable &&
521
- newState.forecastHour === previousStateRef.current?.forecastHour &&
522
- newState.mrmsTimestamp === previousStateRef.current?.mrmsTimestamp &&
523
- newState.model === previousStateRef.current?.model &&
524
- newState.units === previousStateRef.current?.units;
525
-
526
-
527
- if (!isOpacityOnlyChange && lastProcessedState.current === stateKey) {
528
- return;
529
- }
530
-
531
- if (!isOpacityOnlyChange) {
532
- lastProcessedState.current = stateKey;
533
- }
534
-
535
- props.onStateChange?.(newState);
536
-
537
- if (isOpacityOnlyChange) {
538
- setRenderProps(prev => ({ ...prev, opacity: newState.opacity }));
539
- previousStateRef.current = newState;
540
- return;
541
- }
542
-
543
- // Check if only units changed
544
- const isUnitsOnlyChange =
545
- hasInitialLoad.current &&
546
- newState.model === previousStateRef.current.model &&
547
- newState.isMRMS === previousStateRef.current.isMRMS &&
548
- newState.variable === previousStateRef.current.variable &&
549
- newState.date === previousStateRef.current.date &&
550
- newState.run === previousStateRef.current.run &&
551
- newState.forecastHour === previousStateRef.current.forecastHour &&
552
- newState.mrmsTimestamp === previousStateRef.current.mrmsTimestamp &&
553
- newState.units !== previousStateRef.current.units;
554
-
555
- if (isUnitsOnlyChange) {
556
- const { variable, units, isMRMS, mrmsTimestamp, model, date, run, forecastHour } = newState;
557
- const oldCacheKey = isMRMS
558
- ? `mrms-${mrmsTimestamp}-${variable}`
559
- : `${model}-${date}-${run}-${forecastHour}-${variable}`;
560
-
561
- const cachedData = preloadedDataCache.current.get(oldCacheKey);
562
-
563
- if (cachedData && cachedData.originalScale !== undefined && cachedData.originalOffset !== undefined) {
564
- const { baseUnit } = core._getColormapForVariable(variable);
565
- const toUnit = core._getTargetUnit(baseUnit, units);
566
-
567
- let dataScale = cachedData.originalScale;
568
- let dataOffset = cachedData.originalOffset;
569
-
570
- if (baseUnit !== toUnit) {
571
- const conversionFunc = getUnitConversionFunction(baseUnit, toUnit);
572
- console.log('🔧 [Unit Conversion] Conversion function exists:', !!conversionFunc);
573
-
574
- if (conversionFunc) {
575
- if (cachedData.scaleType === 'sqrt') {
576
- // Calculate what the physical values would be at offset and offset+scale
577
- const physicalAtOffset = dataOffset * dataOffset;
578
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
579
-
580
- // Convert these physical values to the new unit
581
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
582
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
583
-
584
- // Take sqrt to get back to intermediate values
585
- const newOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
586
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
587
-
588
- dataScale = newOffsetPlusScale - newOffset;
589
- dataOffset = newOffset;
590
- } else {
591
- const convertedOffset = conversionFunc(dataOffset);
592
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
593
-
594
- dataScale = convertedOffsetPlusScale - convertedOffset;
595
- dataOffset = convertedOffset;
596
- }
597
- }
598
- }
599
-
600
- // Update the colormap AND data range
601
- const { colormap } = core._getColormapForVariable(variable);
602
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
603
- const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
604
-
605
- const colormapBytes = _generateColormapBytes(finalColormap);
606
- const colormapAsBase64 = fromByteArray(colormapBytes);
607
-
608
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
609
- cachedColormap.current = { key: `${variable}-${units}` };
610
- cachedDataRange.current = dataRange;
611
-
612
- setRenderProps(prev => ({ ...prev, dataRange, opacity: newState.opacity }));
613
-
614
- if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
615
- const scaleTypeValue = cachedData.scaleType === 'sqrt' ? 1 : 0; // Convert to number
616
-
617
- console.log('🔄 [Unit Conversion] Calling updateDataParameters with:', {
618
- scale: dataScale,
619
- offset: dataOffset,
620
- missing: cachedData.missing,
621
- scaleType: scaleTypeValue
622
- });
623
-
624
- gridLayerRef.current.updateDataParameters(dataScale, dataOffset, cachedData.missing, scaleTypeValue); // Pass scaleType
625
- }
626
-
627
- const newCacheKey = isMRMS
628
- ? `mrms-${mrmsTimestamp}-${variable}`
629
- : `${model}-${date}-${run}-${forecastHour}-${variable}`;
630
-
631
- preloadedDataCache.current.set(newCacheKey, {
632
- ...cachedData,
633
- scale: dataScale,
634
- offset: dataOffset
635
- });
636
-
637
- } else {
638
- console.warn('⚠️ [Unit Conversion] No cached data found for key:', oldCacheKey);
639
- }
640
-
641
- previousStateRef.current = newState;
642
- return;
643
- }
644
-
645
- const needsFullLoad =
646
- !hasInitialLoad.current ||
647
- newState.model !== previousStateRef.current.model ||
648
- newState.isMRMS !== previousStateRef.current.isMRMS ||
649
- newState.variable !== previousStateRef.current.variable ||
650
- newState.date !== previousStateRef.current.date ||
651
- newState.run !== previousStateRef.current.run;
652
-
653
- if (needsFullLoad) {
654
-
655
- if (gridLayerRef.current) {
656
- gridLayerRef.current.clear();
657
- // --- OPTIMIZATION: Clear the native GPU cache on iOS ---
658
- if (Platform.OS === 'ios' && gridLayerRef.current.clearGpuCache) {
659
- gridLayerRef.current.clearGpuCache();
660
- }
661
- }
662
- hasPreloadedRef.current = false;
663
-
664
- preloadedDataCache.current.clear();
665
- cachedGeometry.current = null;
666
- cachedColormap.current = null;
667
-
668
- // ADD THIS: Clear the inspector cache too
669
- currentGridDataRef.current = null;
670
-
671
- WeatherFrameProcessorModule.cancelAllFrames();
672
-
673
- if (!newState.variable) {
674
- previousStateRef.current = newState;
675
- return;
676
- }
677
-
678
- preloadAllFramesToDisk(newState);
679
- } else if (newState.forecastHour !== previousStateRef.current.forecastHour || (newState.isMRMS && newState.mrmsTimestamp !== previousStateRef.current.mrmsTimestamp)) {
680
- const success = updateGPUWithCachedData(newState);
681
-
682
- if (!success) {
683
- // CHANGED: Don't error, just log and wait for preload
684
- const timeKey = newState.isMRMS ? `timestamp ${newState.mrmsTimestamp}` : `hour +${newState.forecastHour}`;
685
- console.log(`⏳ [handleStateChange] Frame ${timeKey} not ready yet, waiting for preload...`);
686
- // Don't clear the layer - keep showing the previous frame until new one is ready
687
- // The preload will eventually complete and trigger a re-render
688
- } else {
689
- // Only update inspector cache when we successfully loaded new data
690
- if (newState.opacity !== renderProps.opacity) {
691
- setRenderProps(prev => ({ ...prev, opacity: newState.opacity }));
692
- }
693
- }
694
- }
695
-
696
- previousStateRef.current = newState;
697
- };
698
-
699
- handleStateChangeRef.current = handleStateChange;
700
-
701
- const stableHandler = (newState) => {
702
- const isOpacityOnlyChange =
703
- previousStateRef.current &&
704
- newState.opacity !== previousStateRef.current.opacity &&
705
- newState.variable === previousStateRef.current.variable &&
706
- newState.forecastHour === previousStateRef.current.forecastHour &&
707
- newState.mrmsTimestamp === previousStateRef.current.mrmsTimestamp &&
708
- newState.model === previousStateRef.current.model &&
709
- newState.units === previousStateRef.current.units &&
710
- newState.date === previousStateRef.current.date &&
711
- newState.run === previousStateRef.current.run;
712
-
713
- if (isOpacityOnlyChange) {
714
- if (handleStateChangeRef.current) {
715
- handleStateChangeRef.current(newState);
716
- }
717
- return;
718
- }
719
-
720
- if (debounceTimeoutRef.current) {
721
- clearTimeout(debounceTimeoutRef.current);
722
- }
723
-
724
- debounceTimeoutRef.current = setTimeout(() => {
725
- if (handleStateChangeRef.current) {
726
- handleStateChangeRef.current(newState);
727
- }
728
- debounceTimeoutRef.current = null;
729
- }, 50);
730
- };
731
-
732
- core.on('state:change', stableHandler);
733
-
734
- return () => {
735
- core.off('state:change', stableHandler);
736
- if (debounceTimeoutRef.current) {
737
- clearTimeout(debounceTimeoutRef.current);
738
- }
739
- };
740
- }, [core]);
741
-
742
- useEffect(() => {
743
- return () => {
744
- preloadedDataCache.current.clear();
745
- hasInitialLoad.current = false;
746
- lastProcessedState.current = null;
747
- };
748
- }, []);
749
-
750
- const lastInspectorUpdateRef = useRef(0);
751
- const INSPECTOR_THROTTLE_MS = 50;
752
-
753
- useEffect(() => {
754
- if (!core || !inspectorEnabled) {
755
- return;
756
- }
757
-
758
- const handleMapMove = async (center) => {
759
- if (!center || !Array.isArray(center) || center.length !== 2) {
760
- return;
761
- }
762
-
763
- // Throttle updates
764
- const now = Date.now();
765
- if (now - lastInspectorUpdateRef.current < INSPECTOR_THROTTLE_MS) {
766
- return;
767
- }
768
- lastInspectorUpdateRef.current = now;
769
-
770
- const [longitude, latitude] = center;
771
-
772
- const payload = await getValueAtPoint(longitude, latitude);
773
- onInspect?.(payload);
774
- };
775
-
776
- core.on('map:move', handleMapMove);
777
-
778
- if (context && context.getCenter) {
779
- const center = context.getCenter();
780
- if (center) {
781
- handleMapMove(center);
782
- }
783
- }
784
-
785
- return () => {
786
- core.off('map:move', handleMapMove);
787
- };
788
- }, [inspectorEnabled, onInspect, core, context]);
789
-
790
- // Add this new useEffect after the existing inspector useEffect
791
- useEffect(() => {
792
- // Trigger re-inspection when state changes (variable, model, forecast hour, etc.)
793
- if (!core || !inspectorEnabled) {
794
- return;
795
- }
796
-
797
- const triggerReinspection = () => {
798
- const mapRef = mapRegistry.getMap();
799
- const center = mapRef?._currentCenter;
800
-
801
- if (center && Array.isArray(center) && center.length === 2) {
802
- const [longitude, latitude] = center;
803
-
804
- getValueAtPoint(longitude, latitude).then(payload => {
805
- onInspect?.(payload);
806
- });
807
- }
808
- };
809
-
810
- // Small delay to ensure data is loaded before re-inspecting
811
- const timer = setTimeout(triggerReinspection, 100);
812
-
813
- return () => clearTimeout(timer);
814
- }, [
815
- core?.state?.variable,
816
- core?.state?.model,
817
- core?.state?.forecastHour,
818
- core?.state?.mrmsTimestamp,
819
- core?.state?.units,
820
- inspectorEnabled,
821
- onInspect
822
- ]);
823
-
824
- useEffect(() => {
825
- if (!core) {
826
- return;
827
- }
828
-
829
- const handleCameraChange = (center) => {
830
- if (core && center) {
831
- core.setMapCenter(center);
832
- }
833
- };
834
-
835
- // Register with the global registry
836
- mapRegistry.addCameraListener(handleCameraChange);
837
-
838
- // Try to get initial center
839
- const mapRef = mapRegistry.getMap();
840
- if (mapRef?._currentCenter) {
841
- handleCameraChange(mapRef._currentCenter);
842
- }
843
-
844
- return () => {
845
- mapRegistry.removeCameraListener(handleCameraChange);
846
- };
847
- }, [core]);
848
-
849
- useEffect(() => {
850
- core.initialize();
851
- return () => {
852
- core.destroy();
853
- };
854
- }, [core]);
855
-
856
- return (
857
- <GridRenderLayer
858
- ref={gridLayerRef}
859
- opacity={renderProps.opacity}
860
- dataRange={renderProps.dataRange}
861
- belowID="AML_-_terrain"
862
- />
863
- );
864
- });
865
-
866
- WeatherLayerManager.getAvailableVariables = (options) => {
867
- if (!options || !options.apiKey) {
868
- console.error("API key must be provided to get available variables.");
869
- return [];
870
- }
871
- const core = new AguaceroCore({ apiKey: options.apiKey });
872
- return core.getAvailableVariables('mrms');
1
+ // packages/react-native/src/WeatherLayerManager.js
2
+
3
+ import React, { useState, useRef, useContext, useEffect, forwardRef, useImperativeHandle, useMemo } from 'react';
4
+ import { AguaceroCore, getUnitConversionFunction } from '@aguacerowx/javascript-sdk';
5
+ import { AguaceroContext } from './AguaceroContext';
6
+ import { GridRenderLayer } from './GridRenderLayer';
7
+ import { fromByteArray } from 'base64-js';
8
+ import { Platform, NativeModules } from 'react-native';
9
+ import { mapRegistry } from './MapRegistry';
10
+
11
+ console.log("--- Aguacero Native Module Initial State Check ---");
12
+ console.log("All NativeModules:", Object.keys(NativeModules));
13
+ console.log("WeatherFrameProcessorModule available?:", !!NativeModules.WeatherFrameProcessorModule);
14
+ console.log("InspectorModule available?:", !!NativeModules.InspectorModule);
15
+ console.log("GridRenderLayerManager available?:", !!NativeModules.GridRenderLayerManager);
16
+ console.log("-------------------------------------------------");
17
+
18
+ const { WeatherFrameProcessorModule, InspectorModule } = NativeModules;
19
+
20
+ /**
21
+ * A helper function to generate the raw RGBA byte buffer for the colormap texture.
22
+ */
23
+ const _generateColormapBytes = (colormap) => {
24
+ const width = 256;
25
+ const data = new Uint8Array(width * 4);
26
+ const stops = colormap.reduce((acc, _, i) => (i % 2 === 0 ? [...acc, { value: colormap[i], color: colormap[i + 1] }] : acc), []);
27
+
28
+ if (stops.length === 0) return data;
29
+
30
+ const minVal = stops[0].value;
31
+ const maxVal = stops[stops.length - 1].value;
32
+
33
+ const hexToRgb = (hex) => {
34
+ const r = parseInt(hex.slice(1, 3), 16);
35
+ const g = parseInt(hex.slice(3, 5), 16);
36
+ const b = parseInt(hex.slice(5, 7), 16);
37
+ return [r, g, b];
38
+ };
39
+
40
+ for (let i = 0; i < width; i++) {
41
+ const val = minVal + (i / (width - 1)) * (maxVal - minVal);
42
+ let lower = stops[0];
43
+ let upper = stops[stops.length - 1];
44
+ for (let j = 0; j < stops.length - 1; j++) {
45
+ if (val >= stops[j].value && val <= stops[j + 1].value) {
46
+ lower = stops[j];
47
+ upper = stops[j + 1];
48
+ break;
49
+ }
50
+ }
51
+ const t = (val - lower.value) / (upper.value - lower.value || 1);
52
+ const lowerRgb = hexToRgb(lower.color);
53
+ const upperRgb = hexToRgb(upper.color);
54
+ const rgb = lowerRgb.map((c, idx) => c * (1 - t) + upperRgb[idx] * t);
55
+
56
+ const offset = i * 4;
57
+ data[offset + 0] = Math.round(rgb[0]);
58
+ data[offset + 1] = Math.round(rgb[1]);
59
+ data[offset + 2] = Math.round(rgb[2]);
60
+ data[offset + 3] = 255;
61
+ }
62
+ return data;
63
+ };
64
+
65
+ AguaceroCore.prototype.setMapCenter = function(center) {
66
+ this.emit('map:move', center);
67
+ };
68
+
69
+ export const WeatherLayerManager = forwardRef((props, ref) => {
70
+ const { inspectorEnabled, onInspect, apiKey, customColormaps, ...restProps } = props;
71
+ const context = useContext(AguaceroContext);
72
+
73
+ // Create the core here instead of getting it from context
74
+ const core = useMemo(() => new AguaceroCore({
75
+ apiKey: apiKey,
76
+ customColormaps: customColormaps
77
+ }), [apiKey]);
78
+
79
+ const gridLayerRef = useRef(null);
80
+ const currentGridDataRef = useRef(null);
81
+
82
+ // Cache for preloaded grid data - stores the processed data ready for GPU upload
83
+ const preloadedDataCache = useRef(new Map());
84
+
85
+ // Track what we're currently preloading to avoid duplicates
86
+ const preloadingSet = useRef(new Set());
87
+
88
+ // Store geometry and colormap that don't change with forecast hour
89
+ const cachedGeometry = useRef(null);
90
+ const cachedColormap = useRef(null);
91
+ const cachedDataRange = useRef([0, 1]);
92
+
93
+ // Track if we've done the initial load
94
+ const hasInitialLoad = useRef(false);
95
+ const hasPreloadedRef = useRef(false);
96
+
97
+ // Track the last state we processed to avoid redundant updates
98
+ const lastProcessedState = useRef(null);
99
+ const previousStateRef = useRef(null);
100
+
101
+ const [renderProps, setRenderProps] = useState({
102
+ opacity: 1,
103
+ dataRange: [0, 1]
104
+ });
105
+
106
+ useImperativeHandle(ref, () => {
107
+ return {
108
+ play: () => {
109
+ core.play();
110
+ },
111
+ pause: () => {
112
+ core.pause();
113
+ },
114
+ togglePlay: () => {
115
+ core.togglePlay();
116
+ },
117
+ step: (direction) => {
118
+ core.step(direction);
119
+ },
120
+ setPlaybackSpeed: (speed) => core.setPlaybackSpeed(speed),
121
+ setOpacity: (opacity) => core.setOpacity(opacity),
122
+ setUnits: (units) => core.setUnits(units),
123
+ switchMode: (options) => core.switchMode(options),
124
+ getAvailableVariables: (model) => core.getAvailableVariables(model),
125
+ getVariableDisplayName: (code) => core.getVariableDisplayName(code),
126
+ setRun: (runString) => core.setState({ run: runString.split(':')[1] }),
127
+ setState: (newState) => core.setState(newState),
128
+ setMRMSTimestamp: (timestamp) => core.setMRMSTimestamp(timestamp),
129
+ setSmoothing: (enabled) => {
130
+ if (gridLayerRef.current) {
131
+ gridLayerRef.current.setSmoothing(enabled);
132
+ }
133
+ },
134
+ };
135
+ }, [core]);
136
+
137
+ const preloadAllFramesToDisk = (state) => {
138
+
139
+ if (hasPreloadedRef.current) {
140
+ console.log('✅ [Preload] Gating preload; already initiated for this dataset.');
141
+ return;
142
+ }
143
+ hasPreloadedRef.current = true;
144
+ console.log('🚀 [Preload] Initiating parallel preload for new dataset...');
145
+
146
+ const { isMRMS, model, date, run, variable, units, availableHours, availableTimestamps, forecastHour, mrmsTimestamp } = state;
147
+
148
+ if (!cachedGeometry.current || !cachedColormap.current) {
149
+ const gridModel = isMRMS ? 'mrms' : model;
150
+ const { corners, gridDef } = core._getGridCornersAndDef(gridModel);
151
+ gridLayerRef.current.updateGeometry(corners, gridDef);
152
+ cachedGeometry.current = { model: gridModel, variable };
153
+
154
+ const { colormap, baseUnit } = core._getColormapForVariable(variable);
155
+ const toUnit = core._getTargetUnit(baseUnit, units);
156
+ const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
157
+ const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
158
+ const colormapBytes = _generateColormapBytes(finalColormap);
159
+ const colormapAsBase64 = fromByteArray(colormapBytes);
160
+
161
+ gridLayerRef.current.updateColormapTexture(colormapAsBase64);
162
+ cachedColormap.current = { key: `${variable}-${units}` };
163
+ cachedDataRange.current = dataRange;
164
+
165
+ setRenderProps({ opacity: state.opacity, dataRange: dataRange });
166
+ hasInitialLoad.current = true;
167
+ }
168
+
169
+ const allFrames = isMRMS ? availableTimestamps : availableHours;
170
+ if (!allFrames || allFrames.length === 0) {
171
+ console.warn('🟡 [preloadAllFramesToDisk] No frames available to download.');
172
+ return;
173
+ }
174
+
175
+ const currentFrame = isMRMS ? mrmsTimestamp : forecastHour;
176
+ const prioritizedFrames = [
177
+ currentFrame,
178
+ ...allFrames.filter(frame => frame !== currentFrame)
179
+ ];
180
+ console.log(`[Preload] Prioritizing frame: ${currentFrame}. Total frames: ${prioritizedFrames.length}`);
181
+
182
+ const { corners, gridDef } = core._getGridCornersAndDef(isMRMS ? 'mrms' : model);
183
+ const { nx, ny } = gridDef.grid_params;
184
+
185
+ prioritizedFrames.forEach((frame, index) => {
186
+ const cacheKey = isMRMS ? `mrms-${frame}-${variable}` : `${model}-${date}-${run}-${frame}-${variable}`;
187
+ if (preloadedDataCache.current.has(cacheKey)) {
188
+ return; // Use 'return' here as it's a forEach loop
189
+ }
190
+
191
+ let resourcePath;
192
+ if (isMRMS) {
193
+ const frameDate = new Date(frame * 1000);
194
+ const y = frameDate.getUTCFullYear();
195
+ const m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0');
196
+ const d = frameDate.getUTCDate().toString().padStart(2, '0');
197
+ resourcePath = `/grids/mrms/${y}${m}${d}/${frame}/0/${variable}/0`;
198
+ } else {
199
+ resourcePath = `/grids/${model}/${date}/${run}/${frame}/${variable}/0`;
200
+ }
201
+
202
+ const url = `${core.baseGridUrl}${resourcePath}?apiKey=${core.apiKey}`;
203
+ const options = { url, apiKey: core.apiKey, bundleId: core.bundleId };
204
+
205
+ WeatherFrameProcessorModule.processFrame(options)
206
+ .then(result => {
207
+ if (!result || !result.filePath) {
208
+ console.warn(`⚠️ [preloadAllFramesToDisk] Failed frame ${frame}: No filePath`);
209
+ return;
210
+ }
211
+
212
+ const { baseUnit } = core._getColormapForVariable(variable);
213
+ const toUnit = core._getTargetUnit(baseUnit, units);
214
+
215
+ let dataScale = result.scale;
216
+ let dataOffset = result.offset;
217
+
218
+ // Calculate converted values for immediate use
219
+ let convertedScale = dataScale;
220
+ let convertedOffset = dataOffset;
221
+
222
+ if (baseUnit !== toUnit) {
223
+ const conversionFunc = getUnitConversionFunction(baseUnit, toUnit);
224
+ if (conversionFunc) {
225
+ if (result.scaleType === 'sqrt') {
226
+ const physicalAtOffset = dataOffset * dataOffset;
227
+ const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
228
+ const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
229
+ const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
230
+ convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
231
+ const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
232
+ convertedScale = newOffsetPlusScale - convertedOffset;
233
+ } else {
234
+ convertedOffset = conversionFunc(dataOffset);
235
+ const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
236
+ convertedScale = convertedOffsetPlusScale - convertedOffset;
237
+ }
238
+ }
239
+ }
240
+
241
+ // Store with ORIGINAL values for unit conversion later
242
+ const frameData = {
243
+ filePath: result.filePath,
244
+ nx, ny,
245
+ scale: convertedScale, // Current converted values
246
+ offset: convertedOffset,
247
+ missing: result.missing,
248
+ corners,
249
+ gridDef,
250
+ scaleType: result.scaleType,
251
+ originalScale: result.scale, // CRITICAL: Always original
252
+ originalOffset: result.offset // CRITICAL: Always original
253
+ };
254
+
255
+ preloadedDataCache.current.set(cacheKey, frameData);
256
+
257
+ const isCurrentFrame = index === 0;
258
+
259
+ if (isCurrentFrame) {
260
+ console.log(`🎯 [Preload] Using FAST LANE to process and draw current frame (${frame}) immediately.`);
261
+ gridLayerRef.current.updateDataTextureFromFile(
262
+ frameData.filePath,
263
+ frameData.nx, frameData.ny,
264
+ frameData.scale, frameData.offset, frameData.missing,
265
+ frameData.scaleType
266
+ );
267
+
268
+ currentGridDataRef.current = {
269
+ nx: frameData.nx,
270
+ ny: frameData.ny,
271
+ scale: frameData.scale,
272
+ offset: frameData.offset,
273
+ missing: frameData.missing,
274
+ gridDef: frameData.gridDef,
275
+ variable: variable,
276
+ units: units
277
+ };
278
+ } else {
279
+ if (Platform.OS === 'ios' && gridLayerRef.current.primeGpuCache) {
280
+ const frameInfoForGpu = {
281
+ [cacheKey]: {
282
+ filePath: frameData.filePath,
283
+ nx: frameData.nx,
284
+ ny: frameData.ny,
285
+ scale: frameData.scale, // Current converted scale
286
+ offset: frameData.offset, // Current converted offset
287
+ missing: frameData.missing,
288
+ scaleType: frameData.scaleType || 'linear',
289
+ originalScale: frameData.originalScale, // ADD THIS
290
+ originalOffset: frameData.originalOffset // ADD THIS
291
+ }
292
+ };
293
+ gridLayerRef.current.primeGpuCache(frameInfoForGpu);
294
+ }
295
+ }
296
+ })
297
+ .catch(error => {
298
+ console.warn(`⚠️ [preloadAllFramesToDisk] Failed frame ${frame}:`, error);
299
+ });
300
+ });
301
+ };
302
+
303
+ const updateGPUWithCachedData = (state) => {
304
+ const { model, date, run, forecastHour, variable, units, isMRMS, mrmsTimestamp } = state;
305
+
306
+ const cacheKey = isMRMS
307
+ ? `mrms-${mrmsTimestamp}-${variable}`
308
+ : `${model}-${date}-${run}-${forecastHour}-${variable}`;
309
+
310
+ if (Platform.OS === 'ios' && gridLayerRef.current.setActiveFrame) {
311
+ // Get the cached data BEFORE calling setActiveFrame
312
+ const cachedData = preloadedDataCache.current.get(cacheKey);
313
+
314
+ if (cachedData) {
315
+ currentGridDataRef.current = {
316
+ nx: cachedData.nx,
317
+ ny: cachedData.ny,
318
+ scale: cachedData.scale,
319
+ offset: cachedData.offset,
320
+ missing: cachedData.missing,
321
+ gridDef: cachedData.gridDef,
322
+ variable: variable,
323
+ units: units,
324
+ scaleType: cachedData.scaleType
325
+ };
326
+
327
+ console.log('📱 [iOS] Updated currentGridDataRef for inspector:', {
328
+ scale: cachedData.scale,
329
+ offset: cachedData.offset,
330
+ scaleType: cachedData.scaleType // ADD THIS
331
+ });
332
+ }
333
+
334
+ // Now call setActiveFrame (which will async update the native cache)
335
+ gridLayerRef.current.setActiveFrame(cacheKey);
336
+ return true;
337
+ }
338
+
339
+ const cachedData = preloadedDataCache.current.get(cacheKey);
340
+
341
+ if (!cachedData) {
342
+ const timeKey = isMRMS ? `timestamp ${mrmsTimestamp}` : `hour +${forecastHour}`;
343
+ console.log(`⏳ [updateGPUWithCachedData] Frame not ready yet for ${timeKey}. Still preloading...`); // CHANGED
344
+ return false;
345
+ }
346
+
347
+ if (!gridLayerRef.current) {
348
+ console.warn(`⚠️ [updateGPUWithCachedData] GridLayer ref not available`); // CHANGED
349
+ return false;
350
+ }
351
+
352
+ if (!cachedGeometry.current || cachedGeometry.current.model !== (isMRMS ? 'mrms' : model) || cachedGeometry.current.variable !== variable) {
353
+ gridLayerRef.current.updateGeometry(cachedData.corners, cachedData.gridDef);
354
+ cachedGeometry.current = { model: (isMRMS ? 'mrms' : model), variable };
355
+ }
356
+
357
+ const colormapKey = `${variable}-${units}`;
358
+ if (!cachedColormap.current || cachedColormap.current.key !== colormapKey) {
359
+ const { colormap, baseUnit } = core._getColormapForVariable(variable);
360
+ const toUnit = core._getTargetUnit(baseUnit, units);
361
+ const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
362
+ const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
363
+ const colormapBytes = _generateColormapBytes(finalColormap);
364
+ const colormapAsBase64 = fromByteArray(colormapBytes);
365
+
366
+ gridLayerRef.current.updateColormapTexture(colormapAsBase64);
367
+ cachedColormap.current = { key: colormapKey };
368
+ cachedDataRange.current = dataRange;
369
+
370
+ setRenderProps(prev => ({ ...prev, dataRange }));
371
+ }
372
+
373
+ if (cachedData.filePath) {
374
+ gridLayerRef.current.updateDataTextureFromFile(
375
+ cachedData.filePath,
376
+ cachedData.nx, cachedData.ny,
377
+ cachedData.scale, cachedData.offset, cachedData.missing,
378
+ cachedData.scaleType
379
+ );
380
+
381
+ // ADD THIS: Update inspector cache for file-based data too
382
+ currentGridDataRef.current = {
383
+ nx: cachedData.nx,
384
+ ny: cachedData.ny,
385
+ scale: cachedData.scale,
386
+ offset: cachedData.offset,
387
+ missing: cachedData.missing,
388
+ gridDef: cachedData.gridDef,
389
+ variable: variable,
390
+ units: units
391
+ };
392
+ } else if (cachedData.dataAsBase64) {
393
+ gridLayerRef.current.updateDataTexture(
394
+ cachedData.dataAsBase64,
395
+ cachedData.nx, cachedData.ny,
396
+ cachedData.scale, cachedData.offset, cachedData.missing,
397
+ cachedData.scaleType
398
+ );
399
+
400
+ // Update the inspector cache when using dataAsBase64
401
+ const binaryString = atob(cachedData.dataAsBase64);
402
+ const uint8Array = new Uint8Array(binaryString.length);
403
+
404
+ for (let i = 0; i < binaryString.length; i++) {
405
+ uint8Array[i] = binaryString.charCodeAt(i);
406
+ }
407
+
408
+ currentGridDataRef.current = {
409
+ data: uint8Array,
410
+ nx: cachedData.nx,
411
+ ny: cachedData.ny,
412
+ scale: cachedData.scale,
413
+ offset: cachedData.offset,
414
+ missing: cachedData.missing,
415
+ gridDef: cachedData.gridDef,
416
+ variable: variable,
417
+ units: units
418
+ };
419
+ } else {
420
+ console.error(`❌ [updateGPUWithCachedData] Cached data has no filePath or dataAsBase64!`);
421
+ console.error('❌ [updateGPUWithCachedData] Cached data keys:', Object.keys(cachedData));
422
+ return false;
423
+ }
424
+
425
+ // Update inspector parameters for file-based data too
426
+ if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
427
+ gridLayerRef.current.updateDataParameters(cachedData.scale, cachedData.offset, cachedData.missing);
428
+ }
429
+ return true;
430
+ };
431
+
432
+ const handleStateChangeRef = useRef(null);
433
+ const debounceTimeoutRef = useRef(null);
434
+
435
+ useEffect(() => {
436
+ if (core && props.customColormaps) {
437
+ core.customColormaps = props.customColormaps;
438
+ // Trigger a re-render if we already have data loaded
439
+ if (hasInitialLoad.current) {
440
+ core._emitStateChange();
441
+ }
442
+ }
443
+ }, [core, props.customColormaps]);
444
+
445
+ const getValueAtPoint = async (lng, lat) => {
446
+ if (!core) {
447
+ console.warn('🔍 [Inspector] Core not available');
448
+ return null;
449
+ }
450
+
451
+ // ADD THIS: Check if we have valid data before attempting inspection
452
+ if (!currentGridDataRef.current) {
453
+ console.log('🔍 [Inspector] No grid data available');
454
+ return null;
455
+ }
456
+
457
+ try {
458
+ const gridIndices = core._getGridIndexFromLngLat(lng, lat);
459
+ if (!gridIndices) return null;
460
+
461
+ const { i, j } = gridIndices;
462
+
463
+ const value = await InspectorModule.getValueAtGridIndex(i, j);
464
+
465
+ if (value === null) {
466
+ return null;
467
+ }
468
+
469
+ const { colormap, baseUnit } = core._getColormapForVariable(core.state.variable);
470
+ const displayUnit = core._getTargetUnit(baseUnit, core.state.units);
471
+ const finalColormap = core._convertColormapUnits(colormap, baseUnit, displayUnit);
472
+ const minThreshold = finalColormap[0];
473
+
474
+ if (value < minThreshold) {
475
+ console.log('🔍 [Inspector] Rejected: below threshold'); // ADD THIS LOG
476
+ return null;
477
+ }
478
+
479
+ // Filter out values below the minimum threshold (matching shader behavior)
480
+ if (value < minThreshold) {
481
+ return null;
482
+ }
483
+
484
+ // Also check if value is NaN or effectively missing
485
+ if (!isFinite(value)) {
486
+ return null;
487
+ }
488
+
489
+ return {
490
+ value: value,
491
+ unit: displayUnit,
492
+ variable: {
493
+ code: core.state.variable,
494
+ name: core.getVariableDisplayName(core.state.variable)
495
+ },
496
+ lngLat: { lng, lat }
497
+ };
498
+ } catch (error) {
499
+ console.error('🔍 [Inspector] Error:', error);
500
+ return null;
501
+ }
502
+ };
503
+
504
+ useEffect(() => {
505
+ if (!core) {
506
+ console.warn('⚠️ [useEffect] Core is not available yet');
507
+ return;
508
+ }
509
+
510
+ const handleStateChange = async (newState) => {
511
+ if (!previousStateRef.current) {
512
+ previousStateRef.current = core.state;
513
+ }
514
+
515
+ const stateKey = `${newState.model}-${newState.variable}-${newState.date}-${newState.run}-${newState.forecastHour}-${newState.units}-${newState.mrmsTimestamp}`;
516
+
517
+ const isOpacityOnlyChange =
518
+ hasInitialLoad.current &&
519
+ newState.opacity !== renderProps.opacity &&
520
+ newState.variable === previousStateRef.current?.variable &&
521
+ newState.forecastHour === previousStateRef.current?.forecastHour &&
522
+ newState.mrmsTimestamp === previousStateRef.current?.mrmsTimestamp &&
523
+ newState.model === previousStateRef.current?.model &&
524
+ newState.units === previousStateRef.current?.units;
525
+
526
+
527
+ if (!isOpacityOnlyChange && lastProcessedState.current === stateKey) {
528
+ return;
529
+ }
530
+
531
+ if (!isOpacityOnlyChange) {
532
+ lastProcessedState.current = stateKey;
533
+ }
534
+
535
+ props.onStateChange?.(newState);
536
+
537
+ if (isOpacityOnlyChange) {
538
+ setRenderProps(prev => ({ ...prev, opacity: newState.opacity }));
539
+ previousStateRef.current = newState;
540
+ return;
541
+ }
542
+
543
+ // Check if only units changed
544
+ const isUnitsOnlyChange =
545
+ hasInitialLoad.current &&
546
+ newState.model === previousStateRef.current.model &&
547
+ newState.isMRMS === previousStateRef.current.isMRMS &&
548
+ newState.variable === previousStateRef.current.variable &&
549
+ newState.date === previousStateRef.current.date &&
550
+ newState.run === previousStateRef.current.run &&
551
+ newState.forecastHour === previousStateRef.current.forecastHour &&
552
+ newState.mrmsTimestamp === previousStateRef.current.mrmsTimestamp &&
553
+ newState.units !== previousStateRef.current.units;
554
+
555
+ if (isUnitsOnlyChange) {
556
+ const { variable, units, isMRMS, mrmsTimestamp, model, date, run, forecastHour } = newState;
557
+ const oldCacheKey = isMRMS
558
+ ? `mrms-${mrmsTimestamp}-${variable}`
559
+ : `${model}-${date}-${run}-${forecastHour}-${variable}`;
560
+
561
+ const cachedData = preloadedDataCache.current.get(oldCacheKey);
562
+
563
+ if (cachedData && cachedData.originalScale !== undefined && cachedData.originalOffset !== undefined) {
564
+ const { baseUnit } = core._getColormapForVariable(variable);
565
+ const toUnit = core._getTargetUnit(baseUnit, units);
566
+
567
+ let dataScale = cachedData.originalScale;
568
+ let dataOffset = cachedData.originalOffset;
569
+
570
+ if (baseUnit !== toUnit) {
571
+ const conversionFunc = getUnitConversionFunction(baseUnit, toUnit);
572
+ console.log('🔧 [Unit Conversion] Conversion function exists:', !!conversionFunc);
573
+
574
+ if (conversionFunc) {
575
+ if (cachedData.scaleType === 'sqrt') {
576
+ // Calculate what the physical values would be at offset and offset+scale
577
+ const physicalAtOffset = dataOffset * dataOffset;
578
+ const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
579
+
580
+ // Convert these physical values to the new unit
581
+ const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
582
+ const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
583
+
584
+ // Take sqrt to get back to intermediate values
585
+ const newOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
586
+ const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
587
+
588
+ dataScale = newOffsetPlusScale - newOffset;
589
+ dataOffset = newOffset;
590
+ } else {
591
+ const convertedOffset = conversionFunc(dataOffset);
592
+ const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
593
+
594
+ dataScale = convertedOffsetPlusScale - convertedOffset;
595
+ dataOffset = convertedOffset;
596
+ }
597
+ }
598
+ }
599
+
600
+ // Update the colormap AND data range
601
+ const { colormap } = core._getColormapForVariable(variable);
602
+ const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
603
+ const dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
604
+
605
+ const colormapBytes = _generateColormapBytes(finalColormap);
606
+ const colormapAsBase64 = fromByteArray(colormapBytes);
607
+
608
+ gridLayerRef.current.updateColormapTexture(colormapAsBase64);
609
+ cachedColormap.current = { key: `${variable}-${units}` };
610
+ cachedDataRange.current = dataRange;
611
+
612
+ setRenderProps(prev => ({ ...prev, dataRange, opacity: newState.opacity }));
613
+
614
+ if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
615
+ const scaleTypeValue = cachedData.scaleType === 'sqrt' ? 1 : 0; // Convert to number
616
+
617
+ console.log('🔄 [Unit Conversion] Calling updateDataParameters with:', {
618
+ scale: dataScale,
619
+ offset: dataOffset,
620
+ missing: cachedData.missing,
621
+ scaleType: scaleTypeValue
622
+ });
623
+
624
+ gridLayerRef.current.updateDataParameters(dataScale, dataOffset, cachedData.missing, scaleTypeValue); // Pass scaleType
625
+ }
626
+
627
+ const newCacheKey = isMRMS
628
+ ? `mrms-${mrmsTimestamp}-${variable}`
629
+ : `${model}-${date}-${run}-${forecastHour}-${variable}`;
630
+
631
+ preloadedDataCache.current.set(newCacheKey, {
632
+ ...cachedData,
633
+ scale: dataScale,
634
+ offset: dataOffset
635
+ });
636
+
637
+ } else {
638
+ console.warn('⚠️ [Unit Conversion] No cached data found for key:', oldCacheKey);
639
+ }
640
+
641
+ previousStateRef.current = newState;
642
+ return;
643
+ }
644
+
645
+ const needsFullLoad =
646
+ !hasInitialLoad.current ||
647
+ newState.model !== previousStateRef.current.model ||
648
+ newState.isMRMS !== previousStateRef.current.isMRMS ||
649
+ newState.variable !== previousStateRef.current.variable ||
650
+ newState.date !== previousStateRef.current.date ||
651
+ newState.run !== previousStateRef.current.run;
652
+
653
+ if (needsFullLoad) {
654
+
655
+ if (gridLayerRef.current) {
656
+ gridLayerRef.current.clear();
657
+ // --- OPTIMIZATION: Clear the native GPU cache on iOS ---
658
+ if (Platform.OS === 'ios' && gridLayerRef.current.clearGpuCache) {
659
+ gridLayerRef.current.clearGpuCache();
660
+ }
661
+ }
662
+ hasPreloadedRef.current = false;
663
+
664
+ preloadedDataCache.current.clear();
665
+ cachedGeometry.current = null;
666
+ cachedColormap.current = null;
667
+
668
+ // ADD THIS: Clear the inspector cache too
669
+ currentGridDataRef.current = null;
670
+
671
+ WeatherFrameProcessorModule.cancelAllFrames();
672
+
673
+ if (!newState.variable) {
674
+ previousStateRef.current = newState;
675
+ return;
676
+ }
677
+
678
+ preloadAllFramesToDisk(newState);
679
+ } else if (newState.forecastHour !== previousStateRef.current.forecastHour || (newState.isMRMS && newState.mrmsTimestamp !== previousStateRef.current.mrmsTimestamp)) {
680
+ const success = updateGPUWithCachedData(newState);
681
+
682
+ if (!success) {
683
+ // CHANGED: Don't error, just log and wait for preload
684
+ const timeKey = newState.isMRMS ? `timestamp ${newState.mrmsTimestamp}` : `hour +${newState.forecastHour}`;
685
+ console.log(`⏳ [handleStateChange] Frame ${timeKey} not ready yet, waiting for preload...`);
686
+ // Don't clear the layer - keep showing the previous frame until new one is ready
687
+ // The preload will eventually complete and trigger a re-render
688
+ } else {
689
+ // Only update inspector cache when we successfully loaded new data
690
+ if (newState.opacity !== renderProps.opacity) {
691
+ setRenderProps(prev => ({ ...prev, opacity: newState.opacity }));
692
+ }
693
+ }
694
+ }
695
+
696
+ previousStateRef.current = newState;
697
+ };
698
+
699
+ handleStateChangeRef.current = handleStateChange;
700
+
701
+ const stableHandler = (newState) => {
702
+ const isOpacityOnlyChange =
703
+ previousStateRef.current &&
704
+ newState.opacity !== previousStateRef.current.opacity &&
705
+ newState.variable === previousStateRef.current.variable &&
706
+ newState.forecastHour === previousStateRef.current.forecastHour &&
707
+ newState.mrmsTimestamp === previousStateRef.current.mrmsTimestamp &&
708
+ newState.model === previousStateRef.current.model &&
709
+ newState.units === previousStateRef.current.units &&
710
+ newState.date === previousStateRef.current.date &&
711
+ newState.run === previousStateRef.current.run;
712
+
713
+ if (isOpacityOnlyChange) {
714
+ if (handleStateChangeRef.current) {
715
+ handleStateChangeRef.current(newState);
716
+ }
717
+ return;
718
+ }
719
+
720
+ if (debounceTimeoutRef.current) {
721
+ clearTimeout(debounceTimeoutRef.current);
722
+ }
723
+
724
+ debounceTimeoutRef.current = setTimeout(() => {
725
+ if (handleStateChangeRef.current) {
726
+ handleStateChangeRef.current(newState);
727
+ }
728
+ debounceTimeoutRef.current = null;
729
+ }, 50);
730
+ };
731
+
732
+ core.on('state:change', stableHandler);
733
+
734
+ return () => {
735
+ core.off('state:change', stableHandler);
736
+ if (debounceTimeoutRef.current) {
737
+ clearTimeout(debounceTimeoutRef.current);
738
+ }
739
+ };
740
+ }, [core]);
741
+
742
+ useEffect(() => {
743
+ return () => {
744
+ preloadedDataCache.current.clear();
745
+ hasInitialLoad.current = false;
746
+ lastProcessedState.current = null;
747
+ };
748
+ }, []);
749
+
750
+ const lastInspectorUpdateRef = useRef(0);
751
+ const INSPECTOR_THROTTLE_MS = 50;
752
+
753
+ useEffect(() => {
754
+ if (!core || !inspectorEnabled) {
755
+ return;
756
+ }
757
+
758
+ const handleMapMove = async (center) => {
759
+ if (!center || !Array.isArray(center) || center.length !== 2) {
760
+ return;
761
+ }
762
+
763
+ // Throttle updates
764
+ const now = Date.now();
765
+ if (now - lastInspectorUpdateRef.current < INSPECTOR_THROTTLE_MS) {
766
+ return;
767
+ }
768
+ lastInspectorUpdateRef.current = now;
769
+
770
+ const [longitude, latitude] = center;
771
+
772
+ const payload = await getValueAtPoint(longitude, latitude);
773
+ onInspect?.(payload);
774
+ };
775
+
776
+ core.on('map:move', handleMapMove);
777
+
778
+ if (context && context.getCenter) {
779
+ const center = context.getCenter();
780
+ if (center) {
781
+ handleMapMove(center);
782
+ }
783
+ }
784
+
785
+ return () => {
786
+ core.off('map:move', handleMapMove);
787
+ };
788
+ }, [inspectorEnabled, onInspect, core, context]);
789
+
790
+ // Add this new useEffect after the existing inspector useEffect
791
+ useEffect(() => {
792
+ // Trigger re-inspection when state changes (variable, model, forecast hour, etc.)
793
+ if (!core || !inspectorEnabled) {
794
+ return;
795
+ }
796
+
797
+ const triggerReinspection = () => {
798
+ const mapRef = mapRegistry.getMap();
799
+ const center = mapRef?._currentCenter;
800
+
801
+ if (center && Array.isArray(center) && center.length === 2) {
802
+ const [longitude, latitude] = center;
803
+
804
+ getValueAtPoint(longitude, latitude).then(payload => {
805
+ onInspect?.(payload);
806
+ });
807
+ }
808
+ };
809
+
810
+ // Small delay to ensure data is loaded before re-inspecting
811
+ const timer = setTimeout(triggerReinspection, 100);
812
+
813
+ return () => clearTimeout(timer);
814
+ }, [
815
+ core?.state?.variable,
816
+ core?.state?.model,
817
+ core?.state?.forecastHour,
818
+ core?.state?.mrmsTimestamp,
819
+ core?.state?.units,
820
+ inspectorEnabled,
821
+ onInspect
822
+ ]);
823
+
824
+ useEffect(() => {
825
+ if (!core) {
826
+ return;
827
+ }
828
+
829
+ const handleCameraChange = (center) => {
830
+ if (core && center) {
831
+ core.setMapCenter(center);
832
+ }
833
+ };
834
+
835
+ // Register with the global registry
836
+ mapRegistry.addCameraListener(handleCameraChange);
837
+
838
+ // Try to get initial center
839
+ const mapRef = mapRegistry.getMap();
840
+ if (mapRef?._currentCenter) {
841
+ handleCameraChange(mapRef._currentCenter);
842
+ }
843
+
844
+ return () => {
845
+ mapRegistry.removeCameraListener(handleCameraChange);
846
+ };
847
+ }, [core]);
848
+
849
+ useEffect(() => {
850
+ core.initialize();
851
+ return () => {
852
+ core.destroy();
853
+ };
854
+ }, [core]);
855
+
856
+ return (
857
+ <GridRenderLayer
858
+ ref={gridLayerRef}
859
+ opacity={renderProps.opacity}
860
+ dataRange={renderProps.dataRange}
861
+ belowID="AML_-_terrain"
862
+ />
863
+ );
864
+ });
865
+
866
+ WeatherLayerManager.getAvailableVariables = (options) => {
867
+ if (!options || !options.apiKey) {
868
+ console.error("API key must be provided to get available variables.");
869
+ return [];
870
+ }
871
+ const core = new AguaceroCore({ apiKey: options.apiKey });
872
+ return core.getAvailableVariables('mrms');
873
873
  };