@aguacerowx/react-native 0.0.51 → 0.0.53

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 (53) hide show
  1. package/android/src/main/cpp/satellite_ktx_jni.cpp +6 -1
  2. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayer.java +121 -1
  3. package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayerView.java +556 -384
  4. package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +315 -311
  5. package/ios/SatelliteLayerView.swift +517 -510
  6. package/ios/WeatherFrameProcessorModule.swift +222 -219
  7. package/lib/commonjs/WeatherLayerManager.js +82 -46
  8. package/lib/commonjs/WeatherLayerManager.js.map +1 -1
  9. package/lib/commonjs/aguaceroRnDebug.js +9 -1
  10. package/lib/commonjs/aguaceroRnDebug.js.map +1 -1
  11. package/lib/commonjs/gridCdnAuth.js +64 -0
  12. package/lib/commonjs/gridCdnAuth.js.map +1 -0
  13. package/lib/commonjs/index.js +50 -0
  14. package/lib/commonjs/index.js.map +1 -1
  15. package/lib/commonjs/nexrad/nexradAndroidController.js +25 -25
  16. package/lib/commonjs/nexrad/nexradAndroidController.js.map +1 -1
  17. package/lib/commonjs/nexrad/nexradDiag.js +24 -24
  18. package/lib/commonjs/satellite/satelliteAndroidController.js +32 -24
  19. package/lib/commonjs/satellite/satelliteAndroidController.js.map +1 -1
  20. package/lib/commonjs/satelliteRnDebug.js +261 -0
  21. package/lib/commonjs/satelliteRnDebug.js.map +1 -0
  22. package/lib/module/WeatherLayerManager.js +82 -46
  23. package/lib/module/WeatherLayerManager.js.map +1 -1
  24. package/lib/module/aguaceroRnDebug.js +9 -1
  25. package/lib/module/aguaceroRnDebug.js.map +1 -1
  26. package/lib/module/gridCdnAuth.js +56 -0
  27. package/lib/module/gridCdnAuth.js.map +1 -0
  28. package/lib/module/index.js +2 -0
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/nexrad/nexradAndroidController.js +25 -25
  31. package/lib/module/nexrad/nexradAndroidController.js.map +1 -1
  32. package/lib/module/nexrad/nexradDiag.js +24 -24
  33. package/lib/module/satellite/satelliteAndroidController.js +32 -24
  34. package/lib/module/satellite/satelliteAndroidController.js.map +1 -1
  35. package/lib/module/satelliteRnDebug.js +248 -0
  36. package/lib/module/satelliteRnDebug.js.map +1 -0
  37. package/lib/typescript/WeatherLayerManager.d.ts.map +1 -1
  38. package/lib/typescript/aguaceroRnDebug.d.ts.map +1 -1
  39. package/lib/typescript/gridCdnAuth.d.ts +24 -0
  40. package/lib/typescript/gridCdnAuth.d.ts.map +1 -0
  41. package/lib/typescript/index.d.ts +2 -0
  42. package/lib/typescript/satellite/satelliteAndroidController.d.ts.map +1 -1
  43. package/lib/typescript/satelliteRnDebug.d.ts +81 -0
  44. package/lib/typescript/satelliteRnDebug.d.ts.map +1 -0
  45. package/package.json +2 -2
  46. package/src/WeatherLayerManager.js +2044 -2004
  47. package/src/aguaceroRnDebug.js +9 -1
  48. package/src/gridCdnAuth.js +56 -0
  49. package/src/index.js +27 -15
  50. package/src/nexrad/nexradAndroidController.js +1078 -1078
  51. package/src/nexrad/nexradDiag.js +150 -150
  52. package/src/satellite/satelliteAndroidController.js +257 -245
  53. package/src/satelliteRnDebug.js +269 -0
@@ -20,6 +20,8 @@ var _MapRegistry = require("./MapRegistry");
20
20
  var _satelliteBridgeDiag = require("./satelliteBridgeDiag");
21
21
  var _aguaceroRnDebug = require("./aguaceroRnDebug");
22
22
  var _aguaceroCoreDebugHooks = require("./aguaceroCoreDebugHooks");
23
+ var _gridCdnAuth = require("./gridCdnAuth");
24
+ var _satelliteRnDebug = require("./satelliteRnDebug");
23
25
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
24
26
  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); }
25
27
  // packages/react-native/src/WeatherLayerManager.js
@@ -32,9 +34,9 @@ const SATELLITE_NATIVE = _reactNative.Platform.OS === 'android' || _reactNative.
32
34
  note: 'If you never see sat-bridge logs, the app bundle is not loading this WeatherLayerManager build.'
33
35
  });
34
36
 
35
- /**
36
- * Same filtering as {@link AguaceroCore#_getFilteredMrmsTimestampsForVariable} for older cores
37
- * where that helper (or {@code setMRMSDurationValue}) is missing from the prototype chain.
37
+ /**
38
+ * Same filtering as {@link AguaceroCore#_getFilteredMrmsTimestampsForVariable} for older cores
39
+ * where that helper (or {@code setMRMSDurationValue}) is missing from the prototype chain.
38
40
  */
