@aguacerowx/react-native 0.0.51 → 0.0.52
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.
- package/android/src/main/java/com/aguacerowx/reactnative/SatelliteLayerView.java +11 -3
- package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +315 -311
- package/ios/SatelliteLayerView.swift +11 -4
- package/ios/WeatherFrameProcessorModule.swift +222 -219
- package/lib/commonjs/WeatherLayerManager.js +61 -45
- package/lib/commonjs/WeatherLayerManager.js.map +1 -1
- package/lib/commonjs/aguaceroRnDebug.js +8 -1
- package/lib/commonjs/aguaceroRnDebug.js.map +1 -1
- package/lib/commonjs/gridCdnAuth.js +64 -0
- package/lib/commonjs/gridCdnAuth.js.map +1 -0
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nexrad/nexradAndroidController.js +25 -25
- package/lib/commonjs/nexrad/nexradAndroidController.js.map +1 -1
- package/lib/commonjs/nexrad/nexradDiag.js +24 -24
- package/lib/commonjs/satellite/satelliteAndroidController.js +15 -15
- package/lib/module/WeatherLayerManager.js +61 -45
- package/lib/module/WeatherLayerManager.js.map +1 -1
- package/lib/module/aguaceroRnDebug.js +8 -1
- package/lib/module/aguaceroRnDebug.js.map +1 -1
- package/lib/module/gridCdnAuth.js +56 -0
- package/lib/module/gridCdnAuth.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nexrad/nexradAndroidController.js +25 -25
- package/lib/module/nexrad/nexradAndroidController.js.map +1 -1
- package/lib/module/nexrad/nexradDiag.js +24 -24
- package/lib/module/satellite/satelliteAndroidController.js +15 -15
- package/lib/typescript/WeatherLayerManager.d.ts.map +1 -1
- package/lib/typescript/aguaceroRnDebug.d.ts.map +1 -1
- package/lib/typescript/gridCdnAuth.d.ts +24 -0
- package/lib/typescript/gridCdnAuth.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/WeatherLayerManager.js +2024 -2004
- package/src/aguaceroRnDebug.js +8 -1
- package/src/gridCdnAuth.js +56 -0
- package/src/index.js +19 -15
- package/src/nexrad/nexradAndroidController.js +1078 -1078
- package/src/nexrad/nexradDiag.js +150 -150
- package/src/satellite/satelliteAndroidController.js +245 -245
|
@@ -20,6 +20,7 @@ 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");
|
|
23
24
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
24
25
|
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
26
|
// packages/react-native/src/WeatherLayerManager.js
|
|
@@ -32,9 +33,9 @@ const SATELLITE_NATIVE = _reactNative.Platform.OS === 'android' || _reactNative.
|
|
|
32
33
|
note: 'If you never see sat-bridge logs, the app bundle is not loading this WeatherLayerManager build.'
|
|
33
34
|
});
|
|
34
35
|
|
|
35
|
-
/**
|
|
36
|
-
* Same filtering as {@link AguaceroCore#_getFilteredMrmsTimestampsForVariable} for older cores
|
|
37
|
-
* where that helper (or {@code setMRMSDurationValue}) is missing from the prototype chain.
|
|
36
|
+
/**
|
|
37
|
+
* Same filtering as {@link AguaceroCore#_getFilteredMrmsTimestampsForVariable} for older cores
|
|
38
|
+
* where that helper (or {@code setMRMSDurationValue}) is missing from the prototype chain.
|
|
38
39
|
*/
|
|
39
40
|
function getFilteredMrmsTimestampsCompat(core, variable) {
|
|
40
41
|
const raw = core.mrmsStatus?.[variable];
|
|
@@ -49,9 +50,9 @@ function getFilteredMrmsTimestampsCompat(core, variable) {
|
|
|
49
50
|
return list;
|
|
50
51
|
}
|
|
51
52
|
|
|
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.
|
|
53
|
+
/**
|
|
54
|
+
* Older npm installs may resolve an {@link AguaceroCore} without {@code setMRMSDurationValue} /
|
|
55
|
+
* {@code setNexradDurationValue}; mirror those methods here using the same logic as the SDK.
|
|
55
56
|
*/
|
|
56
57
|
async function applyMrmsDurationValue(core, value) {
|
|
57
58
|
if (typeof core.setMRMSDurationValue === 'function') {
|
|
@@ -116,12 +117,12 @@ const {
|
|
|
116
117
|
InspectorModule
|
|
117
118
|
} = _reactNative.NativeModules;
|
|
118
119
|
|
|
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
|
|
120
|
+
/**
|
|
121
|
+
* `state:change` payloads can briefly have {@code isNexrad} before {@code nexradSite} / {@code nexradTimestamp}
|
|
122
|
+
* are populated; {@code core.state} is updated first. Merge so readouts match the active radar.
|
|
123
|
+
*
|
|
124
|
+
* @param {object | null} emitted
|
|
125
|
+
* @param {object | null} coreState
|
|
125
126
|
*/
|
|
126
127
|
function mergeNexradEmittedWithCore(emitted, coreState) {
|
|
127
128
|
if (!emitted || !coreState) return null;
|
|
@@ -136,10 +137,10 @@ function mergeNexradEmittedWithCore(emitted, coreState) {
|
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
139
|
|
|
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.
|
|
140
|
+
/**
|
|
141
|
+
* Compact timeline identity for deduping {@code state:change}: extending the NEXRAD/satellite window
|
|
142
|
+
* often keeps the same selected unix — without this, {@link WeatherLayerManager} short-circuits and
|
|
143
|
+
* never calls native {@code sync} / preload with the expanded frame list.
|
|
143
144
|
*/
|
|
144
145
|
function nexradObsTimelineSig(state) {
|
|
145
146
|
const arr = [...(state?.availableNexradTimestamps || [])].map(Number).filter(t => Number.isFinite(t)).sort((a, b) => a - b);
|
|
@@ -180,37 +181,34 @@ function wxGridWarn(tag, detail) {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
|
|
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 -
|
|
184
|
+
/**
|
|
185
|
+
* Native {@code processFrame} must mirror browser/AguaceroCore grid auth: encoded {@code apiKey}
|
|
186
|
+
* in the query string and optional {@code Origin} / {@code Referer} (many CloudFront setups require them).
|
|
187
|
+
*
|
|
188
|
+
* @param {string} baseGridUrl
|
|
189
|
+
* @param {string} resourcePath
|
|
190
|
+
* @param {string} apiKey
|
|
191
|
+
* @param {string | null | undefined} bundleId
|
|
192
|
+
* @param {string | undefined} gridRequestSiteOrigin - prop or core origin (see {@link resolveGridRequestSiteOrigin})
|
|
193
|
+
* @param {import('@aguacerowx/javascript-sdk').AguaceroCore | null | undefined} core
|
|
192
194
|
*/
|
|
193
|
-
function buildGridFrameProcessOptions(baseGridUrl, resourcePath, apiKey, bundleId, gridRequestSiteOrigin) {
|
|
194
|
-
const
|
|
195
|
+
function buildGridFrameProcessOptions(baseGridUrl, resourcePath, apiKey, bundleId, gridRequestSiteOrigin, core) {
|
|
196
|
+
const trimmedKey = typeof apiKey === 'string' ? apiKey.trim() : apiKey;
|
|
197
|
+
const url = `${baseGridUrl}${resourcePath}?apiKey=${encodeURIComponent(trimmedKey || '')}`;
|
|
195
198
|
const options = {
|
|
196
199
|
url,
|
|
197
|
-
apiKey,
|
|
200
|
+
apiKey: trimmedKey,
|
|
198
201
|
bundleId
|
|
199
202
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
origin = origin.slice(0, -1);
|
|
204
|
-
}
|
|
205
|
-
if (origin.length > 0) {
|
|
206
|
-
options.gridRequestSiteOrigin = origin;
|
|
207
|
-
}
|
|
203
|
+
const origin = (0, _gridCdnAuth.resolveGridRequestSiteOrigin)(gridRequestSiteOrigin, core);
|
|
204
|
+
if (origin) {
|
|
205
|
+
options.gridRequestSiteOrigin = origin;
|
|
208
206
|
}
|
|
209
207
|
return options;
|
|
210
208
|
}
|
|
211
209
|
|
|
212
|
-
/**
|
|
213
|
-
* A helper function to generate the raw RGBA byte buffer for the colormap texture.
|
|
210
|
+
/**
|
|
211
|
+
* A helper function to generate the raw RGBA byte buffer for the colormap texture.
|
|
214
212
|
*/
|
|
215
213
|
const _generateColormapBytes = colormap => {
|
|
216
214
|
const width = 256;
|
|
@@ -416,6 +414,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
416
414
|
// Track if we've done the initial load
|
|
417
415
|
const hasInitialLoad = (0, _react.useRef)(false);
|
|
418
416
|
const hasPreloadedRef = (0, _react.useRef)(false);
|
|
417
|
+
/** Bumped on {@code cancelAllFrames} / full reload so stale {@code processFrame} results are ignored. */
|
|
418
|
+
const preloadGenerationRef = (0, _react.useRef)(0);
|
|
419
419
|
|
|
420
420
|
// Track the last state we processed to avoid redundant updates
|
|
421
421
|
const lastProcessedState = (0, _react.useRef)(null);
|
|
@@ -496,9 +496,9 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
496
496
|
refreshData: () => {
|
|
497
497
|
_checkForUpdates();
|
|
498
498
|
},
|
|
499
|
-
/**
|
|
500
|
-
* NWS watches/warnings (native map, iOS + Android): same options as mapsgl {@link WeatherLayerManager#configureWatchesWarnings}.
|
|
501
|
-
* @param {object} partial
|
|
499
|
+
/**
|
|
500
|
+
* NWS watches/warnings (native map, iOS + Android): same options as mapsgl {@link WeatherLayerManager#configureWatchesWarnings}.
|
|
501
|
+
* @param {object} partial
|
|
502
502
|
*/
|
|
503
503
|
configureWatchesWarnings: partial => {
|
|
504
504
|
setWatchesWarningsOptions(prev => ({
|
|
@@ -562,6 +562,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
562
562
|
|
|
563
563
|
// Only mark as "has preloaded" after validation passes
|
|
564
564
|
hasPreloadedRef.current = true;
|
|
565
|
+
const generation = preloadGenerationRef.current;
|
|
566
|
+
const isStaleGeneration = () => generation !== preloadGenerationRef.current;
|
|
565
567
|
wxGridVerbose('preloadStart', {
|
|
566
568
|
isMRMS,
|
|
567
569
|
model,
|
|
@@ -678,7 +680,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
678
680
|
} else {
|
|
679
681
|
resourcePath = `/grids/${model}/${date}/${run}/${currentFrame}/${variable}/0`;
|
|
680
682
|
}
|
|
681
|
-
const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin), core);
|
|
683
|
+
const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
|
|
682
684
|
(0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
|
|
683
685
|
phase: 'preloadCurrent',
|
|
684
686
|
currentCacheKey
|
|
@@ -690,6 +692,13 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
690
692
|
frame: currentFrame
|
|
691
693
|
});
|
|
692
694
|
const result = await WeatherFrameProcessorModule.processFrame(options);
|
|
695
|
+
if (isStaleGeneration()) {
|
|
696
|
+
wxGridVerbose('preloadCurrentFrameStale', {
|
|
697
|
+
currentCacheKey,
|
|
698
|
+
generation
|
|
699
|
+
});
|
|
700
|
+
return;
|
|
701
|
+
}
|
|
693
702
|
if (!result || !result.filePath) {
|
|
694
703
|
hasPreloadedRef.current = false;
|
|
695
704
|
wxGridWarn('preloadAbort', {
|
|
@@ -825,12 +834,15 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
825
834
|
} else {
|
|
826
835
|
resourcePath = `/grids/${model}/${date}/${run}/${frame}/${variable}/0`;
|
|
827
836
|
}
|
|
828
|
-
const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin), core);
|
|
837
|
+
const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
|
|
829
838
|
(0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
|
|
830
839
|
phase: 'preloadBackground',
|
|
831
840
|
cacheKey
|
|
832
841
|
});
|
|
833
842
|
WeatherFrameProcessorModule.processFrame(options).then(result => {
|
|
843
|
+
if (isStaleGeneration()) {
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
834
846
|
if (!result || !result.filePath) {
|
|
835
847
|
return;
|
|
836
848
|
}
|
|
@@ -1218,7 +1230,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
1218
1230
|
m = (frameDate.getUTCMonth() + 1).toString().padStart(2, '0'),
|
|
1219
1231
|
d = frameDate.getUTCDate().toString().padStart(2, '0');
|
|
1220
1232
|
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);
|
|
1233
|
+
const options = (0, _aguaceroRnDebug.augmentProcessFrameOptionsForDebug)(buildGridFrameProcessOptions(core.baseGridUrl, resourcePath, core.apiKey, core.bundleId, gridRequestSiteOrigin, core), core);
|
|
1222
1234
|
(0, _aguaceroCoreDebugHooks.logProcessFrameAuthMismatch)(core, options, {
|
|
1223
1235
|
phase: 'mrmsRefresh',
|
|
1224
1236
|
cacheKey
|
|
@@ -1487,6 +1499,7 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
1487
1499
|
}
|
|
1488
1500
|
}
|
|
1489
1501
|
hasPreloadedRef.current = false;
|
|
1502
|
+
preloadGenerationRef.current += 1;
|
|
1490
1503
|
preloadedDataCache.current.clear();
|
|
1491
1504
|
cachedGeometry.current = null;
|
|
1492
1505
|
cachedColormap.current = null;
|
|
@@ -1494,7 +1507,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
1494
1507
|
WeatherFrameProcessorModule.cancelAllFrames();
|
|
1495
1508
|
wxGridVerbose('cancelAllFrames', {
|
|
1496
1509
|
reason: 'needsFullLoad',
|
|
1497
|
-
variable: newState.variable
|
|
1510
|
+
variable: newState.variable,
|
|
1511
|
+
generation: preloadGenerationRef.current
|
|
1498
1512
|
});
|
|
1499
1513
|
if (!newState.variable) {
|
|
1500
1514
|
previousStateRef.current = newState;
|
|
@@ -1516,6 +1530,8 @@ const WeatherLayerManager = exports.WeatherLayerManager = /*#__PURE__*/(0, _reac
|
|
|
1516
1530
|
mrmsTimestamp: newState.mrmsTimestamp,
|
|
1517
1531
|
forecastHour: newState.forecastHour
|
|
1518
1532
|
});
|
|
1533
|
+
hasPreloadedRef.current = false;
|
|
1534
|
+
void preloadAllFramesToDisk(newState);
|
|
1519
1535
|
}
|
|
1520
1536
|
if (success && newState.opacity !== renderProps.opacity) {
|
|
1521
1537
|
setRenderProps(prev => ({
|