@aguacerowx/react-native 0.0.52 → 0.0.54

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 (265) hide show
  1. package/LICENSE +21 -0
  2. package/android/src/main/cpp/satellite_ktx_jni.cpp +6 -1
  3. package/android/src/main/java/com/aguacerowx/reactnative/NexradRadarLayerView.java +14 -2
  4. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayer.java +121 -1
  5. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayerView.java +556 -392
  6. package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +77 -0
  7. package/index.js +1 -1
  8. package/ios/SatelliteLayerView.swift +517 -517
  9. package/ios/WeatherFrameProcessorModule.m +19 -15
  10. package/ios/WeatherFrameProcessorModule.swift +65 -0
  11. package/lib/commonjs/AguaceroContext.js +0 -4
  12. package/lib/commonjs/AguaceroContext.js.map +1 -1
  13. package/lib/commonjs/GridRenderLayer.js +62 -76
  14. package/lib/commonjs/GridRenderLayer.js.map +1 -1
  15. package/lib/commonjs/MapManager.js +110 -224
  16. package/lib/commonjs/MapManager.js.map +1 -1
  17. package/lib/commonjs/MapRegistry.js +21 -33
  18. package/lib/commonjs/MapRegistry.js.map +1 -1
  19. package/lib/commonjs/NexradRadarLayer.android.js +28 -100
  20. package/lib/commonjs/NexradRadarLayer.android.js.map +1 -1
  21. package/lib/commonjs/NexradRadarLayer.ios.js +26 -97
  22. package/lib/commonjs/NexradRadarLayer.ios.js.map +1 -1
  23. package/lib/commonjs/NexradSitesMapLayer.js +41 -61
  24. package/lib/commonjs/NexradSitesMapLayer.js.map +1 -1
  25. package/lib/commonjs/SatelliteLayer.android.js +26 -38
  26. package/lib/commonjs/SatelliteLayer.android.js.map +1 -1
  27. package/lib/commonjs/SatelliteLayer.ios.js +30 -42
  28. package/lib/commonjs/SatelliteLayer.ios.js.map +1 -1
  29. package/lib/commonjs/StyleApplicator.js +129 -175
  30. package/lib/commonjs/StyleApplicator.js.map +1 -1
  31. package/lib/commonjs/WeatherLayerManager.js +996 -1627
  32. package/lib/commonjs/WeatherLayerManager.js.map +1 -1
  33. package/lib/commonjs/aguaceroCoreDebugHooks.js +58 -130
  34. package/lib/commonjs/aguaceroCoreDebugHooks.js.map +1 -1
  35. package/lib/commonjs/aguaceroRnDebug.js +147 -287
  36. package/lib/commonjs/aguaceroRnDebug.js.map +1 -1
  37. package/lib/commonjs/cdnAuthenticatedFetch.js +104 -0
  38. package/lib/commonjs/cdnAuthenticatedFetch.js.map +1 -0
  39. package/lib/commonjs/dispatchViewManagerCommandCompat.js +51 -88
  40. package/lib/commonjs/dispatchViewManagerCommandCompat.js.map +1 -1
  41. package/lib/commonjs/gridCdnAuth.js +41 -50
  42. package/lib/commonjs/gridCdnAuth.js.map +1 -1
  43. package/lib/commonjs/index.js +51 -0
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/commonjs/nexrad/nexradAndroidController.js +851 -863
  46. package/lib/commonjs/nexrad/nexradAndroidController.js.map +1 -1
  47. package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
  48. package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
  49. package/lib/commonjs/nexrad/nexradDiag.js +32 -148
  50. package/lib/commonjs/nexrad/nexradDiag.js.map +1 -1
  51. package/lib/commonjs/nexrad/nexradLevel2Keys.js +261 -0
  52. package/lib/commonjs/nexrad/nexradLevel2Keys.js.map +1 -0
  53. package/lib/commonjs/nexrad/nexradLutBuild.js +64 -111
  54. package/lib/commonjs/nexrad/nexradLutBuild.js.map +1 -1
  55. package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js +136 -164
  56. package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
  57. package/lib/commonjs/nexrad/nexradSdkImports.js +51 -0
  58. package/lib/commonjs/nexrad/nexradSdkImports.js.map +1 -0
  59. package/lib/commonjs/nexrad/radarArchiveCore.bundled.js +2848 -4455
  60. package/lib/commonjs/nexrad/radarArchiveCore.bundled.js.map +1 -1
  61. package/lib/commonjs/nexrad/radarDecode.worker.bundled.js +445 -648
  62. package/lib/commonjs/nexrad/radarDecode.worker.bundled.js.map +1 -1
  63. package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js +52 -68
  64. package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
  65. package/lib/commonjs/nexradNativeCommandIds.js +24 -0
  66. package/lib/commonjs/nexradNativeCommandIds.js.map +1 -0
  67. package/lib/commonjs/nws/NwsAlertsOverlay.android.js.map +1 -1
  68. package/lib/commonjs/nws/NwsAlertsOverlay.ios.js.map +1 -1
  69. package/lib/commonjs/nws/NwsAlertsOverlay.js +3 -3
  70. package/lib/commonjs/nws/NwsAlertsOverlay.js.map +1 -1
  71. package/lib/commonjs/nws/NwsAlertsOverlay.native.js +235 -361
  72. package/lib/commonjs/nws/NwsAlertsOverlay.native.js.map +1 -1
  73. package/lib/commonjs/nws/eventSourceRnPolyfill.js +92 -146
  74. package/lib/commonjs/nws/eventSourceRnPolyfill.js.map +1 -1
  75. package/lib/commonjs/nws/nwsAndroidConstants.js +2 -8
  76. package/lib/commonjs/nws/nwsAndroidConstants.js.map +1 -1
  77. package/lib/commonjs/satellite/satelliteAndroidController.js +122 -199
  78. package/lib/commonjs/satellite/satelliteAndroidController.js.map +1 -1
  79. package/lib/commonjs/satelliteBridgeDiag.js +3 -13
  80. package/lib/commonjs/satelliteBridgeDiag.js.map +1 -1
  81. package/lib/commonjs/satelliteRnDebug.js +160 -0
  82. package/lib/commonjs/satelliteRnDebug.js.map +1 -0
  83. package/lib/module/AguaceroContext.js +2 -7
  84. package/lib/module/AguaceroContext.js.map +1 -1
  85. package/lib/module/GridRenderLayer.js +66 -80
  86. package/lib/module/GridRenderLayer.js.map +1 -1
  87. package/lib/module/MapManager.js +125 -239
  88. package/lib/module/MapManager.js.map +1 -1
  89. package/lib/module/MapRegistry.js +21 -33
  90. package/lib/module/MapRegistry.js.map +1 -1
  91. package/lib/module/NexradRadarLayer.android.js +32 -104
  92. package/lib/module/NexradRadarLayer.android.js.map +1 -1
  93. package/lib/module/NexradRadarLayer.ios.js +30 -101
  94. package/lib/module/NexradRadarLayer.ios.js.map +1 -1
  95. package/lib/module/NexradSitesMapLayer.js +44 -63
  96. package/lib/module/NexradSitesMapLayer.js.map +1 -1
  97. package/lib/module/SatelliteLayer.android.js +32 -44
  98. package/lib/module/SatelliteLayer.android.js.map +1 -1
  99. package/lib/module/SatelliteLayer.ios.js +36 -48
  100. package/lib/module/SatelliteLayer.ios.js.map +1 -1
  101. package/lib/module/StyleApplicator.js +144 -191
  102. package/lib/module/StyleApplicator.js.map +1 -1
  103. package/lib/module/WeatherLayerManager.js +1024 -1655
  104. package/lib/module/WeatherLayerManager.js.map +1 -1
  105. package/lib/module/aguaceroCoreDebugHooks.js +59 -130
  106. package/lib/module/aguaceroCoreDebugHooks.js.map +1 -1
  107. package/lib/module/aguaceroRnDebug.js +151 -291
  108. package/lib/module/aguaceroRnDebug.js.map +1 -1
  109. package/lib/module/cdnAuthenticatedFetch.js +97 -0
  110. package/lib/module/cdnAuthenticatedFetch.js.map +1 -0
  111. package/lib/module/dispatchViewManagerCommandCompat.js +52 -90
  112. package/lib/module/dispatchViewManagerCommandCompat.js.map +1 -1
  113. package/lib/module/gridCdnAuth.js +38 -50
  114. package/lib/module/gridCdnAuth.js.map +1 -1
  115. package/lib/module/index.js +9 -6
  116. package/lib/module/index.js.map +1 -1
  117. package/lib/module/nexrad/nexradAndroidController.js +865 -876
  118. package/lib/module/nexrad/nexradAndroidController.js.map +1 -1
  119. package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
  120. package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
  121. package/lib/module/nexrad/nexradDiag.js +31 -145
  122. package/lib/module/nexrad/nexradDiag.js.map +1 -1
  123. package/lib/module/nexrad/nexradLevel2Keys.js +245 -0
  124. package/lib/module/nexrad/nexradLevel2Keys.js.map +1 -0
  125. package/lib/module/nexrad/nexradLutBuild.js +64 -110
  126. package/lib/module/nexrad/nexradLutBuild.js.map +1 -1
  127. package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js +136 -163
  128. package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
  129. package/lib/module/nexrad/nexradSdkImports.js +4 -0
  130. package/lib/module/nexrad/nexradSdkImports.js.map +1 -0
  131. package/lib/module/nexrad/radarArchiveCore.bundled.js +2839 -4448
  132. package/lib/module/nexrad/radarArchiveCore.bundled.js.map +1 -1
  133. package/lib/module/nexrad/radarDecode.worker.bundled.js +445 -648
  134. package/lib/module/nexrad/radarDecode.worker.bundled.js.map +1 -1
  135. package/lib/module/nexrad/radarFrameGpuMatch.bundled.js +50 -66
  136. package/lib/module/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
  137. package/lib/module/nexradNativeCommandIds.js +18 -0
  138. package/lib/module/nexradNativeCommandIds.js.map +1 -0
  139. package/lib/module/nws/NwsAlertsOverlay.android.js +1 -1
  140. package/lib/module/nws/NwsAlertsOverlay.android.js.map +1 -1
  141. package/lib/module/nws/NwsAlertsOverlay.ios.js +1 -1
  142. package/lib/module/nws/NwsAlertsOverlay.ios.js.map +1 -1
  143. package/lib/module/nws/NwsAlertsOverlay.js +5 -5
  144. package/lib/module/nws/NwsAlertsOverlay.js.map +1 -1
  145. package/lib/module/nws/NwsAlertsOverlay.native.js +248 -373
  146. package/lib/module/nws/NwsAlertsOverlay.native.js.map +1 -1
  147. package/lib/module/nws/eventSourceRnPolyfill.js +92 -146
  148. package/lib/module/nws/eventSourceRnPolyfill.js.map +1 -1
  149. package/lib/module/nws/nwsAndroidConstants.js +2 -8
  150. package/lib/module/nws/nwsAndroidConstants.js.map +1 -1
  151. package/lib/module/satellite/satelliteAndroidController.js +125 -202
  152. package/lib/module/satellite/satelliteAndroidController.js.map +1 -1
  153. package/lib/module/satelliteBridgeDiag.js +3 -13
  154. package/lib/module/satelliteBridgeDiag.js.map +1 -1
  155. package/lib/module/satelliteRnDebug.js +148 -0
  156. package/lib/module/satelliteRnDebug.js.map +1 -0
  157. package/lib/typescript/AguaceroContext.d.ts +0 -4
  158. package/lib/typescript/AguaceroContext.d.ts.map +1 -1
  159. package/lib/typescript/GridRenderLayer.d.ts.map +1 -1
  160. package/lib/typescript/MapManager.d.ts +0 -12
  161. package/lib/typescript/MapManager.d.ts.map +1 -1
  162. package/lib/typescript/MapRegistry.d.ts +10 -12
  163. package/lib/typescript/MapRegistry.d.ts.map +1 -1
  164. package/lib/typescript/NexradRadarLayer.android.d.ts.map +1 -1
  165. package/lib/typescript/NexradRadarLayer.ios.d.ts.map +1 -1
  166. package/lib/typescript/NexradSitesMapLayer.d.ts +4 -10
  167. package/lib/typescript/NexradSitesMapLayer.d.ts.map +1 -1
  168. package/lib/typescript/SatelliteLayer.android.d.ts.map +1 -1
  169. package/lib/typescript/SatelliteLayer.ios.d.ts.map +1 -1
  170. package/lib/typescript/StyleApplicator.d.ts +1 -1
  171. package/lib/typescript/StyleApplicator.d.ts.map +1 -1
  172. package/lib/typescript/WeatherLayerManager.d.ts.map +1 -1
  173. package/lib/typescript/aguaceroCoreDebugHooks.d.ts +2 -9
  174. package/lib/typescript/aguaceroCoreDebugHooks.d.ts.map +1 -1
  175. package/lib/typescript/aguaceroRnDebug.d.ts +47 -66
  176. package/lib/typescript/aguaceroRnDebug.d.ts.map +1 -1
  177. package/lib/typescript/cdnAuthenticatedFetch.d.ts +10 -0
  178. package/lib/typescript/cdnAuthenticatedFetch.d.ts.map +1 -0
  179. package/lib/typescript/dispatchViewManagerCommandCompat.d.ts +1 -17
  180. package/lib/typescript/dispatchViewManagerCommandCompat.d.ts.map +1 -1
  181. package/lib/typescript/gridCdnAuth.d.ts +16 -21
  182. package/lib/typescript/gridCdnAuth.d.ts.map +1 -1
  183. package/lib/typescript/index.d.ts +2 -0
  184. package/lib/typescript/nexrad/nexradAndroidController.d.ts +39 -89
  185. package/lib/typescript/nexrad/nexradAndroidController.d.ts.map +1 -1
  186. package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts +2 -1
  187. package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts.map +1 -1
  188. package/lib/typescript/nexrad/nexradDiag.d.ts +13 -101
  189. package/lib/typescript/nexrad/nexradDiag.d.ts.map +1 -1
  190. package/lib/typescript/nexrad/nexradLevel2Keys.d.ts +36 -0
  191. package/lib/typescript/nexrad/nexradLevel2Keys.d.ts.map +1 -0
  192. package/lib/typescript/nexrad/nexradLutBuild.d.ts +3 -10
  193. package/lib/typescript/nexrad/nexradLutBuild.d.ts.map +1 -1
  194. package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts +4 -3
  195. package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts.map +1 -1
  196. package/lib/typescript/nexrad/nexradSdkImports.d.ts +2 -0
  197. package/lib/typescript/nexrad/nexradSdkImports.d.ts.map +1 -0
  198. package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts +12 -7
  199. package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts.map +1 -1
  200. package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts +20 -20
  201. package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts.map +1 -1
  202. package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts +4 -3
  203. package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts.map +1 -1
  204. package/lib/typescript/nexradNativeCommandIds.d.ts +2 -0
  205. package/lib/typescript/nexradNativeCommandIds.d.ts.map +1 -0
  206. package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts +6 -17
  207. package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts.map +1 -1
  208. package/lib/typescript/nws/eventSourceRnPolyfill.d.ts +0 -3
  209. package/lib/typescript/nws/eventSourceRnPolyfill.d.ts.map +1 -1
  210. package/lib/typescript/nws/nwsAndroidConstants.d.ts +0 -5
  211. package/lib/typescript/nws/nwsAndroidConstants.d.ts.map +1 -1
  212. package/lib/typescript/satellite/satelliteAndroidController.d.ts +9 -47
  213. package/lib/typescript/satellite/satelliteAndroidController.d.ts.map +1 -1
  214. package/lib/typescript/satelliteBridgeDiag.d.ts +1 -5
  215. package/lib/typescript/satelliteBridgeDiag.d.ts.map +1 -1
  216. package/lib/typescript/satelliteRnDebug.d.ts +75 -0
  217. package/lib/typescript/satelliteRnDebug.d.ts.map +1 -0
  218. package/package.json +75 -74
  219. package/src/AguaceroContext.js +1 -7
  220. package/src/GridRenderLayer.js +1 -128
  221. package/src/MapManager.js +1 -277
  222. package/src/MapRegistry.js +1 -56
  223. package/src/NexradRadarLayer.android.js +1 -121
  224. package/src/NexradRadarLayer.ios.js +1 -115
  225. package/src/NexradSitesMapLayer.js +1 -75
  226. package/src/SatelliteLayer.android.js +1 -63
  227. package/src/SatelliteLayer.ios.js +1 -70
  228. package/src/StyleApplicator.js +1 -241
  229. package/src/WeatherLayerManager.js +1 -2025
  230. package/src/aguaceroCoreDebugHooks.js +1 -142
  231. package/src/aguaceroRnDebug.js +1 -335
  232. package/src/cdnAuthenticatedFetch.js +1 -0
  233. package/src/dispatchViewManagerCommandCompat.js +1 -100
  234. package/src/gridCdnAuth.js +1 -56
  235. package/src/index.js +1 -19
  236. package/src/nexrad/nexradAndroidController.js +1 -1078
  237. package/src/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +1 -91
  238. package/src/nexrad/nexradDiag.js +1 -150
  239. package/src/nexrad/nexradLevel2Keys.js +1 -0
  240. package/src/nexrad/nexradLutBuild.js +1 -126
  241. package/src/nexrad/nexradMapboxFrameOpts.bundled.js +1 -245
  242. package/src/nexrad/nexradSdkImports.js +1 -0
  243. package/src/nexrad/radarArchiveCore.bundled.js +1 -7085
  244. package/src/nexrad/radarDecode.worker.bundled.js +1 -813
  245. package/src/nexrad/radarFrameGpuMatch.bundled.js +1 -79
  246. package/src/nexradNativeCommandIds.js +1 -0
  247. package/src/nws/NwsAlertsOverlay.android.js +1 -1
  248. package/src/nws/NwsAlertsOverlay.ios.js +1 -1
  249. package/src/nws/NwsAlertsOverlay.js +1 -7
  250. package/src/nws/NwsAlertsOverlay.native.js +1 -463
  251. package/src/nws/eventSourceRnPolyfill.js +7 -193
  252. package/src/nws/nwsAndroidConstants.js +1 -8
  253. package/src/satellite/satelliteAndroidController.js +1 -245
  254. package/src/satelliteBridgeDiag.js +1 -15
  255. package/src/satelliteRnDebug.js +1 -0
  256. package/lib/commonjs/nexrad/nexradNativeCommandIds.js +0 -51
  257. package/lib/commonjs/nexrad/nexradNativeCommandIds.js.map +0 -1
  258. package/lib/module/nexrad/nexradNativeCommandIds.js +0 -44
  259. package/lib/module/nexrad/nexradNativeCommandIds.js.map +0 -1
  260. package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts +0 -9
  261. package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts.map +0 -1
  262. package/src/nexrad/nexradNativeCommandIds.js +0 -44
  263. /package/lib/commonjs/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
  264. /package/lib/module/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
  265. /package/src/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
@@ -13,1811 +13,1180 @@ var _GridRenderLayer = require("./GridRenderLayer");
13
13
  var _NexradRadarLayer = _interopRequireDefault(require("./NexradRadarLayer"));
14
14
  var _SatelliteLayer = _interopRequireDefault(require("./SatelliteLayer"));
15
15
  var _NexradSitesMapLayer = require("./NexradSitesMapLayer");
16
- var _nexradAndroidController = require("./nexrad/nexradAndroidController");
17
16
  var _satelliteAndroidController = require("./satellite/satelliteAndroidController");
17
+ var _nexradAndroidController = require("./nexrad/nexradAndroidController");
18
+ var _cdnAuthenticatedFetch = require("./cdnAuthenticatedFetch");
19
+ var _radarArchiveCoreBundled = require("./nexrad/radarArchiveCore.bundled.js");
18
20
  var _NwsAlertsOverlay = _interopRequireDefault(require("./nws/NwsAlertsOverlay"));
19
21
  var _MapRegistry = require("./MapRegistry");
20
22
  var _satelliteBridgeDiag = require("./satelliteBridgeDiag");
21
23
  var _aguaceroRnDebug = require("./aguaceroRnDebug");
22
24
  var _aguaceroCoreDebugHooks = require("./aguaceroCoreDebugHooks");
23
25
  var _gridCdnAuth = require("./gridCdnAuth");