39
41
  function getFilteredMrmsTimestampsCompat(core, variable) {
40
42
  const raw = core.mrmsStatus?.[variable];
@@ -49,9 +51,9 @@ function getFilteredMrmsTimestampsCompat(core, variable) {
49
51
  return list;
50
52
  }
51
53
 
52
- /**
53
- * Older npm installs may resolve an {@link AguaceroCore} without {@code setMRMSDurationValue} /
54
- * {@code setNexradDurationValue}; mirror those methods here using the same logic as the SDK.
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.
55
57
  */
56
58
  async function applyMrmsDurationValue(core, value) {
57
59
  if (typeof core.setMRMSDurationValue === 'function') {
@@ -116,12 +118,12 @@ const {
116
118
  InspectorModule
117
119
  } = _reactNative.NativeModules;
118
120
 
119
- /**
120
- * `state:change` payloads can briefly have {@code isNexrad} before {@code nexradSite} / {@code nexradTimestamp}
121
- * are populated; {@code core.state} is updated first. Merge so readouts match the active radar.
122
- *
123
- * @param {object | null} emitted
124
- * @param {object | null} coreState
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
125
127
  */
126
128
  function mergeNexradEmittedWithCore(emitted, coreState) {
127
129
  if (!emitted || !coreState) return null;
@@ -136,10 +138,10 @@ function mergeNexradEmittedWithCore(emitted, coreState) {
136
138
  };
137
139
  }
138
140
 
139
- /**
140
- * Compact timeline identity for deduping {@code state:change}: extending the NEXRAD/satellite window
141
- * often keeps the same selected unix — without this, {@link WeatherLayerManager} short-circuits and
142
- * never calls native {@code sync} / preload with the expanded frame list.
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.
143
145
  */
144
146
  function nexradObsTimelineSig(state) {
145
147
  const arr = [...(state?.availableNexradTimestamps || [])].map(Number).filter(t => Number.isFinite(t)).sort((a, b) => a - b);
@@ -180,37 +182,34 @@ function wxGridWarn(tag, detail) {
180
182
  }
181
183
  }
182
184
 
183
- /**
184
- * Native {@code processFrame} must mirror browser/AguaceroCore grid auth: encoded {@code apiKey}
185
- * in the query string and optional {@code Origin} / {@code Referer} (many CloudFront setups require them).
186
- *
187
- * @param {string} baseGridUrl
188
- * @param {string} resourcePath
189
- * @param {string} apiKey
190
- * @param {string | null | undefined} bundleId
191
- * @param {string | undefined} gridRequestSiteOrigin - e.g. production web origin your edge allowlists (no trailing slash)
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
192
195
  */
193
- function buildGridFrameProcessOptions(baseGridUrl, resourcePath, apiKey, bundleId, gridRequestSiteOrigin) {
194
- const url = `${baseGridUrl}${resourcePath}?apiKey=${encodeURIComponent(apiKey)}`;
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 || '')}`;
195
199
  const options = {
196
200
  url,
197
- apiKey,
201
+ apiKey: trimmedKey,
198
202
  bundleId
199
203
  };
200
- if (typeof gridRequestSiteOrigin === 'string') {
201
- let origin = gridRequestSiteOrigin.trim();
202
- while (origin.endsWith('/')) {
203
- origin = origin.slice(0, -1);
204
- }
205
- if (origin.length > 0) {
206
- options.gridRequestSiteOrigin = origin;
207
- }
204
+ const origin = (0, _gridCdnAuth.resolveGridRequestSiteOrigin)(gridRequestSiteOrigin, core);
205
+ if (origin) {
206
+ options.gridRequestSiteOrigin = origin;
208
207
  }
209
208
  return options;
210
209
  }
211
210
 
212
- /**
213
- * A helper function to generate the raw RGBA byte buffer for the colormap texture.
211
+ /**
212
+ * A helper function to generate the raw RGBA byte buffer for the colormap texture.
214
213
  */
215
214
  const _generateColormapBytes = colormap => {
216
215
  const width = 256;
@@ -262,6 +261,12 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
262
261
  customColormaps,
263
262
  initialMode,
264
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,
265
270
  autoRefresh,
266
271
  autoRefreshInterval,
267
272
  initialModel,
@@ -281,6 +286,14 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
281
286
  enabled: Boolean(debug)
282
287
  });
283
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]);
284
297
  const context = (0, _react.useContext)(_AguaceroContext.AguaceroContext);
285
298
 
286
299
  // Create the core here instead of getting it from context
@@ -291,7 +304,12 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
291
304
  layerOptions: {
292
305
  mode: initialMode,
293
306
  variable: initialVariable,
294
- model: initialModel
307
+ model: initialModel,
308
+ ...(initialMode === 'satellite' ? {
309
+ satelliteId: initialSatelliteId,
310
+ sector: initialSatelliteSector,
311
+ satelliteProduct: initialSatelliteProduct ?? initialVariable
312
+ } : {})
295
313
  },
296
314
  autoRefresh: false // <-- add this
297
315
  }), [apiKey, gridRequestSiteOrigin]);
@@ -416,6 +434,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
416
434
  // Track if we've done the initial load
417
435
  const hasInitialLoad = (0, _react.useRef)(false);
418
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);
419
439
 
420
440
  // Track the last state we processed to avoid redundant updates
421
441
  const lastProcessedState = (0, _react.useRef)(null);
@@ -496,9 +516,9 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
496
516
  refreshData: () => {
497
517
  _checkForUpdates();
498
518
  },
499
- /**
500
- * NWS watches/warnings (native map, iOS + Android): same options as mapsgl {@link WeatherLayerManager#configureWatchesWarnings}.
501
- * @param {object} partial
519
+ /**
520
+ * NWS watches/warnings (native map, iOS + Android): same options as mapsgl {@link WeatherLayerManager#configureWatchesWarnings}.
521
+ * @param {object} partial
502
522
  */
503
523
  configureWatchesWarnings: partial => {
504
524
  setWatchesWarningsOptions(prev => ({
@@ -562,6 +582,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
562
582
 
563
583
  // Only mark as "has preloaded" after validation passes
564
584
  hasPreloadedRef.current = true;
585
+ const generation = preloadGenerationRef.current;
586
+ const isStaleGeneration = () => generation !== preloadGenerationRef.current;
565
587
  wxGridVerbose('preloadStart', {
566
588
  isMRMS,
567
589
  model,
@@ -678,7 +700,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
678
700
  } else {
679
701
  resourcePath = `/grids/${model}/${date}/${run}/${currentFrame}/${variable}/0`;
680
702
  }
681
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin), core);
703
+ const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
682
704
  (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
683
705
  phase: 'preloadCurrent',
684
706
  currentCacheKey
@@ -690,6 +712,13 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
690
712
  frame: currentFrame
691
713
  });
692
714
  const result = await WeatherFrameProcessorModule.processFrame(options);
715
+ if (isStaleGeneration()) {
716
+ wxGridVerbose('preloadCurrentFrameStale', {
717
+ currentCacheKey,
718
+ generation
719
+ });
720
+ return;
721
+ }
693
722
  if (!result || !result.filePath) {
694
723
  hasPreloadedRef.current = false;
695
724
  wxGridWarn('preloadAbort', {
@@ -825,12 +854,15 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
825
854
  } else {
826
855
  resourcePath = `/grids/${model}/${date}/${run}/${frame}/${variable}/0`;
827
856
  }
828
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin), core);
857
+ const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
829
858
  (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
830
859
  phase: 'preloadBackground',
831
860
  cacheKey
832
861
  });
833
862
  WeatherFrameProcessorModule.processFrame(options).then(result => {
863
+ if (isStaleGeneration()) {
864
+ return;
865
+ }
834
866
  if (!result || !result.filePath) {
835
867
  return;
836
868
  }
@@ -1218,7 +1250,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
1218
1250
  m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0'),
1219
1251
  d = frameDate.getUTCDate().toString().padStart(2, '0');
1220
1252
  const resourcePath = `/grids/mrms/${y}${m}${d}/${frame}/0/${currentVariable}/0`;
1221
- const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin), core);
1253
+ const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
1222
1254
  (0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
1223
1255
  phase: 'mrmsRefresh',
1224
1256
  cacheKey
@@ -1487,6 +1519,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
1487
1519
  }
1488
1520
  }
1489
1521
  hasPreloadedRef.current = false;
1522
+ preloadGenerationRef.current += 1;
1490
1523
  preloadedDataCache.current.clear();
1491
1524
  cachedGeometry.current = null;
1492
1525
  cachedColormap.current = null;
@@ -1494,7 +1527,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
1494
1527
  WeatherFrameProcessorModule.cancelAllFrames();
1495
1528
  wxGridVerbose('cancelAllFrames', {
1496
1529
  reason: 'needsFullLoad',
1497
- variable: newState.variable
1530
+ variable: newState.variable,
1531
+ generation: preloadGenerationRef.current
1498
1532
  });
1499
1533
  if (!newState.variable) {
1500
1534
  previousStateRef.current = newState;
@@ -1516,6 +1550,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
1516
1550
  mrmsTimestamp: newState.mrmsTimestamp,
1517
1551
  forecastHour: newState.forecastHour
1518
1552
  });
1553
+ hasPreloadedRef.current = false;
1554
+ void preloadAllFramesToDisk(newState);
1519
1555
  }
1520
1556
  if (success && newState.opacity !== renderProps.opacity) {
1521
1557
  setRenderProps(prev => ({