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