26
+ var _satelliteRnDebug = require("./satelliteRnDebug");
24
27
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
28
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
26
- // packages/react-native/src/WeatherLayerManager.js
27
-
28
- const NEXRAD_NATIVE = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
29
- const SATELLITE_NATIVE = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
30
- (0, _satelliteBridgeDiag.satBridgeWarn)('SDK fingerprint', {
29
+ const Q = _reactNative.Platform.OS === "android" || _reactNative.Platform.OS === "ios",
30
+ ie = _reactNative.Platform.OS === "android" || _reactNative.Platform.OS === "ios";
31
+ (0, _satelliteBridgeDiag.satBridgeWarn)("SDK fingerprint", {
31
32
  platform: _reactNative.Platform.OS,
32
- SATELLITE_NATIVE,
33
- note: 'If you never see sat-bridge logs, the app bundle is not loading this WeatherLayerManager build.'
33
+ SATELLITE_NATIVE: ie,
34
+ note: "If you never see sat-bridge logs, the app bundle is not loading this WeatherLayerManager build."
34
35
  });
35
-
36
- /**
37
- * Same filtering as {@link AguaceroCore#_getFilteredMrmsTimestampsForVariable} for older cores
38
- * where that helper (or {@code setMRMSDurationValue}) is missing from the prototype chain.
39
- */
40
- function getFilteredMrmsTimestampsCompat(core, variable) {
41
- const raw = core.mrmsStatus?.[variable];
42
- if (!raw || !raw.length) return [];
43
- const hours = (0, _javascriptSdk.parseTimelineDurationHours)(core.state.mrmsDurationValue);
44
- let list = [...raw].map(t => Number(t)).filter(t => !Number.isNaN(t)).sort((a, b) => a - b);
45
- if (hours > 0 && list.length > 0) {
46
- const latest = list[list.length - 1];
47
- const cutoff = latest - hours * 3600;
48
- list = list.filter(t => t >= cutoff);
36
+ function Kt(m, x) {
37
+ const g = m.mrmsStatus?.[x];
38
+ if (!g || !g.length) return [];
39
+ const I = (0, _javascriptSdk.parseTimelineDurationHours)(m.state.mrmsDurationValue);
40
+ let v = [...g].map(O => Number(O)).filter(O => !Number.isNaN(O)).sort((O, _) => O - _);
41
+ if (I > 0 && v.length > 0) {
42
+ const O = v[v.length - 1] - I * 3600;
43
+ v = v.filter(_ => _ >= O);
49
44
  }
50
- return list;
45
+ return v;
51
46
  }
52
-
53
- /**
54
- * Older npm installs may resolve an {@link AguaceroCore} without {@code setMRMSDurationValue} /
55
- * {@code setNexradDurationValue}; mirror those methods here using the same logic as the SDK.
56
- */
57
- async function applyMrmsDurationValue(core, value) {
58
- if (typeof core.setMRMSDurationValue === 'function') {
59
- await core.setMRMSDurationValue(value);
47
+ async function qt(m, x) {
48
+ if (typeof m.setMRMSDurationValue == "function") {
49
+ await m.setMRMSDurationValue(x);
60
50
  return;
61
51
  }
62
- const v = (0, _javascriptSdk.formatTimelineDurationValue)(value);
63
- await core.setState({
64
- mrmsDurationValue: v
65
- });
66
- if (!core.state.isMRMS || !core.state.variable) return;
67
- const filtered = typeof core._getFilteredMrmsTimestampsForVariable === 'function' ? core._getFilteredMrmsTimestampsForVariable(core.state.variable) : getFilteredMrmsTimestampsCompat(core, core.state.variable);
68
- if (!filtered || filtered.length === 0) return;
69
- const curN = core.state.mrmsTimestamp == null ? null : Number(core.state.mrmsTimestamp);
70
- if (curN == null || !filtered.includes(curN)) {
71
- await core.setState({
72
- mrmsTimestamp: filtered[filtered.length - 1]
73
- });
74
- }
75
- }
76
- async function applyNexradDurationValue(core, value) {
77
- if (typeof core.setNexradDurationValue === 'function') {
78
- await core.setNexradDurationValue(value);
79
- return;
80
- }
81
- const v = (0, _javascriptSdk.formatTimelineDurationValue)(value);
82
- await core.setState({
83
- nexradDurationValue: v
84
- });
85
- if (!core.state.isNexrad || !core.state.nexradSite) return;
86
- if (typeof core.refreshNexradTimes === 'function') {
87
- await core.refreshNexradTimes();
88
- }
89
- const nk = typeof core._nexradTimesCacheKey === 'function' ? core._nexradTimesCacheKey() : null;
90
- const raw = nk ? core.nexradTimesByStation?.[nk]?.unixTimes || [] : [];
91
- const filtered = typeof core._getFilteredNexradTimestampsForVariable === 'function' ? core._getFilteredNexradTimestampsForVariable(raw) : [...raw].map(t => Number(t)).filter(t => !Number.isNaN(t)).sort((a, b) => a - b);
92
- if (!filtered || filtered.length === 0) return;
93
- const curN = core.state.nexradTimestamp == null ? null : Number(core.state.nexradTimestamp);
94
- if (curN == null || !filtered.includes(curN)) {
95
- await core.setState({
96
- nexradTimestamp: filtered[filtered.length - 1]
97
- });
98
- }
52
+ const g = (0, _javascriptSdk.formatTimelineDurationValue)(x);
53
+ if (await m.setState({
54
+ mrmsDurationValue: g
55
+ }), !m.state.isMRMS || !m.state.variable) return;
56
+ const I = typeof m._getFilteredMrmsTimestampsForVariable == "function" ? m._getFilteredMrmsTimestampsForVariable(m.state.variable) : Kt(m, m.state.variable);
57
+ if (!I || I.length === 0) return;
58
+ const v = m.state.mrmsTimestamp == null ? null : Number(m.state.mrmsTimestamp);
59
+ (v == null || !I.includes(v)) && (await m.setState({
60
+ mrmsTimestamp: I[I.length - 1]
61
+ }));
99
62
  }
100
- function findLatestModelRun(modelsData, modelName) {
101
- const model = modelsData?.[modelName];
102
- if (!model) return null;
103
- const availableDates = Object.keys(model).sort((a, b) => b.localeCompare(a));
104
- for (const date of availableDates) {
105
- const runs = model[date];
106
- if (!runs) continue;
107
- const availableRuns = Object.keys(runs).sort((a, b) => b.localeCompare(a));
108
- if (availableRuns.length > 0) return {
109
- date: date,
110
- run: availableRuns[0]
63
+ function Gt(m, x) {
64
+ const g = m?.[x];
65
+ if (!g) return null;
66
+ const I = Object.keys(g).sort((v, O) => O.localeCompare(v));
67
+ for (const v of I) {
68
+ const O = g[v];
69
+ if (!O) continue;
70
+ const _ = Object.keys(O).sort((ee, B) => B.localeCompare(ee));
71
+ if (_.length > 0) return {
72
+ date: v,
73
+ run: _[0]
111
74
  };
112
75
  }
113
76
  return null;
114
77
  }
115
78
  const {
116
- WeatherFrameProcessorModule,
117
- InspectorModule
79
+ WeatherFrameProcessorModule: qe,
80
+ InspectorModule: kt
118
81
  } = _reactNative.NativeModules;
119
-
120
- /**
121
- * `state:change` payloads can briefly have {@code isNexrad} before {@code nexradSite} / {@code nexradTimestamp}
122
- * are populated; {@code core.state} is updated first. Merge so readouts match the active radar.
123
- *
124
- * @param {object | null} emitted
125
- * @param {object | null} coreState
126
- */
127
- function mergeNexradEmittedWithCore(emitted, coreState) {
128
- if (!emitted || !coreState) return null;
129
- return {
130
- ...emitted,
131
- nexradSite: coreState.nexradSite ?? emitted.nexradSite,
132
- nexradTimestamp: coreState.nexradTimestamp ?? emitted.nexradTimestamp,
133
- nexradProduct: coreState.nexradProduct ?? emitted.nexradProduct,
134
- nexradTilt: coreState.nexradTilt ?? emitted.nexradTilt,
135
- nexradDataSource: coreState.nexradDataSource ?? emitted.nexradDataSource,
136
- nexradStormRelative: coreState.nexradStormRelative ?? emitted.nexradStormRelative
137
- };
82
+ function ue(m) {
83
+ const x = Object.keys(m?.satelliteTimeToFileMap || {}).map(Number).filter(g => Number.isFinite(g)).sort((g, I) => g - I);
84
+ return x.length ? `${x.length}:${x[0]}:${x[x.length - 1]}` : "0";
138
85
  }
139
-
140
- /**
141
- * Compact timeline identity for deduping {@code state:change}: extending the NEXRAD/satellite window
142
- * often keeps the same selected unix — without this, {@link WeatherLayerManager} short-circuits and
143
- * never calls native {@code sync} / preload with the expanded frame list.
144
- */
145
- function nexradObsTimelineSig(state) {
146
- const arr = [...(state?.availableNexradTimestamps || [])].map(Number).filter(t => Number.isFinite(t)).sort((a, b) => a - b);
147
- if (!arr.length) return '0';
148
- return `${arr.length}:${arr[0]}:${arr[arr.length - 1]}`;
149
- }
150
- function satelliteObsTimelineSig(state) {
151
- const keys = Object.keys(state?.satelliteTimeToFileMap || {}).map(Number).filter(t => Number.isFinite(t)).sort((a, b) => a - b);
152
- if (!keys.length) return '0';
153
- return `${keys.length}:${keys[0]}:${keys[keys.length - 1]}`;
154
- }
155
-
156
- /** True when {@link WeatherLayerManager} `debug` / {@link configureAguaceroRnDebug}, or legacy `__AGUACERO_WX_GRID_DEBUG__`. */
157
- function wxGridDebugEnabled() {
158
- if ((0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)()) return true;
86
+ function pt() {
87
+ if ((0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)()) return !0;
159
88
  try {
160
- if (typeof __DEV__ !== 'undefined' && __DEV__) return true;
161
- return Boolean(typeof globalThis !== 'undefined' && globalThis.__AGUACERO_WX_GRID_DEBUG__);
89
+ return typeof __DEV__ < "u" && __DEV__ ? !0 : !!(typeof globalThis < "u" && globalThis.__AGUACERO_WX_GRID_DEBUG__);
162
90
  } catch {
163
- return false;
91
+ return !1;
164
92
  }
165
93
  }
166
- function wxGridVerbose(tag, detail) {
167
- if (!wxGridDebugEnabled()) return;
168
- if (detail !== undefined) {
169
- console.log(`[AguaceroWX][grid][${tag}]`, detail);
170
- } else {
171
- console.log(`[AguaceroWX][grid][${tag}]`);
172
- }
94
+ function z(m, x) {
95
+ pt() && (x !== void 0 ? console.log(`[AguaceroWX][grid][${m}]`, x) : console.log(`[AguaceroWX][grid][${m}]`));
173
96
  }
174
-
175
- /** Always logs (Metro / device logs) use for failures and unusual early exits. */
176
- function wxGridWarn(tag, detail) {
177
- if (detail !== undefined) {
178
- console.warn(`[AguaceroWX][grid][${tag}]`, detail);
179
- } else {
180
- console.warn(`[AguaceroWX][grid][${tag}]`);
181
- }
97
+ function Z(m, x) {
98
+ x !== void 0 ? console.warn(`[AguaceroWX][grid][${m}]`, x) : console.warn(`[AguaceroWX][grid][${m}]`);
182
99
  }
183
-
184
- /**
185
- * Native {@code processFrame} must mirror browser/AguaceroCore grid auth: encoded {@code apiKey}
186
- * in the query string and optional {@code Origin} / {@code Referer} (many CloudFront setups require them).
187
- *
188
- * @param {string} baseGridUrl
189
- * @param {string} resourcePath
190
- * @param {string} apiKey
191
- * @param {string | null | undefined} bundleId
192
- * @param {string | undefined} gridRequestSiteOrigin - prop or core origin (see {@link resolveGridRequestSiteOrigin})
193
- * @param {import('@aguacerowx/javascript-sdk').AguaceroCore | null | undefined} core
194
- */
195
- function buildGridFrameProcessOptions(baseGridUrl, resourcePath, apiKey, bundleId, gridRequestSiteOrigin, core) {
196
- const trimmedKey = typeof apiKey === 'string' ? apiKey.trim() : apiKey;
197
- const url = `${baseGridUrl}${resourcePath}?apiKey=${encodeURIComponent(trimmedKey || '')}`;
198
- const options = {
199
- url,
200
- apiKey: trimmedKey,
201
- bundleId
202
- };
203
- const origin = (0, _gridCdnAuth.resolveGridRequestSiteOrigin)(gridRequestSiteOrigin, core);
204
- if (origin) {
205
- options.gridRequestSiteOrigin = origin;
206
- }
207
- return options;
100
+ function Ze(m, x, g, I, v, O) {
101
+ const _ = `${m}${x}`;
102
+ return (0, _gridCdnAuth.buildNativeCloudFrontFetchOptions)({
103
+ url: _,
104
+ apiKey: g,
105
+ bundleId: I,
106
+ gridRequestSiteOrigin: v,
107
+ core: O
108
+ });
208
109
  }
209
-
210
- /**
211
- * A helper function to generate the raw RGBA byte buffer for the colormap texture.
212
- */
213
- const _generateColormapBytes = colormap => {
214
- const width = 256;
215
- const data = new Uint8Array(width * 4);
216
- const stops = colormap.reduce((acc, _, i) => i % 2 === 0 ? [...acc, {
217
- value: colormap[i],
218
- color: colormap[i + 1]
219
- }] : acc, []);
220
- if (stops.length === 0) return data;
221
- const minVal = stops[0].value;
222
- const maxVal = stops[stops.length - 1].value;
223
- const hexToRgb = hex => {
224
- const r = parseInt(hex.slice(1, 3), 16);
225
- const g = parseInt(hex.slice(3, 5), 16);
226
- const b = parseInt(hex.slice(5, 7), 16);
227
- return [r, g, b];
228
- };
229
- for (let i = 0; i < width; i++) {
230
- const val = minVal + i / (width - 1) * (maxVal - minVal);
231
- let lower = stops[0];
232
- let upper = stops[stops.length - 1];
233
- for (let j = 0; j < stops.length - 1; j++) {
234
- if (val >= stops[j].value && val <= stops[j + 1].value) {
235
- lower = stops[j];
236
- upper = stops[j + 1];
237
- break;
238
- }
110
+ const et = m => {
111
+ const x = new Uint8Array(1024),
112
+ g = m.reduce((_, ee, B) => B % 2 === 0 ? [..._, {
113
+ value: m[B],
114
+ color: m[B + 1]
115
+ }] : _, []);
116
+ if (g.length === 0) return x;
117
+ const I = g[0].value,
118
+ v = g[g.length - 1].value,
119
+ O = _ => {
120
+ const ee = parseInt(_.slice(1, 3), 16),
121
+ B = parseInt(_.slice(3, 5), 16),
122
+ fe = parseInt(_.slice(5, 7), 16);
123
+ return [ee, B, fe];
124
+ };
125
+ for (let _ = 0; _ < 256; _++) {
126
+ const ee = I + _ / 255 * (v - I);
127
+ let B = g[0],
128
+ fe = g[g.length - 1];
129
+ for (let J = 0; J < g.length - 1; J++) if (ee >= g[J].value && ee <= g[J + 1].value) {
130
+ B = g[J], fe = g[J + 1];
131
+ break;
239
132
  }
240
- const t = (val - lower.value) / (upper.value - lower.value || 1);
241
- const lowerRgb = hexToRgb(lower.color);
242
- const upperRgb = hexToRgb(upper.color);
243
- const rgb = lowerRgb.map((c, idx) => c * (1 - t) + upperRgb[idx] * t);
244
- const offset = i * 4;
245
- data[offset + 0] = Math.round(rgb[0]);
246
- data[offset + 1] = Math.round(rgb[1]);
247
- data[offset + 2] = Math.round(rgb[2]);
248
- data[offset + 3] = 255;
133
+ const Ae = (ee - B.value) / (fe.value - B.value || 1),
134
+ Pe = O(B.color),
135
+ xe = O(fe.color),
136
+ $e = Pe.map((J, Ge) => J * (1 - Ae) + xe[Ge] * Ae),
137
+ Te = _ * 4;
138
+ x[Te + 0] = Math.round($e[0]), x[Te + 1] = Math.round($e[1]), x[Te + 2] = Math.round($e[2]), x[Te + 3] = 255;
249
139
  }
250
- return data;
140
+ return x;
251
141
  };
252
- _javascriptSdk.AguaceroCore.prototype.setMapCenter = function (center) {
253
- this.emit('map:move', center);
142
+ _javascriptSdk.AguaceroCore.prototype.setMapCenter = function (m) {
143
+ this.emit("map:move", m);
254
144
  };
255
- const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
145
+ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _react.forwardRef)((m, x) => {
256
146
  const {
257
- inspectorEnabled,
258
- onInspect,
259
- apiKey,
260
- customColormaps,
261
- initialMode,
262
- initialVariable,
263
- autoRefresh,
264
- autoRefreshInterval,
265
- initialModel,
266
- belowID: belowIDFromProps,
267
- interpolateNexradColormap = true,
268
- nexradGateSmoothing = false,
269
- watchesWarnings: watchesWarningsProp,
270
- onNwsAlertClick,
271
- /** Same semantics as mapsgl / AguaceroCore: Origin + Referer for grid CDN (required by many CloudFront rules). */
272
- gridRequestSiteOrigin,
273
- /** When true, logs auth/HTTP diagnostics under `[AguaceroRN][debug]` (Metro / Logcat / Xcode). */
274
- debug = false,
275
- ...restProps
276
- } = props;
147
+ inspectorEnabled: g,
148
+ onInspect: I,
149
+ apiKey: v,
150
+ customColormaps: O,
151
+ initialMode: _,
152
+ initialVariable: ee,
153
+ initialSatelliteId: B,
154
+ initialSatelliteSector: fe,
155
+ initialSatelliteProduct: Ae,
156
+ autoRefresh: Pe,
157
+ autoRefreshInterval: xe,
158
+ initialModel: $e,
159
+ belowID: Te,
160
+ watchesWarnings: J,
161
+ onNwsAlertClick: Ge,
162
+ gridRequestSiteOrigin: te,
163
+ debug: Ce = !1,
164
+ ...Ht
165
+ } = m;
277
166
  (0, _react.useEffect)(() => {
278
167
  (0, _aguaceroRnDebug.configureAguaceroRnDebug)({
279
- enabled: Boolean(debug)
168
+ enabled: !!Ce
280
169
  });
281
- }, [debug]);
282
- const context = (0, _react.useContext)(_AguaceroContext.AguaceroContext);
283
-
284
- // Create the core here instead of getting it from context
285
- const core = (0, _react.useMemo)(() => new _javascriptSdk.AguaceroCore({
286
- apiKey: apiKey,
287
- customColormaps: customColormaps,
288
- gridRequestSiteOrigin: gridRequestSiteOrigin,
289
- layerOptions: {
290
- mode: initialMode,
291
- variable: initialVariable,
292
- model: initialModel
293
- },
294
- autoRefresh: false // <-- add this
295
- }), [apiKey, gridRequestSiteOrigin]);
170
+ }, [Ce]), (0, _react.useEffect)(() => {
171
+ if (Ce) return (0, _satelliteRnDebug.auditSatelliteIntegration)({
172
+ core: t,
173
+ satelliteLayerRef: Ne
174
+ }), (0, _satelliteRnDebug.installSatelliteDiagnosticListener)();
175
+ }, [Ce, t]);
176
+ const _e = (0, _react.useContext)(_AguaceroContext.AguaceroContext),
177
+ t = (0, _react.useMemo)(() => new _javascriptSdk.AguaceroCore({
178
+ apiKey: v,
179
+ customColormaps: O,
180
+ gridRequestSiteOrigin: te,
181
+ layerOptions: {
182
+ mode: _,
183
+ variable: ee,
184
+ model: $e,
185
+ ...(_ === "satellite" ? {
186
+ satelliteId: B,
187
+ sector: fe,
188
+ satelliteProduct: Ae ?? ee
189
+ } : {})
190
+ },
191
+ autoRefresh: !1
192
+ }), [v, te]);
296
193
  (0, _react.useEffect)(() => {
297
- if (!core) return;
298
- (0, _aguaceroCoreDebugHooks.installAguaceroCoreDebugHooks)(core, {
299
- gridRequestSiteOriginProp: gridRequestSiteOrigin ?? null,
300
- debugProp: Boolean(debug)
301
- });
302
- if ((0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)() && !apiKey) {
303
- (0, _aguaceroRnDebug.aguaceroDebugWarn)('WeatherLayerManager.missingApiKey', {
304
- hint: 'apiKey prop is empty — all CDN requests will fail or return 403'
305
- });
306
- }
307
- if ((0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)() && apiKey && !gridRequestSiteOrigin) {
308
- (0, _aguaceroRnDebug.aguaceroDebugWarn)('WeatherLayerManager.missingGridOrigin', {
309
- hint: 'gridRequestSiteOrigin is not set — CloudFront often returns 403 without Origin/Referer on React Native',
310
- snapshot: (0, _aguaceroRnDebug.getAguaceroAuthDiagnosticSnapshot)(core)
311
- });
312
- }
313
- }, [core, debug, gridRequestSiteOrigin, apiKey]);
314
- const [watchesWarningsOptions, setWatchesWarningsOptions] = (0, _react.useState)(() => ({
315
- alertInteractionEnabled: true,
316
- ...(watchesWarningsProp ?? {})
194
+ t && ((0, _aguaceroCoreDebugHooks.installAguaceroCoreDebugHooks)(t, {
195
+ gridRequestSiteOriginProp: te ?? null,
196
+ debugProp: !!Ce
197
+ }), (0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)() && !v && (0, _aguaceroRnDebug.aguaceroDebugWarn)("WeatherLayerManager.missingApiKey", {
198
+ hint: "apiKey prop is empty \u2014 all CDN requests will fail or return 403"
199
+ }), (0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)() && v && !te && (0, _aguaceroRnDebug.aguaceroDebugWarn)("WeatherLayerManager.missingGridOrigin", {
200
+ hint: "gridRequestSiteOrigin is not set \u2014 CloudFront often returns 403 without Origin/Referer on React Native",
201
+ snapshot: (0, _aguaceroRnDebug.getAguaceroAuthDiagnosticSnapshot)(t)
202
+ }));
203
+ }, [t, Ce, te, v]);
204
+ const [gt, tt] = (0, _react.useState)(() => ({
205
+ alertInteractionEnabled: !0,
206
+ ...(J ?? {})
317
207
  }));
318
208
  (0, _react.useEffect)(() => {
319
- setWatchesWarningsOptions(prev => ({
320
- ...prev,
321
- ...(watchesWarningsProp ?? {})
209
+ tt(r => ({
210
+ ...r,
211
+ ...(J ?? {})
322
212
  }));
323
- }, [watchesWarningsProp]);
324
- (0, _react.useEffect)(() => {
325
- setNexradSitesMapVisible(Boolean(core.state.isNexrad && core.state.nexradShowSitesPicker !== false));
326
- }, [core]);
327
- const gridLayerRef = (0, _react.useRef)(null);
328
- const nexradLayerRef = (0, _react.useRef)(null);
329
- const nexradControllerRef = (0, _react.useRef)(null);
330
- /** Latest {@code state:change} payload (includes {@code colormap}, NEXRAD maps) — required for readouts; {@code core.state} omits those. */
331
- const lastEmittedStateForInspectRef = (0, _react.useRef)(null);
332
- const satelliteLayerRef = (0, _react.useRef)(null);
333
- const satelliteControllerRef = (0, _react.useRef)(null);
334
- /** @type {React.MutableRefObject<{ cancel?: () => void } | null>} */
335
- const nexradPreloadInteractionRef = (0, _react.useRef)(null);
336
- const currentGridDataRef = (0, _react.useRef)(null);
337
- const autoRefreshIntervalId = (0, _react.useRef)(null);
338
- const ensureNexradController = (0, _react.useCallback)(() => {
339
- if (!NEXRAD_NATIVE) return null;
340
- if (!nexradControllerRef.current) {
341
- nexradControllerRef.current = new _nexradAndroidController.NexradAndroidController(core, nexradLayerRef, {
342
- interpolateNexradColormap,
343
- nexradGateSmoothing
344
- });
345
- }
346
- return nexradControllerRef.current;
347
- }, [core, interpolateNexradColormap, nexradGateSmoothing]);
348
-
349
- /** Synchronous NEXRAD readout (mapsgl-style); no await — avoids jank on map move. */
350
- const getNexradInspectPayloadAt = (0, _react.useCallback)((lng, lat) => {
351
- if (!NEXRAD_NATIVE || !core?.state?.isNexrad) return null;
352
- const ctl = ensureNexradController();
353
- if (!ctl) {
354
- return null;
355
- }
356
- const emitted = lastEmittedStateForInspectRef.current;
357
- if (!emitted) {
358
- return null;
359
- }
360
- const st = mergeNexradEmittedWithCore(emitted, core.state);
361
- if (!st?.nexradSite || st.nexradTimestamp == null) {
362
- return null;
363
- }
364
- return ctl.getInspectPayload(lng, lat, st) ?? null;
365
- }, [core, ensureNexradController]);
366
- const ensureSatelliteController = (0, _react.useCallback)(() => {
367
- if (!SATELLITE_NATIVE) return null;
368
- if (!satelliteControllerRef.current) {
369
- satelliteControllerRef.current = new _satelliteAndroidController.SatelliteAndroidController(core, satelliteLayerRef);
370
- }
371
- return satelliteControllerRef.current;
372
- }, [core]);
213
+ }, [J]), (0, _react.useEffect)(() => {
214
+ st(!!(t.state.isNexrad && t.state.nexradShowSitesPicker !== !1));
215
+ }, [t]);
216
+ const p = (0, _react.useRef)(null),
217
+ rt = (0, _react.useRef)(null),
218
+ X = (0, _react.useRef)(null),
219
+ Ne = (0, _react.useRef)(null),
220
+ re = (0, _react.useRef)(null),
221
+ De = (0, _react.useRef)(null),
222
+ me = (0, _react.useRef)(null),
223
+ at = (0, _react.useCallback)(() => ie ? (re.current || (re.current = new _satelliteAndroidController.SatelliteAndroidController(t, Ne)), re.current) : null, [t]),
224
+ nt = (0, _react.useCallback)(() => !Q || !t ? null : (X.current || (X.current = new _nexradAndroidController.NexradAndroidController(t, rt, {
225
+ interpolateNexradColormap: t.state?.shaderSmoothingEnabled !== !1
226
+ })), X.current), [t]),
227
+ ht = (0, _react.useCallback)(r => {
228
+ const {
229
+ colormap: a,
230
+ baseUnit: e
231
+ } = t._getColormapForVariable(r.variable),
232
+ o = t._getTargetUnit(e, r.units);
233
+ return {
234
+ ...r,
235
+ colormap: t._convertColormapUnits(a, e, o),
236
+ colormapBaseUnit: o
237
+ };
238
+ }, [t]),
239
+ Ie = (0, _react.useCallback)(r => {
240
+ if (!Q || !r?.isNexrad) return;
241
+ const a = nt();
242
+ a && (ae.current = !0, a.preloadAllAvailable(r), a.sync(r));
243
+ }, [nt]);
373
244
  (0, _react.useEffect)(() => {
374
- if (!SATELLITE_NATIVE) return;
375
- let gridCmdKeys = [];
376
- let satCmdKeys = [];
245
+ if (!Q || !t) return;
246
+ const r = (0, _gridCdnAuth.resolveGridRequestSiteOrigin)(te, t),
247
+ a = (0, _cdnAuthenticatedFetch.createNexradCloudFrontFetch)(() => ({
248
+ apiKey: t.apiKey,
249
+ bundleId: t.bundleId,
250
+ gridRequestSiteOrigin: r
251
+ }));
252
+ return (0, _radarArchiveCoreBundled.setNexradLevel2CloudFrontFetch)(a), () => (0, _radarArchiveCoreBundled.setNexradLevel2CloudFrontFetch)(null);
253
+ }, [t, te]), (0, _react.useEffect)(() => {
254
+ if (!ie) return;
255
+ let r = [],
256
+ a = [];
377
257
  try {
378
- gridCmdKeys = Object.keys(_reactNative.UIManager.getViewManagerConfig?.('GridRenderLayer')?.Commands ?? {});
258
+ r = Object.keys(_reactNative.UIManager.getViewManagerConfig?.("GridRenderLayer")?.Commands ?? {});
379
259
  } catch {
380
- gridCmdKeys = ['error'];
260
+ r = ["error"];
381
261
  }
382
262
  try {
383
- satCmdKeys = Object.keys(_reactNative.UIManager.getViewManagerConfig?.('SatelliteLayer')?.Commands ?? {});
263
+ a = Object.keys(_reactNative.UIManager.getViewManagerConfig?.("SatelliteLayer")?.Commands ?? {});
384
264
  } catch {
385
- satCmdKeys = ['error'];
265
+ a = ["error"];
386
266
  }
387
- (0, _satelliteBridgeDiag.satBridgeWarn)('mount UIManager command registration', {
388
- GridRenderLayerCommands: gridCmdKeys,
389
- SatelliteLayerCommands: satCmdKeys,
390
- satelliteMissing: satCmdKeys.length === 0
267
+ (0, _satelliteBridgeDiag.satBridgeWarn)("mount UIManager command registration", {
268
+ GridRenderLayerCommands: r,
269
+ SatelliteLayerCommands: a,
270
+ satelliteMissing: a.length === 0
391
271
  });
392
272
  }, []);
393
- (0, _react.useEffect)(() => {
394
- const ctl = nexradControllerRef.current;
395
- if (NEXRAD_NATIVE && ctl) {
396
- ctl.updateStyleOptions({
397
- interpolateNexradColormap,
398
- nexradGateSmoothing
399
- });
400
- if (core?.state?.isNexrad) {
401
- ctl.applyStyleFromState(core.state);
273
+ const W = (0, _react.useRef)(new Map()),
274
+ pe = (0, _react.useRef)(null),
275
+ ge = (0, _react.useRef)(null),
276
+ ke = (0, _react.useRef)([0, 1]),
277
+ ae = (0, _react.useRef)(!1),
278
+ ne = (0, _react.useRef)(!1),
279
+ Le = (0, _react.useRef)(0),
280
+ He = (0, _react.useRef)(null),
281
+ l = (0, _react.useRef)(null),
282
+ [Ve, Me] = (0, _react.useState)({
283
+ opacity: 1,
284
+ dataRange: [0, 1]
285
+ }),
286
+ [St, st] = (0, _react.useState)(!1);
287
+ (0, _react.useImperativeHandle)(x, () => ({
288
+ play: () => {
289
+ t.play();
290
+ },
291
+ pause: () => {
292
+ t.pause();
293
+ },
294
+ togglePlay: () => {
295
+ t.togglePlay();
296
+ },
297
+ step: r => {
298
+ t.step(r);
299
+ },
300
+ setPlaybackSpeed: r => {
301
+ r > 0 && (t.playbackSpeed = r, t.isPlaying && (t.pause(), t.play()));
302
+ },
303
+ setOpacity: r => t.setOpacity(r),
304
+ setUnits: r => t.setUnits(r),
305
+ switchMode: r => t.switchMode(r),
306
+ getAvailableVariables: r => t.getAvailableVariables(r),
307
+ getVariableDisplayName: r => t.getVariableDisplayName(r),
308
+ setRun: r => t.setState({
309
+ run: r.split(":")[1]
310
+ }),
311
+ setState: r => t.setState(r),
312
+ setMRMSTimestamp: r => t.setMRMSTimestamp(r),
313
+ setMRMSDurationValue: r => qt(t, r),
314
+ setNexradSite: r => t.setNexradSite(r),
315
+ setNexradProduct: r => t.setNexradProduct(r),
316
+ setNexradTilt: r => t.setNexradTilt(r),
317
+ setNexradStormRelative: r => t.setNexradStormRelative(r),
318
+ setNexradTimestamp: r => t.setNexradTimestamp(r),
319
+ setNexradDurationValue: r => typeof t.setNexradDurationValue == "function" ? t.setNexradDurationValue(r) : t.setState({
320
+ nexradDurationValue: (0, _javascriptSdk.formatTimelineDurationValue)(r)
321
+ }),
322
+ setSatelliteTimestamp: r => t.setSatelliteTimestamp(r),
323
+ setSatelliteDurationValue: r => t.setSatelliteDurationValue(r),
324
+ setSatelliteSelection: r => t.setSatelliteSelection(r),
325
+ setShaderSmoothing: async r => {
326
+ await t.setShaderSmoothing(r), p.current && p.current.setSmoothing(r);
327
+ },
328
+ setSmoothing: r => {
329
+ p.current && p.current.setSmoothing(r);
330
+ },
331
+ setAutoRefresh: (r, a) => {
332
+ if (me.current && (clearInterval(me.current), me.current = null), r) {
333
+ const e = (a || xe || 30) * 1e3;
334
+ Se(), me.current = setInterval(Se, e);
402
335
  }
336
+ },
337
+ refreshData: () => {
338
+ Se();
339
+ },
340
+ configureWatchesWarnings: r => {
341
+ tt(a => ({
342
+ ...a,
343
+ ...r
344
+ }));
403
345
  }
404
- }, [interpolateNexradColormap, nexradGateSmoothing, core]);
405
-
406
- // Cache for preloaded grid data - stores the processed data ready for GPU upload
407
- const preloadedDataCache = (0, _react.useRef)(new Map());
408
-
409
- // Store geometry and colormap that don't change with forecast hour
410
- const cachedGeometry = (0, _react.useRef)(null);
411
- const cachedColormap = (0, _react.useRef)(null);
412
- const cachedDataRange = (0, _react.useRef)([0, 1]);
413
-
414
- // Track if we've done the initial load
415
- const hasInitialLoad = (0, _react.useRef)(false);
416
- const hasPreloadedRef = (0, _react.useRef)(false);
417
- /** Bumped on {@code cancelAllFrames} / full reload so stale {@code processFrame} results are ignored. */
418
- const preloadGenerationRef = (0, _react.useRef)(0);
419
-
420
- // Track the last state we processed to avoid redundant updates
421
- const lastProcessedState = (0, _react.useRef)(null);
422
- const previousStateRef = (0, _react.useRef)(null);
423
- const [renderProps, setRenderProps] = (0, _react.useState)({
424
- opacity: 1,
425
- dataRange: [0, 1]
426
- });
427
- /** Drives {@link NexradSitesMapLayer}; must re-render when core NEXRAD / picker flags change. */
428
- const [nexradSitesMapVisible, setNexradSitesMapVisible] = (0, _react.useState)(false);
429
- (0, _react.useImperativeHandle)(ref, () => {
430
- const setAutoRefresh = (enabled, intervalSeconds) => {
431
- if (autoRefreshIntervalId.current) {
432
- clearInterval(autoRefreshIntervalId.current);
433
- autoRefreshIntervalId.current = null;
434
- }
435
- if (enabled) {
436
- const effectiveInterval = (intervalSeconds || autoRefreshInterval || 30) * 1000;
437
- // Run once immediately, then start the interval
438
- _checkForUpdates();
439
- autoRefreshIntervalId.current = setInterval(_checkForUpdates, effectiveInterval);
440
- }
441
- };
442
- return {
443
- play: () => {
444
- core.play();
445
- },
446
- pause: () => {
447
- core.pause();
448
- },
449
- togglePlay: () => {
450
- core.togglePlay();
451
- },
452
- step: direction => {
453
- core.step(direction);
454
- },
455
- setPlaybackSpeed: speed => {
456
- if (speed > 0) {
457
- core.playbackSpeed = speed;
458
- if (core.isPlaying) {
459
- core.pause();
460
- core.play();
461
- }
462
- }
463
- },
464
- setOpacity: opacity => core.setOpacity(opacity),
465
- setUnits: units => core.setUnits(units),
466
- switchMode: options => core.switchMode(options),
467
- getAvailableVariables: model => core.getAvailableVariables(model),
468
- getVariableDisplayName: code => core.getVariableDisplayName(code),
469
- setRun: runString => core.setState({
470
- run: runString.split(':')[1]
471
- }),
472
- setState: newState => core.setState(newState),
473
- setMRMSTimestamp: timestamp => core.setMRMSTimestamp(timestamp),
474
- setMRMSDurationValue: value => applyMrmsDurationValue(core, value),
475
- setNexradSite: siteId => core.setNexradSite(siteId),
476
- setNexradProduct: product => core.setNexradProduct(product),
477
- setNexradTilt: tilt => core.setNexradTilt(tilt),
478
- setNexradStormRelative: enabled => core.setNexradStormRelative(enabled),
479
- setNexradTimestamp: ts => core.setNexradTimestamp(ts),
480
- setNexradDurationValue: value => applyNexradDurationValue(core, value),
481
- setSatelliteTimestamp: timestamp => core.setSatelliteTimestamp(timestamp),
482
- setSatelliteDurationValue: value => core.setSatelliteDurationValue(value),
483
- setSatelliteSelection: opts => core.setSatelliteSelection(opts),
484
- setShaderSmoothing: async enabled => {
485
- await core.setShaderSmoothing(enabled);
486
- if (gridLayerRef.current) {
487
- gridLayerRef.current.setSmoothing(enabled);
488
- }
489
- },
490
- setSmoothing: enabled => {
491
- if (gridLayerRef.current) {
492
- gridLayerRef.current.setSmoothing(enabled);
493
- }
494
- },
495
- setAutoRefresh,
496
- refreshData: () => {
497
- _checkForUpdates();
498
- },
499
- /**
500
- * NWS watches/warnings (native map, iOS + Android): same options as mapsgl {@link WeatherLayerManager#configureWatchesWarnings}.
501
- * @param {object} partial
502
- */
503
- configureWatchesWarnings: partial => {
504
- setWatchesWarningsOptions(prev => ({
505
- ...prev,
506
- ...partial
507
- }));
508
- }
509
- };
510
- }, [core, autoRefreshInterval, _checkForUpdates]);
511
- const preloadAllFramesToDisk = async state => {
512
- if (state.isNexrad || state.isSatellite) {
513
- hasPreloadedRef.current = false;
514
- wxGridVerbose('preloadSkip', {
515
- reason: 'nexrad_or_satellite'
346
+ }), [t, xe, Se]);
347
+ const it = async r => {
348
+ if (r.isNexrad || r.isSatellite) {
349
+ ne.current = !1, z("preloadSkip", {
350
+ reason: "nexrad_or_satellite"
516
351
  });
517
352
  return;
518
353
  }
519
- if (hasPreloadedRef.current) {
520
- wxGridVerbose('preloadSkip', {
521
- reason: 'hasPreloadedRef_gate',
522
- isMRMS: state.isMRMS,
523
- variable: state.variable
354
+ if (ne.current) {
355
+ z("preloadSkip", {
356
+ reason: "hasPreloadedRef_gate",
357
+ isMRMS: r.isMRMS,
358
+ variable: r.variable
524
359
  });
525
360
  return;
526
361
  }
527
362
  const {
528
- isMRMS,
529
- model,
530
- date,
531
- run,
532
- variable,
533
- units,
534
- availableHours,
535
- availableTimestamps,
536
- forecastHour,
537
- mrmsTimestamp
538
- } = state;
539
-
540
- // CRITICAL: Don't start preloading if we don't have a valid current frame
541
- if (isMRMS && (mrmsTimestamp == null || !availableTimestamps || availableTimestamps.length === 0)) {
542
- hasPreloadedRef.current = false;
543
- wxGridWarn('preloadAbort', {
544
- reason: 'mrms_missing_frame_or_timestamps',
545
- mrmsTimestamp,
546
- timestampCount: availableTimestamps?.length ?? 0,
547
- variable
363
+ isMRMS: a,
364
+ model: e,
365
+ date: o,
366
+ run: F,
367
+ variable: s,
368
+ units: w,
369
+ availableHours: N,
370
+ availableTimestamps: c,
371
+ forecastHour: i,
372
+ mrmsTimestamp: u
373
+ } = r;
374
+ if (a && (u == null || !c || c.length === 0)) {
375
+ ne.current = !1, Z("preloadAbort", {
376
+ reason: "mrms_missing_frame_or_timestamps",
377
+ mrmsTimestamp: u,
378
+ timestampCount: c?.length ?? 0,
379
+ variable: s
548
380
  });
549
381
  return;
550
382
  }
551
- if (!isMRMS && (forecastHour == null || !availableHours || availableHours.length === 0)) {
552
- hasPreloadedRef.current = false;
553
- wxGridWarn('preloadAbort', {
554
- reason: 'model_missing_hour_or_hours',
555
- forecastHour,
556
- hourCount: availableHours?.length ?? 0,
557
- model,
558
- variable
383
+ if (!a && (i == null || !N || N.length === 0)) {
384
+ ne.current = !1, Z("preloadAbort", {
385
+ reason: "model_missing_hour_or_hours",
386
+ forecastHour: i,
387
+ hourCount: N?.length ?? 0,
388
+ model: e,
389
+ variable: s
559
390
  });
560
391
  return;
561
392
  }
562
-
563
- // Only mark as "has preloaded" after validation passes
564
- hasPreloadedRef.current = true;
565
- const generation = preloadGenerationRef.current;
566
- const isStaleGeneration = () => generation !== preloadGenerationRef.current;
567
- wxGridVerbose('preloadStart', {
568
- isMRMS,
569
- model,
570
- date,
571
- run,
572
- variable,
573
- mrmsTimestamp: isMRMS ? mrmsTimestamp : undefined,
574
- forecastHour: !isMRMS ? forecastHour : undefined,
575
- baseGridUrl: core?.baseGridUrl,
576
- hasApiKey: Boolean(core?.apiKey),
577
- bundleId: core?.bundleId ?? null,
578
- gridRequestSiteOrigin: gridRequestSiteOrigin || null
393
+ ne.current = !0;
394
+ const A = Le.current,
395
+ y = () => A !== Le.current;
396
+ z("preloadStart", {
397
+ isMRMS: a,
398
+ model: e,
399
+ date: o,
400
+ run: F,
401
+ variable: s,
402
+ mrmsTimestamp: a ? u : void 0,
403
+ forecastHour: a ? void 0 : i,
404
+ baseGridUrl: t?.baseGridUrl,
405
+ hasApiKey: !!t?.apiKey,
406
+ bundleId: t?.bundleId ?? null,
407
+ gridRequestSiteOrigin: te || null
579
408
  });
580
-
581
- // Fix the current forecast hour if it's invalid for this variable/model combo
582
- let effectiveForecastHour = forecastHour;
583
- if (!isMRMS && variable === 'ptypeRefl' && model === 'hrrr' && forecastHour === 0) {
584
- const validHours = availableHours.filter(hour => hour !== 0);
585
- effectiveForecastHour = validHours.length > 0 ? validHours[0] : 0;
409
+ let M = i;
410
+ if (!a && s === "ptypeRefl" && e === "hrrr" && i === 0) {
411
+ const d = N.filter(G => G !== 0);
412
+ M = d.length > 0 ? d[0] : 0;
586
413
  }
587
- if (!cachedGeometry.current || !cachedColormap.current) {
588
- const gridModel = isMRMS ? 'mrms' : model;
589
- const {
590
- corners,
591
- gridDef
592
- } = core._getGridCornersAndDef(gridModel);
593
- gridLayerRef.current.updateGeometry(corners, gridDef);
594
- cachedGeometry.current = {
595
- model: gridModel,
596
- variable
597
- };
598
- wxGridVerbose('geometryColormapInit', {
599
- gridModel,
600
- variable,
601
- nx: gridDef?.grid_params?.nx,
602
- ny: gridDef?.grid_params?.ny
414
+ if (!pe.current || !ge.current) {
415
+ const d = a ? "mrms" : e,
416
+ {
417
+ corners: G,
418
+ gridDef: n
419
+ } = t._getGridCornersAndDef(d);
420
+ p.current.updateGeometry(G, n), pe.current = {
421
+ model: d,
422
+ variable: s
423
+ }, z("geometryColormapInit", {
424
+ gridModel: d,
425
+ variable: s,
426
+ nx: n?.grid_params?.nx,
427
+ ny: n?.grid_params?.ny
603
428
  });
604
429
  const {
605
- colormap,
606
- baseUnit
607
- } = core._getColormapForVariable(variable);
608
- const toUnit = core._getTargetUnit(baseUnit, units);
609
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
610
- let dataRange;
611
- if (variable === 'ptypeRefl' || variable === 'ptypeRate') {
612
- dataRange = isMRMS ? [5, 380] : [5, 380];
613
- } else {
614
- dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
615
- }
616
- const colormapBytes = _generateColormapBytes(finalColormap);
617
- const colormapAsBase64 = (0, _base64Js.fromByteArray)(colormapBytes);
618
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
619
- cachedColormap.current = {
620
- key: `${variable}-${units}`
621
- };
622
- cachedDataRange.current = dataRange;
623
- setRenderProps({
624
- opacity: state.opacity,
625
- dataRange: dataRange
626
- });
627
- hasInitialLoad.current = true;
430
+ colormap: R,
431
+ baseUnit: h
432
+ } = t._getColormapForVariable(s),
433
+ k = t._getTargetUnit(h, w),
434
+ P = t._convertColormapUnits(R, h, k);
435
+ let f;
436
+ s === "ptypeRefl" || s === "ptypeRate" ? f = a ? [5, 380] : [5, 380] : f = [P[0], P[P.length - 2]];
437
+ const C = et(P),
438
+ b = (0, _base64Js.fromByteArray)(C);
439
+ p.current.updateColormapTexture(b), ge.current = {
440
+ key: `${s}-${w}`
441
+ }, ke.current = f, Me({
442
+ opacity: r.opacity,
443
+ dataRange: f
444
+ }), ae.current = !0;
628
445
  }
629
-
630
- // Apply the same filtering logic as in AguaceroCore._emitStateChange
631
- let filteredHours = availableHours;
632
- if (!isMRMS && variable === 'ptypeRefl' && model === 'hrrr' && availableHours && availableHours.length > 0) {
633
- filteredHours = availableHours.filter(hour => hour !== 0);
634
- }
635
- const allFrames = isMRMS ? availableTimestamps : filteredHours;
636
- if (!allFrames || allFrames.length === 0) {
637
- hasPreloadedRef.current = false;
638
- wxGridWarn('preloadAbort', {
639
- reason: 'no_frames_after_filter',
640
- isMRMS,
641
- variable
446
+ let U = N;
447
+ !a && s === "ptypeRefl" && e === "hrrr" && N && N.length > 0 && (U = N.filter(d => d !== 0));
448
+ const E = a ? c : U;
449
+ if (!E || E.length === 0) {
450
+ ne.current = !1, Z("preloadAbort", {
451
+ reason: "no_frames_after_filter",
452
+ isMRMS: a,
453
+ variable: s
642
454
  });
643
455
  return;
644
456
  }
645
- const currentFrame = isMRMS ? mrmsTimestamp : effectiveForecastHour;
646
-
647
- // Double-check currentFrame is valid
648
- if (currentFrame == null) {
649
- hasPreloadedRef.current = false;
650
- wxGridWarn('preloadAbort', {
651
- reason: 'currentFrame_null',
652
- isMRMS,
653
- variable
457
+ const K = a ? u : M;
458
+ if (K == null) {
459
+ ne.current = !1, Z("preloadAbort", {
460
+ reason: "currentFrame_null",
461
+ isMRMS: a,
462
+ variable: s
654
463
  });
655
464
  return;
656
465
  }
657
-
658
- // Reverse the frame order to load from last to first
659
- const reversedFrames = [...allFrames].reverse();
660
- const framesToPreload = reversedFrames.filter(frame => frame !== currentFrame);
661
- const {
662
- corners,
663
- gridDef
664
- } = core._getGridCornersAndDef(isMRMS ? 'mrms' : model);
665
- const {
666
- nx,
667
- ny
668
- } = gridDef.grid_params;
669
-
670
- // Load the current frame FIRST and WAIT for it before continuing
671
- const currentCacheKey = isMRMS ? `mrms-${currentFrame}-${variable}` : `${model}-${date}-${run}-${currentFrame}-${variable}`;
672
- if (!preloadedDataCache.current.has(currentCacheKey)) {
673
- let resourcePath;
674
- if (isMRMS) {
675
- const frameDate = new Date(currentFrame * 1000);
676
- const y = frameDate.getUTCFullYear();
677
- const m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0');
678
- const d = frameDate.getUTCDate().toString().padStart(2, '0');
679
- resourcePath = `/grids/mrms/${y}${m}${d}/${currentFrame}/0/${variable}/0`;
680
- } else {
681
- resourcePath = `/grids/${model}/${date}/${run}/${currentFrame}/${variable}/0`;
682
- }
683
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
684
- (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
685
- phase: 'preloadCurrent',
686
- currentCacheKey
466
+ const Y = [...E].reverse().filter(d => d !== K),
467
+ {
468
+ corners: D,
469
+ gridDef: q
470
+ } = t._getGridCornersAndDef(a ? "mrms" : e),
471
+ {
472
+ nx: de,
473
+ ny: ye
474
+ } = q.grid_params,
475
+ $ = a ? `mrms-${K}-${s}` : `${e}-${o}-${F}-${K}-${s}`;
476
+ if (!W.current.has($)) {
477
+ let d;
478
+ if (a) {
479
+ const n = new Date(K * 1e3),
480
+ R = n.getUTCFullYear(),
481
+ h = (n.getUTCMonth() + 1).toString().padStart(2, "0"),
482
+ k = n.getUTCDate().toString().padStart(2, "0");
483
+ d = `/grids/mrms/${R}${h}${k}/${K}/0/${s}/0`;
484
+ } else d = `/grids/${e}/${o}/${F}/${K}/${s}/0`;
485
+ const G = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(Ze(t.baseGridUrl, d, t.apiKey, t.bundleId, te, t), t);
486
+ (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(t, G, {
487
+ phase: "preloadCurrent",
488
+ currentCacheKey: $
687
489
  });
688
490
  try {
689
- wxGridVerbose('processFrameRequest', {
690
- currentCacheKey,
691
- resourcePath,
692
- frame: currentFrame
491
+ z("processFrameRequest", {
492
+ currentCacheKey: $,
493
+ resourcePath: d,
494
+ frame: K
693
495
  });
694
- const result = await WeatherFrameProcessorModule.processFrame(options);
695
- if (isStaleGeneration()) {
696
- wxGridVerbose('preloadCurrentFrameStale', {
697
- currentCacheKey,
698
- generation
496
+ const n = await qe.processFrame(G);
497
+ if (y()) {
498
+ z("preloadCurrentFrameStale", {
499
+ currentCacheKey: $,
500
+ generation: A
699
501
  });
700
502
  return;
701
503
  }
702
- if (!result || !result.filePath) {
703
- hasPreloadedRef.current = false;
704
- wxGridWarn('preloadAbort', {
705
- reason: 'processFrame_empty_result',
706
- currentCacheKey,
707
- resultKeys: result ? Object.keys(result) : []
504
+ if (!n || !n.filePath) {
505
+ ne.current = !1, Z("preloadAbort", {
506
+ reason: "processFrame_empty_result",
507
+ currentCacheKey: $,
508
+ resultKeys: n ? Object.keys(n) : []
708
509
  });
709
510
  return;
710
511
  }
711
512
  const {
712
- baseUnit
713
- } = core._getColormapForVariable(variable);
714
- const toUnit = core._getTargetUnit(baseUnit, units);
715
- const fieldInfo = _javascriptSdk.DICTIONARIES?.fld?.[variable] || {};
716
- const serverDataUnit = fieldInfo.defaultUnit || baseUnit;
717
- let dataScale = result.scale;
718
- let dataOffset = result.offset;
719
- let convertedScale = dataScale;
720
- let convertedOffset = dataOffset;
721
- if (serverDataUnit !== baseUnit) {
722
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(serverDataUnit, baseUnit);
723
- if (conversionFunc) {
724
- if (result.scaleType === 'sqrt') {
725
- const physicalAtOffset = dataOffset * dataOffset;
726
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
727
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
728
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
729
- convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
730
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
731
- convertedScale = newOffsetPlusScale - convertedOffset;
732
- } else {
733
- convertedOffset = conversionFunc(dataOffset);
734
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
735
- convertedScale = convertedOffsetPlusScale - convertedOffset;
736
- }
737
- dataScale = convertedScale;
738
- dataOffset = convertedOffset;
513
+ baseUnit: R
514
+ } = t._getColormapForVariable(s),
515
+ h = t._getTargetUnit(R, w),
516
+ k = (_javascriptSdk.DICTIONARIES?.fld?.[s] || {}).defaultUnit || R;
517
+ let P = n.scale,
518
+ f = n.offset,
519
+ C = P,
520
+ b = f;
521
+ if (k !== R) {
522
+ const T = (0, _javascriptSdk.getUnitConversionFunction)(k, R);
523
+ if (T) {
524
+ if (n.scaleType === "sqrt") {
525
+ const L = f * f,
526
+ H = (f + P) * (f + P),
527
+ oe = T(L),
528
+ ce = T(H);
529
+ b = Math.sqrt(Math.abs(oe)) * Math.sign(oe), C = Math.sqrt(Math.abs(ce)) * Math.sign(ce) - b;
530
+ } else b = T(f), C = T(f + P) - b;
531
+ P = C, f = b;
739
532
  }
740
533
  }
741
- if (baseUnit !== toUnit) {
742
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(baseUnit, toUnit);
743
- if (conversionFunc) {
744
- if (result.scaleType === 'sqrt') {
745
- const physicalAtOffset = dataOffset * dataOffset;
746
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
747
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
748
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
749
- convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
750
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
751
- convertedScale = newOffsetPlusScale - convertedOffset;
752
- } else {
753
- convertedOffset = conversionFunc(dataOffset);
754
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
755
- convertedScale = convertedOffsetPlusScale - convertedOffset;
756
- }
757
- }
534
+ if (R !== h) {
535
+ const T = (0, _javascriptSdk.getUnitConversionFunction)(R, h);
536
+ if (T) if (n.scaleType === "sqrt") {
537
+ const L = f * f,
538
+ H = (f + P) * (f + P),
539
+ oe = T(L),
540
+ ce = T(H);
541
+ b = Math.sqrt(Math.abs(oe)) * Math.sign(oe), C = Math.sqrt(Math.abs(ce)) * Math.sign(ce) - b;
542
+ } else b = T(f), C = T(f + P) - b;
758
543
  }
759
- const frameData = {
760
- filePath: result.filePath,
761
- nx,
762
- ny,
763
- scale: convertedScale,
764
- offset: convertedOffset,
765
- missing: result.missing,
766
- corners,
767
- gridDef,
768
- scaleType: result.scaleType,
769
- originalScale: result.scale,
770
- originalOffset: result.offset
771
- };
772
- preloadedDataCache.current.set(currentCacheKey, frameData);
773
-
774
- // Update the GPU with the current frame
775
- gridLayerRef.current.updateDataTextureFromFile(frameData.filePath, frameData.nx, frameData.ny, frameData.scale, frameData.offset, frameData.missing, frameData.scaleType);
776
- currentGridDataRef.current = {
777
- nx: frameData.nx,
778
- ny: frameData.ny,
779
- scale: frameData.scale,
780
- offset: frameData.offset,
781
- missing: frameData.missing,
782
- gridDef: frameData.gridDef,
783
- variable: variable,
784
- units: units,
785
- scaleType: frameData.scaleType
544
+ const S = {
545
+ filePath: n.filePath,
546
+ nx: de,
547
+ ny: ye,
548
+ scale: C,
549
+ offset: b,
550
+ missing: n.missing,
551
+ corners: D,
552
+ gridDef: q,
553
+ scaleType: n.scaleType,
554
+ originalScale: n.scale,
555
+ originalOffset: n.offset
786
556
  };
787
- wxGridVerbose('preloadCurrentFrameOk', {
788
- currentCacheKey,
789
- nx: frameData.nx,
790
- ny: frameData.ny,
791
- scale: frameData.scale,
792
- offset: frameData.offset,
793
- filePathSuffix: String(frameData.filePath).split('/').pop()
557
+ W.current.set($, S), p.current.updateDataTextureFromFile(S.filePath, S.nx, S.ny, S.scale, S.offset, S.missing, S.scaleType), De.current = {
558
+ nx: S.nx,
559
+ ny: S.ny,
560
+ scale: S.scale,
561
+ offset: S.offset,
562
+ missing: S.missing,
563
+ gridDef: S.gridDef,
564
+ variable: s,
565
+ units: w,
566
+ scaleType: S.scaleType
567
+ }, z("preloadCurrentFrameOk", {
568
+ currentCacheKey: $,
569
+ nx: S.nx,
570
+ ny: S.ny,
571
+ scale: S.scale,
572
+ offset: S.offset,
573
+ filePathSuffix: String(S.filePath).split("/").pop()
794
574
  });
795
- } catch (e) {
796
- const cancelled = e && (e.code === 'E_CANCELLED' || e?.userInfo?.code === 'E_CANCELLED' || typeof e?.message === 'string' && e.message.includes('superseded'));
797
- if (!cancelled) {
798
- hasPreloadedRef.current = false;
799
- const errDetail = {
800
- currentCacheKey,
801
- code: e?.code,
802
- message: e?.message,
803
- userInfo: e?.userInfo
575
+ } catch (n) {
576
+ if (n && (n.code === "E_CANCELLED" || n?.userInfo?.code === "E_CANCELLED" || typeof n?.message == "string" && n.message.includes("superseded"))) z("preloadProcessFrameCancelled", {
577
+ currentCacheKey: $
578
+ });else {
579
+ ne.current = !1;
580
+ const R = {
581
+ currentCacheKey: $,
582
+ code: n?.code,
583
+ message: n?.message,
584
+ userInfo: n?.userInfo
804
585
  };
805
- wxGridWarn('preloadProcessFrameError', errDetail);
806
- if ((0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)()) {
807
- (0, _aguaceroRnDebug.aguaceroDebugWarn)('preloadProcessFrameError', {
808
- ...errDetail,
809
- auth: (0, _aguaceroRnDebug.getAguaceroAuthDiagnosticSnapshot)(core),
810
- is403: e?.code === 'HTTP_ERROR' && typeof e?.message === 'string' && e.message.includes('403')
811
- });
812
- }
813
- } else {
814
- wxGridVerbose('preloadProcessFrameCancelled', {
815
- currentCacheKey
586
+ Z("preloadProcessFrameError", R), (0, _aguaceroRnDebug.isAguaceroRnDebugEnabled)() && (0, _aguaceroRnDebug.aguaceroDebugWarn)("preloadProcessFrameError", {
587
+ ...R,
588
+ auth: (0, _aguaceroRnDebug.getAguaceroAuthDiagnosticSnapshot)(t),
589
+ is403: n?.code === "HTTP_ERROR" && typeof n?.message == "string" && n.message.includes("403")
816
590
  });
817
591
  }
818
592
  }
819
593
  }
820
-
821
- // NOW preload the rest of the frames asynchronously
822
- framesToPreload.forEach(frame => {
823
- const cacheKey = isMRMS ? `mrms-${frame}-${variable}` : `${model}-${date}-${run}-${frame}-${variable}`;
824
- if (preloadedDataCache.current.has(cacheKey)) {
825
- return;
826
- }
827
- let resourcePath;
828
- if (isMRMS) {
829
- const frameDate = new Date(frame * 1000);
830
- const y = frameDate.getUTCFullYear();
831
- const m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0');
832
- const d = frameDate.getUTCDate().toString().padStart(2, '0');
833
- resourcePath = `/grids/mrms/${y}${m}${d}/${frame}/0/${variable}/0`;
834
- } else {
835
- resourcePath = `/grids/${model}/${date}/${run}/${frame}/${variable}/0`;
836
- }
837
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
838
- (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
839
- phase: 'preloadBackground',
840
- cacheKey
841
- });
842
- WeatherFrameProcessorModule.processFrame(options).then(result => {
843
- if (isStaleGeneration()) {
844
- return;
845
- }
846
- if (!result || !result.filePath) {
847
- return;
848
- }
849
-
850
- // ADD: Same two-step conversion as the current frame
594
+ Y.forEach(d => {
595
+ const G = a ? `mrms-${d}-${s}` : `${e}-${o}-${F}-${d}-${s}`;
596
+ if (W.current.has(G)) return;
597
+ let n;
598
+ if (a) {
599
+ const h = new Date(d * 1e3),
600
+ k = h.getUTCFullYear(),
601
+ P = (h.getUTCMonth() + 1).toString().padStart(2, "0"),
602
+ f = h.getUTCDate().toString().padStart(2, "0");
603
+ n = `/grids/mrms/${k}${P}${f}/${d}/0/${s}/0`;
604
+ } else n = `/grids/${e}/${o}/${F}/${d}/${s}/0`;
605
+ const R = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(Ze(t.baseGridUrl, n, t.apiKey, t.bundleId, te, t), t);
606
+ (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(t, R, {
607
+ phase: "preloadBackground",
608
+ cacheKey: G
609
+ }), qe.processFrame(R).then(h => {
610
+ if (y() || !h || !h.filePath) return;
851
611
  const {
852
- baseUnit
853
- } = core._getColormapForVariable(variable);
854
- const toUnit = core._getTargetUnit(baseUnit, units);
855
- const fieldInfo = _javascriptSdk.DICTIONARIES?.fld?.[variable] || {};
856
- const serverDataUnit = fieldInfo.defaultUnit || baseUnit;
857
- let dataScale = result.scale;
858
- let dataOffset = result.offset;
859
- let convertedScale = dataScale;
860
- let convertedOffset = dataOffset;
861
-
862
- // Step 1: Convert from server unit to colormap base unit
863
- if (serverDataUnit !== baseUnit) {
864
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(serverDataUnit, baseUnit);
865
- if (conversionFunc) {
866
- if (result.scaleType === 'sqrt') {
867
- const physicalAtOffset = dataOffset * dataOffset;
868
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
869
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
870
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
871
- convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
872
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
873
- convertedScale = newOffsetPlusScale - convertedOffset;
874
- } else {
875
- convertedOffset = conversionFunc(dataOffset);
876
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
877
- convertedScale = convertedOffsetPlusScale - convertedOffset;
878
- }
879
- dataScale = convertedScale;
880
- dataOffset = convertedOffset;
612
+ baseUnit: k
613
+ } = t._getColormapForVariable(s),
614
+ P = t._getTargetUnit(k, w),
615
+ f = (_javascriptSdk.DICTIONARIES?.fld?.[s] || {}).defaultUnit || k;
616
+ let C = h.scale,
617
+ b = h.offset,
618
+ S = C,
619
+ T = b;
620
+ if (f !== k) {
621
+ const H = (0, _javascriptSdk.getUnitConversionFunction)(f, k);
622
+ if (H) {
623
+ if (h.scaleType === "sqrt") {
624
+ const oe = b * b,
625
+ ce = (b + C) * (b + C),
626
+ Re = H(oe),
627
+ Fe = H(ce);
628
+ T = Math.sqrt(Math.abs(Re)) * Math.sign(Re), S = Math.sqrt(Math.abs(Fe)) * Math.sign(Fe) - T;
629
+ } else T = H(b), S = H(b + C) - T;
630
+ C = S, b = T;
881
631
  }
882
632
  }
883
-
884
- // Step 2: Convert from colormap base unit to target display unit
885
- if (baseUnit !== toUnit) {
886
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(baseUnit, toUnit);
887
- if (conversionFunc) {
888
- if (result.scaleType === 'sqrt') {
889
- const physicalAtOffset = dataOffset * dataOffset;
890
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
891
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
892
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
893
- convertedOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
894
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
895
- convertedScale = newOffsetPlusScale - convertedOffset;
896
- } else {
897
- convertedOffset = conversionFunc(dataOffset);
898
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
899
- convertedScale = convertedOffsetPlusScale - convertedOffset;
900
- }
901
- }
633
+ if (k !== P) {
634
+ const H = (0, _javascriptSdk.getUnitConversionFunction)(k, P);
635
+ if (H) if (h.scaleType === "sqrt") {
636
+ const oe = b * b,
637
+ ce = (b + C) * (b + C),
638
+ Re = H(oe),
639
+ Fe = H(ce);
640
+ T = Math.sqrt(Math.abs(Re)) * Math.sign(Re), S = Math.sqrt(Math.abs(Fe)) * Math.sign(Fe) - T;
641
+ } else T = H(b), S = H(b + C) - T;
902
642
  }
903
- const frameData = {
904
- filePath: result.filePath,
905
- nx,
906
- ny,
907
- scale: convertedScale,
908
- offset: convertedOffset,
909
- missing: result.missing,
910
- corners,
911
- gridDef,
912
- scaleType: result.scaleType,
913
- originalScale: result.scale,
914
- originalOffset: result.offset
643
+ const L = {
644
+ filePath: h.filePath,
645
+ nx: de,
646
+ ny: ye,
647
+ scale: S,
648
+ offset: T,
649
+ missing: h.missing,
650
+ corners: D,
651
+ gridDef: q,
652
+ scaleType: h.scaleType,
653
+ originalScale: h.scale,
654
+ originalOffset: h.offset
915
655
  };
916
- preloadedDataCache.current.set(cacheKey, frameData);
917
- if (_reactNative.Platform.OS === 'ios' && gridLayerRef.current.primeGpuCache) {
918
- const frameInfoForGpu = {
919
- [cacheKey]: {
920
- filePath: frameData.filePath,
921
- nx: frameData.nx,
922
- ny: frameData.ny,
923
- scale: frameData.scale,
924
- offset: frameData.offset,
925
- missing: frameData.missing,
926
- scaleType: frameData.scaleType || 'linear',
927
- originalScale: frameData.originalScale,
928
- originalOffset: frameData.originalOffset
656
+ if (W.current.set(G, L), _reactNative.Platform.OS === "ios" && p.current.primeGpuCache) {
657
+ const H = {
658
+ [G]: {
659
+ filePath: L.filePath,
660
+ nx: L.nx,
661
+ ny: L.ny,
662
+ scale: L.scale,
663
+ offset: L.offset,
664
+ missing: L.missing,
665
+ scaleType: L.scaleType || "linear",
666
+ originalScale: L.originalScale,
667
+ originalOffset: L.originalOffset
929
668
  }
930
669
  };
931
- gridLayerRef.current.primeGpuCache(frameInfoForGpu);
932
- }
933
- }).catch(e => {
934
- const cancelled = e && (e.code === 'E_CANCELLED' || e?.userInfo?.code === 'E_CANCELLED' || typeof e?.message === 'string' && e.message.includes('superseded'));
935
- if (!cancelled) {
936
- wxGridWarn('backgroundFrameError', {
937
- cacheKey,
938
- code: e?.code,
939
- message: e?.message
940
- });
670
+ p.current.primeGpuCache(H);
941
671
  }
672
+ }).catch(h => {
673
+ h && (h.code === "E_CANCELLED" || h?.userInfo?.code === "E_CANCELLED" || typeof h?.message == "string" && h.message.includes("superseded")) || Z("backgroundFrameError", {
674
+ cacheKey: G,
675
+ code: h?.code,
676
+ message: h?.message
677
+ });
942
678
  });
943
679
  });
944
680
  };
945
681
  (0, _react.useEffect)(() => {
946
- // This effect manages the auto-refresh based on props
947
- if (autoRefresh) {
948
- const interval = (autoRefreshInterval || 30) * 1000;
949
- _checkForUpdates(); // Run immediately on enable
950
- autoRefreshIntervalId.current = setInterval(_checkForUpdates, interval);
682
+ if (Pe) {
683
+ const r = (xe || 30) * 1e3;
684
+ Se(), me.current = setInterval(Se, r);
951
685
  }
952
-
953
- // Cleanup function: this runs when the component unmounts or props change
954
686
  return () => {
955
- if (autoRefreshIntervalId.current) {
956
- clearInterval(autoRefreshIntervalId.current);
957
- autoRefreshIntervalId.current = null;
958
- }
687
+ me.current && (clearInterval(me.current), me.current = null);
959
688
  };
960
- }, [autoRefresh, autoRefreshInterval, _checkForUpdates]);
961
- const updateGPUWithCachedData = state => {
962
- const {
963
- model,
964
- date,
965
- run,
966
- forecastHour,
967
- variable,
968
- units,
969
- isMRMS,
970
- mrmsTimestamp
971
- } = state;
972
- const cacheKey = isMRMS ? `mrms-${mrmsTimestamp}-${variable}` : `${model}-${date}-${run}-${forecastHour}-${variable}`;
973
- if (_reactNative.Platform.OS === 'ios' && gridLayerRef.current.setActiveFrame) {
974
- // Get the cached data BEFORE calling setActiveFrame
975
- const cachedData = preloadedDataCache.current.get(cacheKey);
976
- if (cachedData) {
977
- currentGridDataRef.current = {
978
- nx: cachedData.nx,
979
- ny: cachedData.ny,
980
- scale: cachedData.scale,
981
- offset: cachedData.offset,
982
- missing: cachedData.missing,
983
- gridDef: cachedData.gridDef,
984
- variable: variable,
985
- units: units,
986
- scaleType: cachedData.scaleType
987
- };
988
- } else {
989
- wxGridVerbose('gpuIOS_setActiveFrame_no_row', {
990
- cacheKey,
991
- cacheSize: preloadedDataCache.current.size
992
- });
993
- }
994
- gridLayerRef.current.setActiveFrame(cacheKey);
995
- wxGridVerbose('gpuIOS_setActiveFrame', {
996
- cacheKey,
997
- hadCachedRow: Boolean(cachedData)
998
- });
999
- return true;
1000
- }
1001
- const cachedData = preloadedDataCache.current.get(cacheKey);
1002
- if (!cachedData) {
1003
- wxGridWarn('updateGPUNoCache', {
1004
- cacheKey,
1005
- cacheSize: preloadedDataCache.current.size,
1006
- sampleKeys: Array.from(preloadedDataCache.current.keys()).slice(0, 5)
1007
- });
1008
- return false;
1009
- }
1010
- if (!gridLayerRef.current) {
1011
- wxGridWarn('updateGPUNoGridLayerRef', {
1012
- cacheKey
1013
- });
1014
- return false;
1015
- }
1016
- if (!cachedGeometry.current || cachedGeometry.current.model !== (isMRMS ? 'mrms' : model) || cachedGeometry.current.variable !== variable) {
1017
- gridLayerRef.current.updateGeometry(cachedData.corners, cachedData.gridDef);
1018
- cachedGeometry.current = {
1019
- model: isMRMS ? 'mrms' : model,
1020
- variable
1021
- };
1022
- }
1023
- const colormapKey = `${variable}-${units}`;
1024
- if (!cachedColormap.current || cachedColormap.current.key !== colormapKey) {
689
+ }, [Pe, xe, Se]);
690
+ const yt = r => {
1025
691
  const {
1026
- colormap,
1027
- baseUnit
1028
- } = core._getColormapForVariable(variable);
1029
- const toUnit = core._getTargetUnit(baseUnit, units);
1030
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
1031
- let dataRange;
1032
- if (variable === 'ptypeRefl' || variable === 'ptypeRate') {
1033
- if (isMRMS) {
1034
- dataRange = [5, 380];
1035
- } else {
1036
- dataRange = [5, 380];
1037
- }
1038
- } else {
1039
- dataRange = [finalColormap[0], finalColormap[finalColormap.length - 2]];
692
+ model: a,
693
+ date: e,
694
+ run: o,
695
+ forecastHour: F,
696
+ variable: s,
697
+ units: w,
698
+ isMRMS: N,
699
+ mrmsTimestamp: c
700
+ } = r,
701
+ i = N ? `mrms-${c}-${s}` : `${a}-${e}-${o}-${F}-${s}`;
702
+ if (_reactNative.Platform.OS === "ios" && p.current.setActiveFrame) {
703
+ const y = W.current.get(i);
704
+ return y ? De.current = {
705
+ nx: y.nx,
706
+ ny: y.ny,
707
+ scale: y.scale,
708
+ offset: y.offset,
709
+ missing: y.missing,
710
+ gridDef: y.gridDef,
711
+ variable: s,
712
+ units: w,
713
+ scaleType: y.scaleType
714
+ } : z("gpuIOS_setActiveFrame_no_row", {
715
+ cacheKey: i,
716
+ cacheSize: W.current.size
717
+ }), p.current.setActiveFrame(i), z("gpuIOS_setActiveFrame", {
718
+ cacheKey: i,
719
+ hadCachedRow: !!y
720
+ }), !0;
1040
721
  }
1041
- const colormapBytes = _generateColormapBytes(finalColormap);
1042
- const colormapAsBase64 = (0, _base64Js.fromByteArray)(colormapBytes);
1043
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
1044
- cachedColormap.current = {
1045
- key: colormapKey
1046
- };
1047
- cachedDataRange.current = dataRange;
1048
- setRenderProps(prev => ({
1049
- ...prev,
1050
- dataRange
1051
- }));
1052
- }
1053
- if (cachedData.filePath) {
1054
- gridLayerRef.current.updateDataTextureFromFile(cachedData.filePath, cachedData.nx, cachedData.ny, cachedData.scale, cachedData.offset, cachedData.missing, cachedData.scaleType);
1055
- currentGridDataRef.current = {
1056
- nx: cachedData.nx,
1057
- ny: cachedData.ny,
1058
- scale: cachedData.scale,
1059
- offset: cachedData.offset,
1060
- missing: cachedData.missing,
1061
- gridDef: cachedData.gridDef,
1062
- variable: variable,
1063
- units: units,
1064
- scaleType: cachedData.scaleType
1065
- };
1066
- wxGridVerbose('gpuUploadFromFile', {
1067
- cacheKey,
1068
- nx: cachedData.nx,
1069
- ny: cachedData.ny,
1070
- filePathSuffix: String(cachedData.filePath).split('/').pop()
722
+ const u = W.current.get(i);
723
+ if (!u) return Z("updateGPUNoCache", {
724
+ cacheKey: i,
725
+ cacheSize: W.current.size,
726
+ sampleKeys: Array.from(W.current.keys()).slice(0, 5)
727
+ }), !1;
728
+ if (!p.current) return Z("updateGPUNoGridLayerRef", {
729
+ cacheKey: i
730
+ }), !1;
731
+ (!pe.current || pe.current.model !== (N ? "mrms" : a) || pe.current.variable !== s) && (p.current.updateGeometry(u.corners, u.gridDef), pe.current = {
732
+ model: N ? "mrms" : a,
733
+ variable: s
1071
734
  });
1072
- } else {
1073
- wxGridWarn('updateGPUNoFilePath', {
1074
- cacheKey
1075
- });
1076
- return false;
1077
- }
1078
-
1079
- // Update inspector parameters for file-based data too
1080
- if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
1081
- gridLayerRef.current.updateDataParameters(cachedData.scale, cachedData.offset, cachedData.missing);
1082
- }
1083
- return true;
1084
- };
1085
- const handleStateChangeRef = (0, _react.useRef)(null);
1086
- const debounceTimeoutRef = (0, _react.useRef)(null);
1087
- (0, _react.useEffect)(() => {
1088
- if (core && props.customColormaps) {
1089
- core.customColormaps = props.customColormaps;
1090
- // Trigger a re-render if we already have data loaded
1091
- if (hasInitialLoad.current) {
1092
- core._emitStateChange();
1093
- }
1094
- }
1095
- }, [core, props.customColormaps]);
1096
- const getValueAtPoint = async (lng, lat) => {
1097
- if (!core) {
1098
- return null;
1099
- }
1100
- if (NEXRAD_NATIVE && core.state?.isNexrad) {
1101
- return getNexradInspectPayloadAt(lng, lat);
1102
- }
1103
-
1104
- // ADD THIS: Check if we have valid data before attempting inspection
1105
- if (!currentGridDataRef.current) {
1106
- return null;
1107
- }
1108
- try {
1109
- const gridIndices = core._getGridIndexFromLngLat(lng, lat);
1110
- if (!gridIndices) return null;
1111
- const {
1112
- i,
1113
- j
1114
- } = gridIndices;
1115
- const value = await InspectorModule.getValueAtGridIndex(i, j);
1116
- if (value === null) {
1117
- return null;
1118
- }
1119
- const {
1120
- colormap,
1121
- baseUnit
1122
- } = core._getColormapForVariable(core.state.variable);
1123
- const displayUnit = core._getTargetUnit(baseUnit, core.state.units);
1124
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, displayUnit);
1125
- const minThreshold = finalColormap[0];
1126
- if (value < minThreshold) {
1127
- return null;
735
+ const A = `${s}-${w}`;
736
+ if (!ge.current || ge.current.key !== A) {
737
+ const {
738
+ colormap: y,
739
+ baseUnit: M
740
+ } = t._getColormapForVariable(s),
741
+ U = t._getTargetUnit(M, w),
742
+ E = t._convertColormapUnits(y, M, U);
743
+ let K;
744
+ s === "ptypeRefl" || s === "ptypeRate" ? N ? K = [5, 380] : K = [5, 380] : K = [E[0], E[E.length - 2]];
745
+ const Y = et(E),
746
+ D = (0, _base64Js.fromByteArray)(Y);
747
+ p.current.updateColormapTexture(D), ge.current = {
748
+ key: A
749
+ }, ke.current = K, Me(q => ({
750
+ ...q,
751
+ dataRange: K
752
+ }));
1128
753
  }
1129
-
1130
- // Filter out values below the minimum threshold (matching shader behavior)
1131
- if (value < minThreshold) {
1132
- return null;
754
+ if (u.filePath) p.current.updateDataTextureFromFile(u.filePath, u.nx, u.ny, u.scale, u.offset, u.missing, u.scaleType), De.current = {
755
+ nx: u.nx,
756
+ ny: u.ny,
757
+ scale: u.scale,
758
+ offset: u.offset,
759
+ missing: u.missing,
760
+ gridDef: u.gridDef,
761
+ variable: s,
762
+ units: w,
763
+ scaleType: u.scaleType
764
+ }, z("gpuUploadFromFile", {
765
+ cacheKey: i,
766
+ nx: u.nx,
767
+ ny: u.ny,
768
+ filePathSuffix: String(u.filePath).split("/").pop()
769
+ });else return Z("updateGPUNoFilePath", {
770
+ cacheKey: i
771
+ }), !1;
772
+ return p.current && p.current.updateDataParameters && p.current.updateDataParameters(u.scale, u.offset, u.missing), !0;
773
+ },
774
+ he = (0, _react.useRef)(null),
775
+ le = (0, _react.useRef)(null);
776
+ (0, _react.useEffect)(() => {
777
+ t && m.customColormaps && (t.customColormaps = m.customColormaps, ae.current && t._emitStateChange());
778
+ }, [t, m.customColormaps]);
779
+ const lt = async (r, a) => {
780
+ if (!t) return null;
781
+ if (t.state?.isNexrad) {
782
+ const e = X.current;
783
+ return e ? e.getInspectPayload(r, a, ht(t.state)) : null;
1133
784
  }
1134
-
1135
- // Also check if value is NaN or effectively missing
1136
- if (!isFinite(value)) {
785
+ if (!De.current) return null;
786
+ try {
787
+ const e = t._getGridIndexFromLngLat(r, a);
788
+ if (!e) return null;
789
+ const {
790
+ i: o,
791
+ j: F
792
+ } = e,
793
+ s = await kt.getValueAtGridIndex(o, F);
794
+ if (s === null) return null;
795
+ const {
796
+ colormap: w,
797
+ baseUnit: N
798
+ } = t._getColormapForVariable(t.state.variable),
799
+ c = t._getTargetUnit(N, t.state.units),
800
+ i = t._convertColormapUnits(w, N, c)[0];
801
+ return s < i || s < i || !isFinite(s) ? null : {
802
+ value: s,
803
+ unit: c,
804
+ variable: {
805
+ code: t.state.variable,
806
+ name: t.getVariableDisplayName(t.state.variable)
807
+ },
808
+ lngLat: {
809
+ lng: r,
810
+ lat: a
811
+ }
812
+ };
813
+ } catch {
1137
814
  return null;
1138
815
  }
1139
- return {
1140
- value: value,
1141
- unit: displayUnit,
1142
- variable: {
1143
- code: core.state.variable,
1144
- name: core.getVariableDisplayName(core.state.variable)
1145
- },
1146
- lngLat: {
1147
- lng,
1148
- lat
1149
- }
1150
- };
1151
- } catch {
1152
- return null;
1153
- }
1154
- };
1155
- const getValueAtPointRef = (0, _react.useRef)(getValueAtPoint);
1156
- getValueAtPointRef.current = getValueAtPoint;
1157
- const getNexradInspectPayloadAtRef = (0, _react.useRef)(getNexradInspectPayloadAt);
1158
- getNexradInspectPayloadAtRef.current = getNexradInspectPayloadAt;
1159
- const _checkForUpdates = (0, _react.useMemo)(() => async () => {
1160
- if (!core) return;
1161
- const s = core.state;
1162
- const {
1163
- isMRMS,
1164
- isSatellite,
1165
- isNexrad,
1166
- model: currentModel,
1167
- variable: currentVariable,
1168
- date,
1169
- run
1170
- } = s;
1171
- if (isSatellite) {
1172
- const prevTimeline = core._computeSatelliteTimeline();
1173
- const prevTimes = [...(prevTimeline.unixTimes || [])].map(t => Number(t)).filter(t => !Number.isNaN(t)).sort((a, b) => a - b);
1174
- const prevMax = prevTimes.length ? prevTimes[prevTimes.length - 1] : null;
1175
- const curSat = s.satelliteTimestamp == null ? null : Number(s.satelliteTimestamp);
1176
- await core.fetchSatelliteListing(true);
1177
- core._emitStateChange();
1178
- const nextTimeline = core._computeSatelliteTimeline();
1179
- const nextTimes = [...(nextTimeline.unixTimes || [])].map(t => Number(t)).filter(t => !Number.isNaN(t)).sort((a, b) => a - b);
1180
- const newMax = nextTimes.length ? nextTimes[nextTimes.length - 1] : null;
1181
- if (prevMax != null && curSat != null && curSat === prevMax && newMax != null && newMax > prevMax) {
1182
- await core.setSatelliteTimestamp(newMax);
1183
- } else if (curSat != null && newMax != null && nextTimes.length && !nextTimes.includes(curSat)) {
1184
- await core.setSatelliteTimestamp(newMax);
1185
- }
816
+ },
817
+ We = (0, _react.useRef)(lt);
818
+ We.current = lt;
819
+ const Se = (0, _react.useMemo)(() => async () => {
820
+ if (!t) return;
821
+ const r = t.state,
822
+ {
823
+ isMRMS: a,
824
+ isSatellite: e,
825
+ isNexrad: o,
826
+ model: F,
827
+ variable: s,
828
+ date: w,
829
+ run: N
830
+ } = r;
831
+ if (e) {
832
+ const c = [...(t._computeSatelliteTimeline().unixTimes || [])].map(M => Number(M)).filter(M => !Number.isNaN(M)).sort((M, U) => M - U),
833
+ i = c.length ? c[c.length - 1] : null,
834
+ u = r.satelliteTimestamp == null ? null : Number(r.satelliteTimestamp);
835
+ await t.fetchSatelliteListing(!0), t._emitStateChange();
836
+ const A = [...(t._computeSatelliteTimeline().unixTimes || [])].map(M => Number(M)).filter(M => !Number.isNaN(M)).sort((M, U) => M - U),
837
+ y = A.length ? A[A.length - 1] : null;
838
+ i != null && u != null && u === i && y != null && y > i ? await t.setSatelliteTimestamp(y) : u != null && y != null && A.length && !A.includes(u) && (await t.setSatelliteTimestamp(y));
1186
839
  return;
1187
840
  }
1188
- if (isNexrad && s.nexradSite) {
1189
- const nk = core._nexradTimesCacheKey();
1190
- const rawBefore = nk ? core.nexradTimesByStation[nk]?.unixTimes : [];
1191
- const filteredBefore = core._getFilteredNexradTimestampsForVariable(rawBefore || []);
1192
- const prevMax = filteredBefore.length ? filteredBefore[filteredBefore.length - 1] : null;
1193
- const curNx = s.nexradTimestamp == null ? null : Number(s.nexradTimestamp);
1194
- await core.refreshNexradTimes();
1195
- const rawAfter = nk ? core.nexradTimesByStation[nk]?.unixTimes : [];
1196
- const filteredAfter = core._getFilteredNexradTimestampsForVariable(rawAfter || []);
1197
- const newMax = filteredAfter.length ? filteredAfter[filteredAfter.length - 1] : null;
1198
- if (prevMax != null && curNx != null && curNx === prevMax && newMax != null && newMax > prevMax) {
1199
- await core.setNexradTimestamp(newMax);
1200
- } else if (curNx != null && newMax != null && filteredAfter.length && !filteredAfter.includes(curNx)) {
1201
- await core.setNexradTimestamp(newMax);
1202
- }
841
+ if (o && r.nexradSite) {
842
+ const c = t._nexradTimesCacheKey(),
843
+ i = c ? t.nexradTimesByStation[c]?.unixTimes : [],
844
+ u = t._getFilteredNexradTimestampsForVariable(i || []),
845
+ A = u.length ? u[u.length - 1] : null,
846
+ y = r.nexradTimestamp == null ? null : Number(r.nexradTimestamp);
847
+ await t.refreshNexradTimes(), t._emitStateChange();
848
+ const M = c ? t.nexradTimesByStation[c]?.unixTimes : [],
849
+ U = t._getFilteredNexradTimestampsForVariable(M || []),
850
+ E = U.length ? U[U.length - 1] : null;
851
+ A != null && y != null && y === A && E != null && E > A ? await t.setNexradTimestamp(E) : y != null && E != null && U.length && !U.includes(y) && (await t.setNexradTimestamp(E));
1203
852
  return;
1204
853
  }
1205
- if (isMRMS) {
1206
- // --- MRMS LOGIC (Keep existing logic) ---
1207
- const oldTimestamps = new Set(core.mrmsStatus?.[currentVariable] || []);
1208
- const mrmsStatus = await core.fetchMRMSStatus(true);
1209
- const newTimestamps = mrmsStatus?.[currentVariable] || [];
1210
- if (newTimestamps.length === 0) return;
1211
- const newTimestampsToPreload = newTimestamps.filter(ts => !oldTimestamps.has(ts));
1212
- if (newTimestampsToPreload.length > 0) {
1213
- core.mrmsStatus = mrmsStatus;
1214
- core._emitStateChange(); // Update UI slider without changing selection
1215
-
1216
- // ... (Keep your existing preloading logic here) ...
854
+ if (a) {
855
+ const c = new Set(t.mrmsStatus?.[s] || []),
856
+ i = await t.fetchMRMSStatus(!0),
857
+ u = i?.[s] || [];
858
+ if (u.length === 0) return;
859
+ const A = u.filter(y => !c.has(y));
860
+ if (A.length > 0) {
861
+ t.mrmsStatus = i, t._emitStateChange();
1217
862
  const {
1218
- corners,
1219
- gridDef
1220
- } = core._getGridCornersAndDef('mrms');
1221
- const {
1222
- nx,
1223
- ny
1224
- } = gridDef.grid_params;
1225
- newTimestampsToPreload.forEach(frame => {
1226
- const cacheKey = `mrms-${frame}-${currentVariable}`;
1227
- if (preloadedDataCache.current.has(cacheKey)) return;
1228
- const frameDate = new Date(frame * 1000);
1229
- const y = frameDate.getUTCFullYear(),
1230
- m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0'),
1231
- d = frameDate.getUTCDate().toString().padStart(2, '0');
1232
- const resourcePath = `/grids/mrms/${y}${m}${d}/${frame}/0/${currentVariable}/0`;
1233
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
1234
- (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
1235
- phase: 'mrmsRefresh',
1236
- cacheKey
1237
- });
1238
- WeatherFrameProcessorModule.processFrame(options).then(result => {
1239
- if (!result || !result.filePath) return;
1240
- const frameData = {
1241
- filePath: result.filePath,
1242
- nx,
1243
- ny,
1244
- scale: result.scale,
1245
- offset: result.offset,
1246
- missing: result.missing,
1247
- corners,
1248
- gridDef,
1249
- scaleType: result.scaleType,
1250
- originalScale: result.scale,
1251
- originalOffset: result.offset
863
+ corners: y,
864
+ gridDef: M
865
+ } = t._getGridCornersAndDef("mrms"),
866
+ {
867
+ nx: U,
868
+ ny: E
869
+ } = M.grid_params;
870
+ A.forEach(Y => {
871
+ const D = `mrms-${Y}-${s}`;
872
+ if (W.current.has(D)) return;
873
+ const q = new Date(Y * 1e3),
874
+ de = q.getUTCFullYear(),
875
+ ye = (q.getUTCMonth() + 1).toString().padStart(2, "0"),
876
+ $ = q.getUTCDate().toString().padStart(2, "0"),
877
+ d = `/grids/mrms/${de}${ye}${$}/${Y}/0/${s}/0`,
878
+ G = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(Ze(t.baseGridUrl, d, t.apiKey, t.bundleId, te, t), t);
879
+ (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(t, G, {
880
+ phase: "mrmsRefresh",
881
+ cacheKey: D
882
+ }), qe.processFrame(G).then(n => {
883
+ if (!n || !n.filePath) return;
884
+ const R = {
885
+ filePath: n.filePath,
886
+ nx: U,
887
+ ny: E,
888
+ scale: n.scale,
889
+ offset: n.offset,
890
+ missing: n.missing,
891
+ corners: y,
892
+ gridDef: M,
893
+ scaleType: n.scaleType,
894
+ originalScale: n.scale,
895
+ originalOffset: n.offset
1252
896
  };
1253
- preloadedDataCache.current.set(cacheKey, frameData);
1254
- if (_reactNative.Platform.OS === 'ios' && gridLayerRef.current?.primeGpuCache) {
1255
- gridLayerRef.current.primeGpuCache({
1256
- [cacheKey]: frameData
1257
- });
1258
- }
1259
- }).catch(e => {
1260
- const cancelled = e && (e.code === 'E_CANCELLED' || e?.userInfo?.code === 'E_CANCELLED' || typeof e?.message === 'string' && e.message.includes('superseded'));
1261
- if (!cancelled) {
1262
- wxGridWarn('mrmsRefreshFrameError', {
1263
- cacheKey,
1264
- code: e?.code,
1265
- message: e?.message
1266
- });
1267
- }
897
+ W.current.set(D, R), _reactNative.Platform.OS === "ios" && p.current?.primeGpuCache && p.current.primeGpuCache({
898
+ [D]: R
899
+ });
900
+ }).catch(n => {
901
+ n && (n.code === "E_CANCELLED" || n?.userInfo?.code === "E_CANCELLED" || typeof n?.message == "string" && n.message.includes("superseded")) || Z("mrmsRefreshFrameError", {
902
+ cacheKey: D,
903
+ code: n?.code,
904
+ message: n?.message
905
+ });
1268
906
  });
1269
907
  });
1270
- const newTimestampsSet = new Set(newTimestamps);
1271
- oldTimestamps.forEach(oldTs => {
1272
- if (!newTimestampsSet.has(oldTs)) {
1273
- const cacheKey = `mrms-${oldTs}-${currentVariable}`;
1274
- preloadedDataCache.current.delete(cacheKey);
908
+ const K = new Set(u);
909
+ c.forEach(Y => {
910
+ if (!K.has(Y)) {
911
+ const D = `mrms-${Y}-${s}`;
912
+ W.current.delete(D);
1275
913
  }
1276
914
  });
1277
915
  }
1278
916
  } else {
1279
- const previousStatus = core.modelStatus;
1280
- const modelStatus = await core.fetchModelStatus(true);
1281
- const statusChanged = JSON.stringify(previousStatus) !== JSON.stringify(modelStatus);
1282
- if (statusChanged) {
1283
- core._emitStateChange();
1284
- }
1285
- const latestRun = findLatestModelRun(modelStatus, currentModel);
1286
- if (!latestRun) return;
917
+ const c = t.modelStatus,
918
+ i = await t.fetchModelStatus(!0);
919
+ if (JSON.stringify(c) !== JSON.stringify(i) && t._emitStateChange(), !Gt(i, F)) return;
1287
920
  }
1288
- }, [core]);
921
+ }, [t]);
1289
922
  (0, _react.useEffect)(() => {
1290
- if (!core) {
1291
- return;
1292
- }
1293
- const handleStateChange = newState => {
1294
- if (!previousStateRef.current) {
1295
- previousStateRef.current = core.state;
1296
- }
1297
- const variableChanged = !previousStateRef.current || newState.variable !== previousStateRef.current.variable;
1298
- if (variableChanged && gridLayerRef.current?.setVariable) {
1299
- gridLayerRef.current.setVariable(newState.variable);
1300
- }
1301
- const stateKey = newState.isNexrad ? `nx-${newState.nexradSite}-${newState.nexradProduct}-${newState.nexradDataSource}-${newState.nexradTimestamp}-${newState.nexradTilt}-${newState.units}-${newState.model}-${newState.variable}-${newState.mrmsTimestamp}-${newState.forecastHour}-dur:${newState.nexradDurationValue ?? ''}-tl:${nexradObsTimelineSig(newState)}` : newState.isSatellite ? `sat-${newState.satelliteInstrumentId}-${newState.satelliteSectorLabel}-${newState.satelliteChannel}-${newState.satelliteTimestamp}-${newState.variable}-${newState.units}-${newState.opacity}-dur:${newState.satelliteDurationValue ?? ''}-tl:${satelliteObsTimelineSig(newState)}` : `${newState.model}-${newState.variable}-${newState.date}-${newState.run}-${newState.forecastHour}-${newState.units}-${newState.mrmsTimestamp}`;
1302
- const sameTimeline = newState.isNexrad ? newState.nexradTimestamp === previousStateRef.current?.nexradTimestamp && newState.nexradSite === previousStateRef.current?.nexradSite && newState.nexradProduct === previousStateRef.current?.nexradProduct && Number(newState.nexradTilt) === Number(previousStateRef.current?.nexradTilt) && newState.nexradDurationValue === previousStateRef.current?.nexradDurationValue && nexradObsTimelineSig(newState) === nexradObsTimelineSig(previousStateRef.current) : newState.isSatellite ? newState.satelliteTimestamp === previousStateRef.current?.satelliteTimestamp && newState.satelliteInstrumentId === previousStateRef.current?.satelliteInstrumentId && newState.satelliteSectorLabel === previousStateRef.current?.satelliteSectorLabel && newState.satelliteChannel === previousStateRef.current?.satelliteChannel && newState.satelliteDurationValue === previousStateRef.current?.satelliteDurationValue && satelliteObsTimelineSig(newState) === satelliteObsTimelineSig(previousStateRef.current) : newState.forecastHour === previousStateRef.current?.forecastHour && newState.mrmsTimestamp === previousStateRef.current?.mrmsTimestamp;
1303
- const sameModeAnchor = newState.isSatellite ? newState.satelliteInstrumentId === previousStateRef.current?.satelliteInstrumentId && newState.satelliteSectorLabel === previousStateRef.current?.satelliteSectorLabel && newState.satelliteChannel === previousStateRef.current?.satelliteChannel : newState.model === previousStateRef.current?.model && newState.isMRMS === previousStateRef.current?.isMRMS;
1304
- const isOpacityOnlyChange = hasInitialLoad.current && newState.opacity !== renderProps.opacity && newState.variable === previousStateRef.current?.variable && sameTimeline && sameModeAnchor && newState.units === previousStateRef.current?.units;
1305
- const isPlayStateOnlyChange = hasInitialLoad.current && newState.isPlaying !== previousStateRef.current?.isPlaying && newState.variable === previousStateRef.current?.variable && sameTimeline && sameModeAnchor && newState.units === previousStateRef.current?.units && newState.opacity === previousStateRef.current?.opacity;
1306
- if (!isOpacityOnlyChange && !isPlayStateOnlyChange && lastProcessedState.current === stateKey) {
1307
- previousStateRef.current = newState;
923
+ if (!t) return;
924
+ const r = e => {
925
+ l.current || (l.current = t.state), (!l.current || e.variable !== l.current.variable) && p.current?.setVariable && p.current.setVariable(e.variable);
926
+ const o = e.isNexrad ? `nx-${e.nexradSite}-${e.nexradProduct}-${e.nexradDataSource}-${e.nexradTimestamp}-${e.nexradTilt}-${e.opacity}` : e.isSatellite ? `sat-${e.satelliteInstrumentId}-${e.satelliteSectorLabel}-${e.satelliteChannel}-${e.satelliteTimestamp}-${e.variable}-${e.units}-${e.opacity}-dur:${e.satelliteDurationValue ?? ""}-tl:${ue(e)}` : `${e.model}-${e.variable}-${e.date}-${e.run}-${e.forecastHour}-${e.units}-${e.mrmsTimestamp}`,
927
+ F = e.isNexrad ? e.nexradTimestamp === l.current?.nexradTimestamp && e.nexradSite === l.current?.nexradSite && e.nexradProduct === l.current?.nexradProduct && Number(e.nexradTilt) === Number(l.current?.nexradTilt) : e.isSatellite ? e.satelliteTimestamp === l.current?.satelliteTimestamp && e.satelliteInstrumentId === l.current?.satelliteInstrumentId && e.satelliteSectorLabel === l.current?.satelliteSectorLabel && e.satelliteChannel === l.current?.satelliteChannel && e.satelliteDurationValue === l.current?.satelliteDurationValue && ue(e) === ue(l.current) : e.forecastHour === l.current?.forecastHour && e.mrmsTimestamp === l.current?.mrmsTimestamp,
928
+ s = e.isSatellite ? e.satelliteInstrumentId === l.current?.satelliteInstrumentId && e.satelliteSectorLabel === l.current?.satelliteSectorLabel && e.satelliteChannel === l.current?.satelliteChannel : e.model === l.current?.model && e.isMRMS === l.current?.isMRMS,
929
+ w = ae.current && e.opacity !== Ve.opacity && e.variable === l.current?.variable && F && s && e.units === l.current?.units,
930
+ N = ae.current && e.isPlaying !== l.current?.isPlaying && e.variable === l.current?.variable && F && s && e.units === l.current?.units && e.opacity === l.current?.opacity;
931
+ if (!w && !N && He.current === o) {
932
+ l.current = e;
1308
933
  return;
1309
934
  }
1310
- if (wxGridDebugEnabled() && _reactNative.Platform.OS === 'ios' && (newState.isNexrad && previousStateRef.current?.isNexrad || newState.isSatellite && previousStateRef.current?.isSatellite)) {
1311
- const prev = previousStateRef.current;
1312
- if (newState.isNexrad && prev?.isNexrad) {
1313
- if (newState.nexradDurationValue !== prev.nexradDurationValue || nexradObsTimelineSig(newState) !== nexradObsTimelineSig(prev)) {
1314
- wxGridVerbose('iosNexradTimelineWindowChanged', {
1315
- duration: {
1316
- from: prev.nexradDurationValue,
1317
- to: newState.nexradDurationValue
1318
- },
1319
- timelineSig: {
1320
- from: nexradObsTimelineSig(prev),
1321
- to: nexradObsTimelineSig(newState)
1322
- },
1323
- willSyncNative: true
1324
- });
1325
- }
1326
- }
1327
- if (newState.isSatellite && prev?.isSatellite) {
1328
- if (newState.satelliteDurationValue !== prev.satelliteDurationValue || satelliteObsTimelineSig(newState) !== satelliteObsTimelineSig(prev)) {
1329
- wxGridVerbose('iosSatelliteTimelineWindowChanged', {
1330
- duration: {
1331
- from: prev.satelliteDurationValue,
1332
- to: newState.satelliteDurationValue
1333
- },
1334
- timelineSig: {
1335
- from: satelliteObsTimelineSig(prev),
1336
- to: satelliteObsTimelineSig(newState)
1337
- },
1338
- willSyncNative: true
1339
- });
1340
- }
1341
- }
1342
- }
1343
- if (!isOpacityOnlyChange && !isPlayStateOnlyChange) {
1344
- lastProcessedState.current = stateKey;
935
+ if (pt() && _reactNative.Platform.OS === "ios" && e.isSatellite && l.current?.isSatellite) {
936
+ const i = l.current;
937
+ e.isSatellite && i?.isSatellite && (e.satelliteDurationValue !== i.satelliteDurationValue || ue(e) !== ue(i)) && z("iosSatelliteTimelineWindowChanged", {
938
+ duration: {
939
+ from: i.satelliteDurationValue,
940
+ to: e.satelliteDurationValue
941
+ },
942
+ timelineSig: {
943
+ from: ue(i),
944
+ to: ue(e)
945
+ },
946
+ willSyncNative: !0
947
+ });
1345
948
  }
1346
- if (isOpacityOnlyChange) {
1347
- setRenderProps(prev => ({
1348
- ...prev,
1349
- opacity: newState.opacity
1350
- }));
1351
- if (NEXRAD_NATIVE && newState.isNexrad) {
1352
- nexradControllerRef.current?.applyStyleFromState?.(newState);
1353
- }
1354
- if (SATELLITE_NATIVE && newState.isSatellite) {
1355
- satelliteLayerRef.current?.updateSatelliteStyle?.(JSON.stringify({
1356
- visible: newState.visible !== false,
1357
- opacity: newState.opacity ?? 1,
1358
- fillSmoothing: 0
1359
- }));
1360
- }
1361
- previousStateRef.current = newState;
949
+ if (!w && !N && (He.current = o), w) {
950
+ Me(i => ({
951
+ ...i,
952
+ opacity: e.opacity
953
+ })), ie && e.isSatellite && Ne.current?.updateSatelliteStyle?.(JSON.stringify({
954
+ visible: e.visible !== !1,
955
+ opacity: e.opacity ?? 1,
956
+ fillSmoothing: 0
957
+ })), Q && e.isNexrad && Ie(e), l.current = e;
1362
958
  return;
1363
959
  }
1364
- if (isPlayStateOnlyChange) {
1365
- previousStateRef.current = newState;
960
+ if (N) {
961
+ l.current = e;
1366
962
  return;
1367
963
  }
1368
- const isUnitsOnlyChange = hasInitialLoad.current && newState.model === previousStateRef.current.model && newState.isMRMS === previousStateRef.current.isMRMS && newState.variable === previousStateRef.current.variable && newState.date === previousStateRef.current.date && newState.run === previousStateRef.current.run && (newState.isNexrad ? newState.nexradTimestamp === previousStateRef.current.nexradTimestamp && newState.nexradSite === previousStateRef.current.nexradSite && newState.nexradProduct === previousStateRef.current.nexradProduct : newState.forecastHour === previousStateRef.current.forecastHour && newState.mrmsTimestamp === previousStateRef.current.mrmsTimestamp) && newState.units !== previousStateRef.current.units;
1369
- if (isUnitsOnlyChange) {
1370
- if (NEXRAD_NATIVE && newState.isNexrad) {
1371
- setRenderProps(prev => ({
1372
- ...prev,
1373
- opacity: newState.opacity
1374
- }));
1375
- nexradControllerRef.current?.applyStyleFromState?.(newState);
1376
- previousStateRef.current = newState;
964
+ if (ae.current && e.model === l.current.model && e.isMRMS === l.current.isMRMS && e.variable === l.current.variable && e.date === l.current.date && e.run === l.current.run && (e.isNexrad ? e.nexradTimestamp === l.current.nexradTimestamp && e.nexradSite === l.current.nexradSite && e.nexradProduct === l.current.nexradProduct : e.forecastHour === l.current.forecastHour && e.mrmsTimestamp === l.current.mrmsTimestamp) && e.units !== l.current.units) {
965
+ if (Q && e.isNexrad) {
966
+ Me(q => ({
967
+ ...q,
968
+ opacity: e.opacity
969
+ })), Ie(e), l.current = e;
1377
970
  return;
1378
971
  }
1379
972
  const {
1380
- variable,
1381
- units,
1382
- isMRMS,
1383
- mrmsTimestamp,
1384
- model,
1385
- date,
1386
- run,
1387
- forecastHour
1388
- } = newState;
1389
- const oldCacheKey = isMRMS ? `mrms-${mrmsTimestamp}-${variable}` : `${model}-${date}-${run}-${forecastHour}-${variable}`;
1390
- const cachedData = preloadedDataCache.current.get(oldCacheKey);
1391
- if (cachedData && cachedData.originalScale !== undefined && cachedData.originalOffset !== undefined) {
973
+ variable: i,
974
+ units: u,
975
+ isMRMS: A,
976
+ mrmsTimestamp: y,
977
+ model: M,
978
+ date: U,
979
+ run: E,
980
+ forecastHour: K
981
+ } = e,
982
+ Y = A ? `mrms-${y}-${i}` : `${M}-${U}-${E}-${K}-${i}`,
983
+ D = W.current.get(Y);
984
+ if (D && D.originalScale !== void 0 && D.originalOffset !== void 0) {
1392
985
  const {
1393
- baseUnit
1394
- } = core._getColormapForVariable(variable);
1395
- const toUnit = core._getTargetUnit(baseUnit, units);
1396
- const fieldInfo = _javascriptSdk.DICTIONARIES?.fld?.[variable] || {};
1397
- const serverDataUnit = fieldInfo.defaultUnit || baseUnit;
1398
- let dataScale = cachedData.originalScale;
1399
- let dataOffset = cachedData.originalOffset;
1400
- if (serverDataUnit !== baseUnit) {
1401
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(serverDataUnit, baseUnit);
1402
- if (conversionFunc) {
1403
- if (cachedData.scaleType === 'sqrt') {
1404
- const physicalAtOffset = dataOffset * dataOffset;
1405
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
1406
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
1407
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
1408
- const newOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
1409
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
1410
- dataScale = newOffsetPlusScale - newOffset;
1411
- dataOffset = newOffset;
1412
- } else {
1413
- const convertedOffset = conversionFunc(dataOffset);
1414
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
1415
- dataScale = convertedOffsetPlusScale - convertedOffset;
1416
- dataOffset = convertedOffset;
1417
- }
986
+ baseUnit: q
987
+ } = t._getColormapForVariable(i),
988
+ de = t._getTargetUnit(q, u),
989
+ ye = (_javascriptSdk.DICTIONARIES?.fld?.[i] || {}).defaultUnit || q;
990
+ let $ = D.originalScale,
991
+ d = D.originalOffset;
992
+ if (ye !== q) {
993
+ const f = (0, _javascriptSdk.getUnitConversionFunction)(ye, q);
994
+ if (f) if (D.scaleType === "sqrt") {
995
+ const C = d * d,
996
+ b = (d + $) * (d + $),
997
+ S = f(C),
998
+ T = f(b),
999
+ L = Math.sqrt(Math.abs(S)) * Math.sign(S);
1000
+ $ = Math.sqrt(Math.abs(T)) * Math.sign(T) - L, d = L;
1001
+ } else {
1002
+ const C = f(d);
1003
+ $ = f(d + $) - C, d = C;
1418
1004
  }
1419
1005
  }
1420
- if (baseUnit !== toUnit) {
1421
- const conversionFunc = (0, _javascriptSdk.getUnitConversionFunction)(baseUnit, toUnit);
1422
- if (conversionFunc) {
1423
- if (cachedData.scaleType === 'sqrt') {
1424
- const physicalAtOffset = dataOffset * dataOffset;
1425
- const physicalAtOffsetPlusScale = (dataOffset + dataScale) * (dataOffset + dataScale);
1426
- const convertedPhysicalAtOffset = conversionFunc(physicalAtOffset);
1427
- const convertedPhysicalAtOffsetPlusScale = conversionFunc(physicalAtOffsetPlusScale);
1428
- const newOffset = Math.sqrt(Math.abs(convertedPhysicalAtOffset)) * Math.sign(convertedPhysicalAtOffset);
1429
- const newOffsetPlusScale = Math.sqrt(Math.abs(convertedPhysicalAtOffsetPlusScale)) * Math.sign(convertedPhysicalAtOffsetPlusScale);
1430
- dataScale = newOffsetPlusScale - newOffset;
1431
- dataOffset = newOffset;
1432
- } else {
1433
- const convertedOffset = conversionFunc(dataOffset);
1434
- const convertedOffsetPlusScale = conversionFunc(dataOffset + dataScale);
1435
- dataScale = convertedOffsetPlusScale - convertedOffset;
1436
- dataOffset = convertedOffset;
1437
- }
1006
+ if (q !== de) {
1007
+ const f = (0, _javascriptSdk.getUnitConversionFunction)(q, de);
1008
+ if (f) if (D.scaleType === "sqrt") {
1009
+ const C = d * d,
1010
+ b = (d + $) * (d + $),
1011
+ S = f(C),
1012
+ T = f(b),
1013
+ L = Math.sqrt(Math.abs(S)) * Math.sign(S);
1014
+ $ = Math.sqrt(Math.abs(T)) * Math.sign(T) - L, d = L;
1015
+ } else {
1016
+ const C = f(d);
1017
+ $ = f(d + $) - C, d = C;
1438
1018
  }
1439
1019
  }
1440
1020
  const {
1441
- colormap
1442
- } = core._getColormapForVariable(variable);
1443
- const finalColormap = core._convertColormapUnits(colormap, baseUnit, toUnit);
1444
- let dataRange = variable === 'ptypeRefl' || variable === 'ptypeRate' ? [5, 380] : [finalColormap[0], finalColormap[finalColormap.length - 2]];
1445
- const colormapBytes = _generateColormapBytes(finalColormap);
1446
- const colormapAsBase64 = (0, _base64Js.fromByteArray)(colormapBytes);
1447
- gridLayerRef.current.updateColormapTexture(colormapAsBase64);
1448
- cachedColormap.current = {
1449
- key: `${variable}-${units}`
1450
- };
1451
- cachedDataRange.current = dataRange;
1452
- setRenderProps(prev => ({
1453
- ...prev,
1454
- dataRange,
1455
- opacity: newState.opacity
1456
- }));
1457
- if (gridLayerRef.current && gridLayerRef.current.updateDataParameters) {
1458
- const scaleTypeValue = cachedData.scaleType === 'sqrt' ? 1 : 0;
1459
- gridLayerRef.current.updateDataParameters(dataScale, dataOffset, cachedData.missing, scaleTypeValue);
1021
+ colormap: G
1022
+ } = t._getColormapForVariable(i),
1023
+ n = t._convertColormapUnits(G, q, de);
1024
+ let R = i === "ptypeRefl" || i === "ptypeRate" ? [5, 380] : [n[0], n[n.length - 2]];
1025
+ const h = et(n),
1026
+ k = (0, _base64Js.fromByteArray)(h);
1027
+ if (p.current.updateColormapTexture(k), ge.current = {
1028
+ key: `${i}-${u}`
1029
+ }, ke.current = R, Me(f => ({
1030
+ ...f,
1031
+ dataRange: R,
1032
+ opacity: e.opacity
1033
+ })), p.current && p.current.updateDataParameters) {
1034
+ const f = D.scaleType === "sqrt" ? 1 : 0;
1035
+ p.current.updateDataParameters($, d, D.missing, f);
1460
1036
  }
1461
- const newCacheKey = isMRMS ? `mrms-${mrmsTimestamp}-${variable}` : `${model}-${date}-${run}-${forecastHour}-${variable}`;
1462
- preloadedDataCache.current.set(newCacheKey, {
1463
- ...cachedData,
1464
- scale: dataScale,
1465
- offset: dataOffset
1037
+ const P = A ? `mrms-${y}-${i}` : `${M}-${U}-${E}-${K}-${i}`;
1038
+ W.current.set(P, {
1039
+ ...D,
1040
+ scale: $,
1041
+ offset: d
1466
1042
  });
1467
1043
  }
1468
- previousStateRef.current = newState;
1044
+ l.current = e;
1469
1045
  return;
1470
1046
  }
1471
- const prev = previousStateRef.current;
1472
- const needsFullLoad = !hasInitialLoad.current || newState.isNexrad !== prev?.isNexrad || newState.isSatellite !== prev?.isSatellite || newState.isNexrad && prev?.isNexrad && (newState.nexradSite !== prev.nexradSite || newState.nexradDataSource !== prev.nexradDataSource || newState.nexradProduct !== prev.nexradProduct) || newState.isSatellite && prev?.isSatellite && (newState.satelliteInstrumentId !== prev.satelliteInstrumentId || newState.satelliteSectorLabel !== prev.satelliteSectorLabel || newState.satelliteChannel !== prev.satelliteChannel) || !newState.isNexrad && !newState.isSatellite && (newState.model !== prev?.model || newState.isMRMS !== prev?.isMRMS || newState.variable !== prev?.variable || newState.date !== prev?.date || newState.run !== prev?.run);
1473
- if (needsFullLoad) {
1474
- wxGridVerbose('needsFullLoad', {
1475
- variable: newState.variable,
1476
- isMRMS: newState.isMRMS,
1477
- model: newState.model,
1478
- isInitial: !hasInitialLoad.current,
1479
- prevVariable: prev?.variable,
1480
- prevModel: prev?.model
1047
+ const c = l.current;
1048
+ if (!ae.current || e.isNexrad !== c?.isNexrad || e.isSatellite !== c?.isSatellite || e.isNexrad && c?.isNexrad && (e.nexradSite !== c.nexradSite || e.nexradDataSource !== c.nexradDataSource || e.nexradProduct !== c.nexradProduct) || e.isSatellite && c?.isSatellite && (e.satelliteInstrumentId !== c.satelliteInstrumentId || e.satelliteSectorLabel !== c.satelliteSectorLabel || e.satelliteChannel !== c.satelliteChannel) || !e.isNexrad && !e.isSatellite && (e.model !== c?.model || e.isMRMS !== c?.isMRMS || e.variable !== c?.variable || e.date !== c?.date || e.run !== c?.run)) {
1049
+ z("needsFullLoad", {
1050
+ variable: e.variable,
1051
+ isMRMS: e.isMRMS,
1052
+ model: e.model,
1053
+ isInitial: !ae.current,
1054
+ prevVariable: c?.variable,
1055
+ prevModel: c?.model
1481
1056
  });
1482
- const nexradIdentityChange = NEXRAD_NATIVE && (newState.isNexrad !== prev?.isNexrad || newState.isNexrad && prev?.isNexrad && (newState.nexradSite !== prev.nexradSite || newState.nexradDataSource !== prev.nexradDataSource || newState.nexradProduct !== prev.nexradProduct));
1483
- const satelliteIdentityChange = SATELLITE_NATIVE && (newState.isSatellite !== prev?.isSatellite || newState.isSatellite && prev?.isSatellite && (newState.satelliteInstrumentId !== prev.satelliteInstrumentId || newState.satelliteSectorLabel !== prev.satelliteSectorLabel || newState.satelliteChannel !== prev.satelliteChannel));
1484
- if (nexradIdentityChange) {
1485
- nexradPreloadInteractionRef.current?.cancel?.();
1486
- nexradPreloadInteractionRef.current = null;
1487
- nexradControllerRef.current?.destroy();
1488
- nexradControllerRef.current = null;
1489
- }
1490
- if (satelliteIdentityChange) {
1491
- satelliteControllerRef.current?.destroy();
1492
- satelliteControllerRef.current = null;
1493
- }
1494
- if (gridLayerRef.current) {
1495
- gridLayerRef.current.setVariable(newState.variable);
1496
- gridLayerRef.current.clear();
1497
- if (_reactNative.Platform.OS === 'ios' && gridLayerRef.current.clearGpuCache) {
1498
- gridLayerRef.current.clearGpuCache();
1499
- }
1500
- }
1501
- hasPreloadedRef.current = false;
1502
- preloadGenerationRef.current += 1;
1503
- preloadedDataCache.current.clear();
1504
- cachedGeometry.current = null;
1505
- cachedColormap.current = null;
1506
- currentGridDataRef.current = null;
1507
- WeatherFrameProcessorModule.cancelAllFrames();
1508
- wxGridVerbose('cancelAllFrames', {
1509
- reason: 'needsFullLoad',
1510
- variable: newState.variable,
1511
- generation: preloadGenerationRef.current
1512
- });
1513
- if (!newState.variable) {
1514
- previousStateRef.current = newState;
1057
+ const i = Q && (e.isNexrad !== c?.isNexrad || e.isNexrad && c?.isNexrad && (e.nexradSite !== c.nexradSite || e.nexradDataSource !== c.nexradDataSource || e.nexradProduct !== c.nexradProduct)),
1058
+ u = ie && (e.isSatellite !== c?.isSatellite || e.isSatellite && c?.isSatellite && (e.satelliteInstrumentId !== c.satelliteInstrumentId || e.satelliteSectorLabel !== c.satelliteSectorLabel || e.satelliteChannel !== c.satelliteChannel));
1059
+ if (i && (X.current?.destroy(), X.current = null), u && (re.current?.destroy(), re.current = null), p.current && (p.current.setVariable(e.variable), p.current.clear(), _reactNative.Platform.OS === "ios" && p.current.clearGpuCache && p.current.clearGpuCache()), ne.current = !1, Le.current += 1, W.current.clear(), pe.current = null, ge.current = null, De.current = null, qe.cancelAllFrames(), z("cancelAllFrames", {
1060
+ reason: "needsFullLoad",
1061
+ variable: e.variable,
1062
+ generation: Le.current
1063
+ }), !e.variable) {
1064
+ l.current = e;
1515
1065
  return;
1516
1066
  }
1517
- if (!newState.isNexrad && !newState.isSatellite) {
1518
- preloadAllFramesToDisk(newState);
1519
- } else if (NEXRAD_NATIVE && newState.isNexrad) {
1520
- hasInitialLoad.current = true;
1521
- } else if (SATELLITE_NATIVE && newState.isSatellite) {
1522
- hasInitialLoad.current = true;
1523
- }
1524
- } else if (!newState.isNexrad && (newState.forecastHour !== previousStateRef.current.forecastHour || newState.isMRMS && newState.mrmsTimestamp !== previousStateRef.current.mrmsTimestamp)) {
1525
- const success = updateGPUWithCachedData(newState);
1526
- if (!success) {
1527
- wxGridWarn('timelineGpuUpdateMiss', {
1528
- isMRMS: newState.isMRMS,
1529
- variable: newState.variable,
1530
- mrmsTimestamp: newState.mrmsTimestamp,
1531
- forecastHour: newState.forecastHour
1532
- });
1533
- hasPreloadedRef.current = false;
1534
- void preloadAllFramesToDisk(newState);
1535
- }
1536
- if (success && newState.opacity !== renderProps.opacity) {
1537
- setRenderProps(prev => ({
1538
- ...prev,
1539
- opacity: newState.opacity
1540
- }));
1541
- }
1542
- }
1543
- if (NEXRAD_NATIVE && newState.isNexrad && newState.nexradSite && newState.nexradTimestamp != null) {
1544
- const ctl = ensureNexradController();
1545
- if (ctl) {
1546
- hasInitialLoad.current = true;
1547
- void ctl.sync(newState);
1548
- nexradPreloadInteractionRef.current?.cancel?.();
1549
- const preloadCancelled = {
1550
- v: false
1551
- };
1552
- nexradPreloadInteractionRef.current = {
1553
- cancel: () => {
1554
- preloadCancelled.v = true;
1555
- }
1556
- };
1557
- const nexradTimelineSnapshot = Array.isArray(newState.availableNexradTimestamps) ? newState.availableNexradTimestamps : [];
1558
- const kickPreload = () => {
1559
- nexradPreloadInteractionRef.current = null;
1560
- if (preloadCancelled.v) {
1561
- return;
1562
- }
1563
- const cur = nexradControllerRef.current;
1564
- if (!cur) {
1565
- return;
1566
- }
1567
- const s = core.state;
1568
- if (!s.isNexrad || !s.nexradSite || s.nexradTimestamp == null) {
1569
- return;
1570
- }
1571
- const coreTs = Array.isArray(s.availableNexradTimestamps) ? s.availableNexradTimestamps : [];
1572
- const mergedTimestamps = coreTs.length > 0 ? coreTs : nexradTimelineSnapshot.length > 0 ? nexradTimelineSnapshot : [];
1573
- const preloadState = {
1574
- ...s,
1575
- availableNexradTimestamps: mergedTimestamps
1576
- };
1577
- cur.preloadAllAvailable(preloadState);
1578
- };
1579
- if (typeof queueMicrotask === 'function') {
1580
- queueMicrotask(kickPreload);
1581
- } else {
1582
- setTimeout(kickPreload, 0);
1583
- }
1584
- }
1585
- } else if (NEXRAD_NATIVE && (!newState.isNexrad || !newState.nexradSite)) {
1586
- nexradPreloadInteractionRef.current?.cancel?.();
1587
- nexradPreloadInteractionRef.current = null;
1588
- nexradControllerRef.current?.destroy();
1589
- nexradControllerRef.current = null;
1067
+ !e.isNexrad && !e.isSatellite ? it(e) : Q && e.isNexrad ? Ie(e) : ie && e.isSatellite && (ae.current = !0);
1068
+ } else if (!e.isNexrad && (e.forecastHour !== l.current.forecastHour || e.isMRMS && e.mrmsTimestamp !== l.current.mrmsTimestamp)) {
1069
+ const i = yt(e);
1070
+ i || (Z("timelineGpuUpdateMiss", {
1071
+ isMRMS: e.isMRMS,
1072
+ variable: e.variable,
1073
+ mrmsTimestamp: e.mrmsTimestamp,
1074
+ forecastHour: e.forecastHour
1075
+ }), ne.current = !1, it(e)), i && e.opacity !== Ve.opacity && Me(u => ({
1076
+ ...u,
1077
+ opacity: e.opacity
1078
+ }));
1590
1079
  }
1591
- if (SATELLITE_NATIVE && newState.isSatellite) {
1592
- (0, _satelliteBridgeDiag.satBridgeWarn)('handleStateChange satellite', {
1593
- satelliteInstrumentId: newState.satelliteInstrumentId ?? null,
1594
- satelliteSectorLabel: newState.satelliteSectorLabel ?? null,
1595
- satelliteChannel: newState.satelliteChannel ?? null,
1596
- timelineKeys: Object.keys(newState.satelliteTimeToFileMap || {}).length,
1597
- refHasSync: Boolean(satelliteLayerRef.current?.syncSatellite)
1080
+ if (Q && e.isNexrad ? Ie(e) : Q && !e.isNexrad && (X.current?.destroy(), X.current = null), ie && e.isSatellite) {
1081
+ (0, _satelliteBridgeDiag.satBridgeWarn)("handleStateChange \u2192 satellite", {
1082
+ satelliteInstrumentId: e.satelliteInstrumentId ?? null,
1083
+ satelliteSectorLabel: e.satelliteSectorLabel ?? null,
1084
+ satelliteChannel: e.satelliteChannel ?? null,
1085
+ timelineKeys: Object.keys(e.satelliteTimeToFileMap || {}).length,
1086
+ refHasSync: !!Ne.current?.syncSatellite
1598
1087
  });
1599
- const satCtl = ensureSatelliteController();
1600
- if (satCtl) {
1601
- hasInitialLoad.current = true;
1602
- void satCtl.sync(newState);
1603
- } else {
1604
- (0, _satelliteBridgeDiag.satBridgeWarn)('handleStateChange satellite: ensureSatelliteController returned null', {});
1605
- }
1606
- if (!newState.satelliteInstrumentId && typeof __DEV__ !== 'undefined' && __DEV__) {
1607
- console.warn('[AguaceroWX][satellite] isSatellite is true but satelliteInstrumentId is missing — native sync still runs; timeline may be empty until core sets instrument.');
1608
- }
1609
- } else if (SATELLITE_NATIVE && !newState.isSatellite) {
1610
- satelliteControllerRef.current?.destroy();
1611
- satelliteControllerRef.current = null;
1612
- }
1613
- previousStateRef.current = newState;
1088
+ const i = at();
1089
+ i ? (ae.current = !0, i.sync(e)) : (0, _satelliteBridgeDiag.satBridgeWarn)("handleStateChange satellite: ensureSatelliteController returned null", {}), !e.satelliteInstrumentId && typeof __DEV__ < "u" && __DEV__ && console.warn("[AguaceroWX][satellite] isSatellite is true but satelliteInstrumentId is missing \u2014 native sync still runs; timeline may be empty until core sets instrument.");
1090
+ } else ie && !e.isSatellite && (re.current?.destroy(), re.current = null);
1091
+ l.current = e;
1614
1092
  };
1615
- handleStateChangeRef.current = handleStateChange;
1616
- const stableHandler = newState => {
1617
- lastEmittedStateForInspectRef.current = newState;
1618
- setNexradSitesMapVisible(Boolean(newState.isNexrad && newState.nexradShowSitesPicker !== false));
1619
- // OPTIMIZATION: If playing (high speed), prioritize MAP update and skip debounce
1620
- if (newState.isPlaying) {
1621
- // 1. Update Map FIRST (Native Enqueue)
1622
- if (handleStateChangeRef.current) {
1623
- handleStateChangeRef.current(newState);
1624
- }
1625
-
1626
- // 2. Update UI Slider SECOND
1627
- // This ensures the heavy map frame is processing while React reconciles the slider
1628
- props.onStateChange?.(newState);
1629
- if (debounceTimeoutRef.current) {
1630
- clearTimeout(debounceTimeoutRef.current);
1631
- debounceTimeoutRef.current = null;
1632
- }
1093
+ he.current = r;
1094
+ const a = e => {
1095
+ if (st(!!(e.isNexrad && e.nexradShowSitesPicker !== !1)), e.isPlaying) {
1096
+ he.current && he.current(e), m.onStateChange?.(e), le.current && (clearTimeout(le.current), le.current = null);
1633
1097
  return;
1634
1098
  }
1635
-
1636
- // --- Existing Logic for scrubbing/paused ---
1637
-
1638
- // 1. Immediate Slider Update for responsiveness
1639
- props.onStateChange?.(newState);
1640
- if (debounceTimeoutRef.current) {
1641
- clearTimeout(debounceTimeoutRef.current);
1642
- }
1643
- const prevStable = previousStateRef.current;
1644
- const sameTimelineStable = prevStable && (prevStable.isNexrad ? newState.nexradTimestamp === prevStable.nexradTimestamp && newState.nexradSite === prevStable.nexradSite && newState.nexradProduct === prevStable.nexradProduct && Number(newState.nexradTilt) === Number(prevStable.nexradTilt) && newState.nexradDurationValue === prevStable.nexradDurationValue && nexradObsTimelineSig(newState) === nexradObsTimelineSig(prevStable) : prevStable.isSatellite ? newState.satelliteTimestamp === prevStable.satelliteTimestamp && newState.satelliteInstrumentId === prevStable.satelliteInstrumentId && newState.satelliteSectorLabel === prevStable.satelliteSectorLabel && newState.satelliteChannel === prevStable.satelliteChannel && newState.satelliteDurationValue === prevStable.satelliteDurationValue && satelliteObsTimelineSig(newState) === satelliteObsTimelineSig(prevStable) : newState.forecastHour === prevStable.forecastHour && newState.mrmsTimestamp === prevStable.mrmsTimestamp);
1645
- const sameModeStable = prevStable && (newState.isSatellite ? newState.satelliteInstrumentId === prevStable.satelliteInstrumentId && newState.satelliteSectorLabel === prevStable.satelliteSectorLabel && newState.satelliteChannel === prevStable.satelliteChannel : newState.model === prevStable.model && newState.isMRMS === prevStable.isMRMS);
1646
-
1647
- // Opacity and Play state changes should be immediate for the native layer too
1648
- const isOpacityOnlyChange = prevStable && sameTimelineStable && sameModeStable && newState.opacity !== prevStable.opacity && newState.variable === prevStable.variable && newState.units === prevStable.units;
1649
- const isPlayStateOnlyChange = prevStable && sameTimelineStable && sameModeStable && newState.isPlaying !== prevStable.isPlaying && newState.variable === prevStable.variable && newState.units === prevStable.units && newState.opacity === prevStable.opacity;
1650
- if (isOpacityOnlyChange || isPlayStateOnlyChange || !previousStateRef.current) {
1651
- if (handleStateChangeRef.current) {
1652
- handleStateChangeRef.current(newState);
1653
- }
1099
+ m.onStateChange?.(e), le.current && clearTimeout(le.current);
1100
+ const o = l.current,
1101
+ F = o && (o.isNexrad ? e.nexradTimestamp === o.nexradTimestamp && e.nexradSite === o.nexradSite && e.nexradProduct === o.nexradProduct && Number(e.nexradTilt) === Number(o.nexradTilt) : o.isSatellite ? e.satelliteTimestamp === o.satelliteTimestamp && e.satelliteInstrumentId === o.satelliteInstrumentId && e.satelliteSectorLabel === o.satelliteSectorLabel && e.satelliteChannel === o.satelliteChannel && e.satelliteDurationValue === o.satelliteDurationValue && ue(e) === ue(o) : e.forecastHour === o.forecastHour && e.mrmsTimestamp === o.mrmsTimestamp),
1102
+ s = o && (e.isSatellite ? e.satelliteInstrumentId === o.satelliteInstrumentId && e.satelliteSectorLabel === o.satelliteSectorLabel && e.satelliteChannel === o.satelliteChannel : e.model === o.model && e.isMRMS === o.isMRMS),
1103
+ w = o && F && s && e.opacity !== o.opacity && e.variable === o.variable && e.units === o.units,
1104
+ N = o && F && s && e.isPlaying !== o.isPlaying && e.variable === o.variable && e.units === o.units && e.opacity === o.opacity;
1105
+ if (w || N || !l.current) {
1106
+ he.current && he.current(e);
1654
1107
  return;
1655
1108
  }
1656
- debounceTimeoutRef.current = setTimeout(() => {
1657
- if (handleStateChangeRef.current) {
1658
- handleStateChangeRef.current(newState);
1659
- }
1660
- debounceTimeoutRef.current = null;
1661
- }, 16); // ~60fps map updates
1109
+ le.current = setTimeout(() => {
1110
+ he.current && he.current(e), le.current = null;
1111
+ }, 16);
1662
1112
  };
1663
- core.on('state:change', stableHandler);
1664
- return () => {
1665
- core.off('state:change', stableHandler);
1666
- if (debounceTimeoutRef.current) {
1667
- clearTimeout(debounceTimeoutRef.current);
1668
- }
1669
- if (NEXRAD_NATIVE) {
1670
- nexradPreloadInteractionRef.current?.cancel?.();
1671
- nexradPreloadInteractionRef.current = null;
1672
- nexradControllerRef.current?.destroy();
1673
- nexradControllerRef.current = null;
1674
- }
1675
- if (SATELLITE_NATIVE) {
1676
- satelliteControllerRef.current?.destroy();
1677
- satelliteControllerRef.current = null;
1678
- }
1679
- };
1680
- }, [core, ensureNexradController, ensureSatelliteController]);
1681
- (0, _react.useEffect)(() => {
1682
- return () => {
1683
- preloadedDataCache.current.clear(); // This drops JS references
1684
- hasInitialLoad.current = false;
1685
- lastProcessedState.current = null;
1686
- // Native cleanup
1687
- if (gridLayerRef.current && _reactNative.Platform.OS === 'ios') {
1688
- gridLayerRef.current.clearGpuCache();
1689
- }
1690
- if (NEXRAD_NATIVE) {
1691
- nexradPreloadInteractionRef.current?.cancel?.();
1692
- nexradPreloadInteractionRef.current = null;
1693
- nexradControllerRef.current?.destroy();
1694
- nexradControllerRef.current = null;
1695
- }
1696
- if (SATELLITE_NATIVE) {
1697
- satelliteControllerRef.current?.destroy();
1698
- satelliteControllerRef.current = null;
1699
- }
1113
+ return t.on("state:change", a), () => {
1114
+ t.off("state:change", a), le.current && clearTimeout(le.current), Q && (X.current?.destroy(), X.current = null), ie && (re.current?.destroy(), re.current = null);
1700
1115
  };
1116
+ }, [t, at, Ie]), (0, _react.useEffect)(() => () => {
1117
+ W.current.clear(), ae.current = !1, He.current = null, p.current && _reactNative.Platform.OS === "ios" && p.current.clearGpuCache(), Q && (X.current?.destroy(), X.current = null), ie && (re.current?.destroy(), re.current = null);
1701
1118
  }, []);
1702
- const lastInspectorUpdateRef = (0, _react.useRef)(0);
1703
- const INSPECTOR_THROTTLE_MS = 50;
1119
+ const ot = (0, _react.useRef)(0),
1120
+ bt = 50;
1704
1121
  (0, _react.useEffect)(() => {
1705
- if (!core || !inspectorEnabled) {
1706
- return;
1707
- }
1708
- const handleMapMove = center => {
1709
- if (!center || !Array.isArray(center) || center.length !== 2) {
1710
- return;
1711
- }
1712
-
1713
- // Throttle updates
1714
- const now = Date.now();
1715
- if (now - lastInspectorUpdateRef.current < INSPECTOR_THROTTLE_MS) {
1716
- return;
1717
- }
1718
- lastInspectorUpdateRef.current = now;
1719
- const [longitude, latitude] = center;
1720
- if (NEXRAD_NATIVE && core.state?.isNexrad) {
1721
- onInspect?.(getNexradInspectPayloadAtRef.current(longitude, latitude));
1722
- return;
1723
- }
1724
- void getValueAtPointRef.current(longitude, latitude).then(payload => {
1725
- onInspect?.(payload);
1122
+ if (!t || !g) return;
1123
+ const r = a => {
1124
+ if (!a || !Array.isArray(a) || a.length !== 2) return;
1125
+ const e = Date.now();
1126
+ if (e - ot.current < bt) return;
1127
+ ot.current = e;
1128
+ const [o, F] = a;
1129
+ We.current(o, F).then(s => {
1130
+ I?.(s);
1726
1131
  });
1727
1132
  };
1728
- core.on('map:move', handleMapMove);
1729
- if (context && context.getCenter) {
1730
- const center = context.getCenter();
1731
- if (center) {
1732
- handleMapMove(center);
1733
- }
1133
+ if (t.on("map:move", r), _e && _e.getCenter) {
1134
+ const a = _e.getCenter();
1135
+ a && r(a);
1734
1136
  }
1735
1137
  return () => {
1736
- core.off('map:move', handleMapMove);
1737
- };
1738
- }, [inspectorEnabled, onInspect, core, context]);
1739
- (0, _react.useEffect)(() => {
1740
- if (!core || !inspectorEnabled) {
1741
- return;
1742
- }
1743
- const triggerReinspection = () => {
1744
- const mapRef = _MapRegistry.mapRegistry.getMap();
1745
- const center = mapRef?._currentCenter;
1746
- if (center && Array.isArray(center) && center.length === 2) {
1747
- const [longitude, latitude] = center;
1748
- if (NEXRAD_NATIVE && core?.state?.isNexrad) {
1749
- onInspect?.(getNexradInspectPayloadAtRef.current(longitude, latitude));
1750
- } else {
1751
- getValueAtPointRef.current(longitude, latitude).then(payload => {
1752
- onInspect?.(payload);
1753
- });
1754
- }
1755
- }
1138
+ t.off("map:move", r);
1756
1139
  };
1757
-
1758
- // Small delay to ensure data is loaded before re-inspecting
1759
- const timer = setTimeout(triggerReinspection, 100);
1760
- return () => clearTimeout(timer);
1761
- }, [core?.state?.nexradTimestamp, core?.state?.isNexrad, core?.state?.nexradSite, core?.state?.nexradProduct, core?.state?.nexradTilt, core?.state?.nexradDataSource, core?.state?.nexradStormRelative, core?.state?.variable, core?.state?.model, core?.state?.forecastHour, core?.state?.mrmsTimestamp, core?.state?.units, core?.state?.opacity, inspectorEnabled, onInspect]);
1762
- (0, _react.useEffect)(() => {
1763
- if (!core) {
1764
- return;
1765
- }
1766
- const handleCameraChange = center => {
1767
- if (core && center) {
1768
- core.setMapCenter(center);
1140
+ }, [g, I, t, _e]), (0, _react.useEffect)(() => {
1141
+ if (!t || !g) return;
1142
+ const r = setTimeout(() => {
1143
+ const a = _MapRegistry.mapRegistry.getMap()?._currentCenter;
1144
+ if (a && Array.isArray(a) && a.length === 2) {
1145
+ const [e, o] = a;
1146
+ We.current(e, o).then(F => {
1147
+ I?.(F);
1148
+ });
1769
1149
  }
1150
+ }, 100);
1151
+ return () => clearTimeout(r);
1152
+ }, [t?.state?.nexradTimestamp, t?.state?.isNexrad, t?.state?.nexradSite, t?.state?.nexradProduct, t?.state?.nexradTilt, t?.state?.nexradDataSource, t?.state?.nexradStormRelative, t?.state?.variable, t?.state?.model, t?.state?.forecastHour, t?.state?.mrmsTimestamp, t?.state?.units, t?.state?.opacity, g, I]), (0, _react.useEffect)(() => {
1153
+ if (!t) return;
1154
+ const r = e => {
1155
+ t && e && t.setMapCenter(e);
1770
1156
  };
1771
-
1772
- // Register with the global registry
1773
- _MapRegistry.mapRegistry.addCameraListener(handleCameraChange);
1774
-
1775
- // Try to get initial center
1776
- const mapRef = _MapRegistry.mapRegistry.getMap();
1777
- if (mapRef?._currentCenter) {
1778
- handleCameraChange(mapRef._currentCenter);
1779
- }
1780
- return () => {
1781
- _MapRegistry.mapRegistry.removeCameraListener(handleCameraChange);
1782
- };
1783
- }, [core]);
1784
- (0, _react.useEffect)(() => {
1785
- core.initialize({
1786
- autoRefresh: false
1787
- }); // <-- add the argument
1788
- return () => {
1789
- core.destroy();
1157
+ _MapRegistry.mapRegistry.addCameraListener(r);
1158
+ const a = _MapRegistry.mapRegistry.getMap();
1159
+ return a?._currentCenter && r(a._currentCenter), () => {
1160
+ _MapRegistry.mapRegistry.removeCameraListener(r);
1790
1161
  };
1791
- }, [core]);
1792
- const gridBelowId = belowIDFromProps ?? context?.weatherBeforeLayerId ?? 'AML_-_terrain';
1162
+ }, [t]), (0, _react.useEffect)(() => (t.initialize({
1163
+ autoRefresh: !1
1164
+ }), () => {
1165
+ t.destroy();
1166
+ }), [t]);
1167
+ const Oe = Te ?? _e?.weatherBeforeLayerId ?? "AML_-_terrain";
1793
1168
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_GridRenderLayer.GridRenderLayer, {
1794
- ref: gridLayerRef,
1795
- opacity: renderProps.opacity,
1796
- dataRange: renderProps.dataRange,
1797
- belowID: gridBelowId
1798
- }), NEXRAD_NATIVE ? /*#__PURE__*/_react.default.createElement(_NexradRadarLayer.default, {
1799
- ref: nexradLayerRef,
1800
- belowID: gridBelowId
1801
- }) : null, SATELLITE_NATIVE ? /*#__PURE__*/_react.default.createElement(_SatelliteLayer.default, {
1802
- ref: satelliteLayerRef,
1803
- belowID: gridBelowId
1169
+ ref: p,
1170
+ opacity: Ve.opacity,
1171
+ dataRange: Ve.dataRange,
1172
+ belowID: Oe
1173
+ }), Q ? /*#__PURE__*/_react.default.createElement(_NexradRadarLayer.default, {
1174
+ ref: rt,
1175
+ belowID: Oe
1176
+ }) : null, ie ? /*#__PURE__*/_react.default.createElement(_SatelliteLayer.default, {
1177
+ ref: Ne,
1178
+ belowID: Oe
1804
1179
  }) : null, /*#__PURE__*/_react.default.createElement(_NwsAlertsOverlay.default, {
1805
- core: core,
1806
- watchesWarnings: watchesWarningsOptions,
1807
- onNwsAlertClick: onNwsAlertClick
1808
- }), nexradSitesMapVisible ? /*#__PURE__*/_react.default.createElement(_NexradSitesMapLayer.NexradSitesMapLayer, {
1809
- visible: true,
1810
- belowLayerID: gridBelowId,
1811
- onSelectSite: siteId => void core.setNexradSite(siteId)
1180
+ core: t,
1181
+ watchesWarnings: gt,
1182
+ onNwsAlertClick: Ge
1183
+ }), St ? /*#__PURE__*/_react.default.createElement(_NexradSitesMapLayer.NexradSitesMapLayer, {
1184
+ visible: !0,
1185
+ belowLayerID: Oe,
1186
+ onSelectSite: r => void t.setNexradSite(r)
1812
1187
  }) : null);
1813
1188
  });
1814
- WeatherLayerManager.getAvailableVariables = options => {
1815
- if (!options || !options.apiKey) {
1816
- return [];
1817
- }
1818
- const core = new _javascriptSdk.AguaceroCore({
1819
- apiKey: options.apiKey
1820
- });
1821
- return core.getAvailableVariables('mrms');
1822
- };
1189
+ WeatherLayerManager.getAvailableVariables = m => !m || !m.apiKey ? [] : new _javascriptSdk.AguaceroCore({
1190
+ apiKey: m.apiKey
1191
+ }).getAvailableVariables("mrms");
1823
1192
  //# sourceMappingURL=WeatherLayerManager.js.map