@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.
- package/LICENSE +21 -0
- package/android/src/main/java/com/aguacerowx/reactnative/NexradRadarLayerView.java +14 -2
- package/android/src/main/java/com/aguacerowx/reactnative/WeatherFrameProcessorModule.java +77 -0
- package/index.js +1 -1
- package/ios/WeatherFrameProcessorModule.m +19 -15
- package/ios/WeatherFrameProcessorModule.swift +65 -0
- package/lib/commonjs/AguaceroContext.js +0 -4
- package/lib/commonjs/AguaceroContext.js.map +1 -1
- package/lib/commonjs/GridRenderLayer.js +62 -76
- package/lib/commonjs/GridRenderLayer.js.map +1 -1
- package/lib/commonjs/MapManager.js +110 -224
- package/lib/commonjs/MapManager.js.map +1 -1
- package/lib/commonjs/MapRegistry.js +21 -33
- package/lib/commonjs/MapRegistry.js.map +1 -1
- package/lib/commonjs/NexradRadarLayer.android.js +28 -100
- package/lib/commonjs/NexradRadarLayer.android.js.map +1 -1
- package/lib/commonjs/NexradRadarLayer.ios.js +26 -97
- package/lib/commonjs/NexradRadarLayer.ios.js.map +1 -1
- package/lib/commonjs/NexradSitesMapLayer.js +41 -61
- package/lib/commonjs/NexradSitesMapLayer.js.map +1 -1
- package/lib/commonjs/SatelliteLayer.android.js +26 -38
- package/lib/commonjs/SatelliteLayer.android.js.map +1 -1
- package/lib/commonjs/SatelliteLayer.ios.js +30 -42
- package/lib/commonjs/SatelliteLayer.ios.js.map +1 -1
- package/lib/commonjs/StyleApplicator.js +129 -175
- package/lib/commonjs/StyleApplicator.js.map +1 -1
- package/lib/commonjs/WeatherLayerManager.js +995 -1646
- package/lib/commonjs/WeatherLayerManager.js.map +1 -1
- package/lib/commonjs/aguaceroCoreDebugHooks.js +58 -130
- package/lib/commonjs/aguaceroCoreDebugHooks.js.map +1 -1
- package/lib/commonjs/aguaceroRnDebug.js +147 -288
- package/lib/commonjs/aguaceroRnDebug.js.map +1 -1
- package/lib/commonjs/cdnAuthenticatedFetch.js +104 -0
- package/lib/commonjs/cdnAuthenticatedFetch.js.map +1 -0
- package/lib/commonjs/dispatchViewManagerCommandCompat.js +51 -88
- package/lib/commonjs/dispatchViewManagerCommandCompat.js.map +1 -1
- package/lib/commonjs/gridCdnAuth.js +41 -50
- package/lib/commonjs/gridCdnAuth.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nexrad/nexradAndroidController.js +851 -863
- package/lib/commonjs/nexrad/nexradAndroidController.js.map +1 -1
- package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
- package/lib/commonjs/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
- package/lib/commonjs/nexrad/nexradDiag.js +32 -148
- package/lib/commonjs/nexrad/nexradDiag.js.map +1 -1
- package/lib/commonjs/nexrad/nexradLevel2Keys.js +261 -0
- package/lib/commonjs/nexrad/nexradLevel2Keys.js.map +1 -0
- package/lib/commonjs/nexrad/nexradLutBuild.js +64 -111
- package/lib/commonjs/nexrad/nexradLutBuild.js.map +1 -1
- package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js +136 -164
- package/lib/commonjs/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
- package/lib/commonjs/nexrad/nexradSdkImports.js +51 -0
- package/lib/commonjs/nexrad/nexradSdkImports.js.map +1 -0
- package/lib/commonjs/nexrad/radarArchiveCore.bundled.js +2848 -4455
- package/lib/commonjs/nexrad/radarArchiveCore.bundled.js.map +1 -1
- package/lib/commonjs/nexrad/radarDecode.worker.bundled.js +445 -648
- package/lib/commonjs/nexrad/radarDecode.worker.bundled.js.map +1 -1
- package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js +52 -68
- package/lib/commonjs/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
- package/lib/commonjs/nexradNativeCommandIds.js +24 -0
- package/lib/commonjs/nexradNativeCommandIds.js.map +1 -0
- package/lib/commonjs/nws/NwsAlertsOverlay.android.js.map +1 -1
- package/lib/commonjs/nws/NwsAlertsOverlay.ios.js.map +1 -1
- package/lib/commonjs/nws/NwsAlertsOverlay.js +3 -3
- package/lib/commonjs/nws/NwsAlertsOverlay.js.map +1 -1
- package/lib/commonjs/nws/NwsAlertsOverlay.native.js +235 -361
- package/lib/commonjs/nws/NwsAlertsOverlay.native.js.map +1 -1
- package/lib/commonjs/nws/eventSourceRnPolyfill.js +92 -146
- package/lib/commonjs/nws/eventSourceRnPolyfill.js.map +1 -1
- package/lib/commonjs/nws/nwsAndroidConstants.js +2 -8
- package/lib/commonjs/nws/nwsAndroidConstants.js.map +1 -1
- package/lib/commonjs/satellite/satelliteAndroidController.js +117 -202
- package/lib/commonjs/satellite/satelliteAndroidController.js.map +1 -1
- package/lib/commonjs/satelliteBridgeDiag.js +3 -13
- package/lib/commonjs/satelliteBridgeDiag.js.map +1 -1
- package/lib/commonjs/satelliteRnDebug.js +117 -218
- package/lib/commonjs/satelliteRnDebug.js.map +1 -1
- package/lib/module/AguaceroContext.js +2 -7
- package/lib/module/AguaceroContext.js.map +1 -1
- package/lib/module/GridRenderLayer.js +66 -80
- package/lib/module/GridRenderLayer.js.map +1 -1
- package/lib/module/MapManager.js +125 -239
- package/lib/module/MapManager.js.map +1 -1
- package/lib/module/MapRegistry.js +21 -33
- package/lib/module/MapRegistry.js.map +1 -1
- package/lib/module/NexradRadarLayer.android.js +32 -104
- package/lib/module/NexradRadarLayer.android.js.map +1 -1
- package/lib/module/NexradRadarLayer.ios.js +30 -101
- package/lib/module/NexradRadarLayer.ios.js.map +1 -1
- package/lib/module/NexradSitesMapLayer.js +44 -63
- package/lib/module/NexradSitesMapLayer.js.map +1 -1
- package/lib/module/SatelliteLayer.android.js +32 -44
- package/lib/module/SatelliteLayer.android.js.map +1 -1
- package/lib/module/SatelliteLayer.ios.js +36 -48
- package/lib/module/SatelliteLayer.ios.js.map +1 -1
- package/lib/module/StyleApplicator.js +144 -191
- package/lib/module/StyleApplicator.js.map +1 -1
- package/lib/module/WeatherLayerManager.js +1024 -1675
- package/lib/module/WeatherLayerManager.js.map +1 -1
- package/lib/module/aguaceroCoreDebugHooks.js +59 -130
- package/lib/module/aguaceroCoreDebugHooks.js.map +1 -1
- package/lib/module/aguaceroRnDebug.js +151 -292
- package/lib/module/aguaceroRnDebug.js.map +1 -1
- package/lib/module/cdnAuthenticatedFetch.js +97 -0
- package/lib/module/cdnAuthenticatedFetch.js.map +1 -0
- package/lib/module/dispatchViewManagerCommandCompat.js +52 -90
- package/lib/module/dispatchViewManagerCommandCompat.js.map +1 -1
- package/lib/module/gridCdnAuth.js +38 -50
- package/lib/module/gridCdnAuth.js.map +1 -1
- package/lib/module/index.js +9 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/nexrad/nexradAndroidController.js +865 -876
- package/lib/module/nexrad/nexradAndroidController.js.map +1 -1
- package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +62 -85
- package/lib/module/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js.map +1 -1
- package/lib/module/nexrad/nexradDiag.js +31 -145
- package/lib/module/nexrad/nexradDiag.js.map +1 -1
- package/lib/module/nexrad/nexradLevel2Keys.js +245 -0
- package/lib/module/nexrad/nexradLevel2Keys.js.map +1 -0
- package/lib/module/nexrad/nexradLutBuild.js +64 -110
- package/lib/module/nexrad/nexradLutBuild.js.map +1 -1
- package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js +136 -163
- package/lib/module/nexrad/nexradMapboxFrameOpts.bundled.js.map +1 -1
- package/lib/module/nexrad/nexradSdkImports.js +4 -0
- package/lib/module/nexrad/nexradSdkImports.js.map +1 -0
- package/lib/module/nexrad/radarArchiveCore.bundled.js +2839 -4448
- package/lib/module/nexrad/radarArchiveCore.bundled.js.map +1 -1
- package/lib/module/nexrad/radarDecode.worker.bundled.js +445 -648
- package/lib/module/nexrad/radarDecode.worker.bundled.js.map +1 -1
- package/lib/module/nexrad/radarFrameGpuMatch.bundled.js +50 -66
- package/lib/module/nexrad/radarFrameGpuMatch.bundled.js.map +1 -1
- package/lib/module/nexradNativeCommandIds.js +18 -0
- package/lib/module/nexradNativeCommandIds.js.map +1 -0
- package/lib/module/nws/NwsAlertsOverlay.android.js +1 -1
- package/lib/module/nws/NwsAlertsOverlay.android.js.map +1 -1
- package/lib/module/nws/NwsAlertsOverlay.ios.js +1 -1
- package/lib/module/nws/NwsAlertsOverlay.ios.js.map +1 -1
- package/lib/module/nws/NwsAlertsOverlay.js +5 -5
- package/lib/module/nws/NwsAlertsOverlay.js.map +1 -1
- package/lib/module/nws/NwsAlertsOverlay.native.js +248 -373
- package/lib/module/nws/NwsAlertsOverlay.native.js.map +1 -1
- package/lib/module/nws/eventSourceRnPolyfill.js +92 -146
- package/lib/module/nws/eventSourceRnPolyfill.js.map +1 -1
- package/lib/module/nws/nwsAndroidConstants.js +2 -8
- package/lib/module/nws/nwsAndroidConstants.js.map +1 -1
- package/lib/module/satellite/satelliteAndroidController.js +123 -208
- package/lib/module/satellite/satelliteAndroidController.js.map +1 -1
- package/lib/module/satelliteBridgeDiag.js +3 -13
- package/lib/module/satelliteBridgeDiag.js.map +1 -1
- package/lib/module/satelliteRnDebug.js +123 -223
- package/lib/module/satelliteRnDebug.js.map +1 -1
- package/lib/typescript/AguaceroContext.d.ts +0 -4
- package/lib/typescript/AguaceroContext.d.ts.map +1 -1
- package/lib/typescript/GridRenderLayer.d.ts.map +1 -1
- package/lib/typescript/MapManager.d.ts +0 -12
- package/lib/typescript/MapManager.d.ts.map +1 -1
- package/lib/typescript/MapRegistry.d.ts +10 -12
- package/lib/typescript/MapRegistry.d.ts.map +1 -1
- package/lib/typescript/NexradRadarLayer.android.d.ts.map +1 -1
- package/lib/typescript/NexradRadarLayer.ios.d.ts.map +1 -1
- package/lib/typescript/NexradSitesMapLayer.d.ts +4 -10
- package/lib/typescript/NexradSitesMapLayer.d.ts.map +1 -1
- package/lib/typescript/SatelliteLayer.android.d.ts.map +1 -1
- package/lib/typescript/SatelliteLayer.ios.d.ts.map +1 -1
- package/lib/typescript/StyleApplicator.d.ts +1 -1
- package/lib/typescript/StyleApplicator.d.ts.map +1 -1
- package/lib/typescript/WeatherLayerManager.d.ts.map +1 -1
- package/lib/typescript/aguaceroCoreDebugHooks.d.ts +2 -9
- package/lib/typescript/aguaceroCoreDebugHooks.d.ts.map +1 -1
- package/lib/typescript/aguaceroRnDebug.d.ts +47 -66
- package/lib/typescript/aguaceroRnDebug.d.ts.map +1 -1
- package/lib/typescript/cdnAuthenticatedFetch.d.ts +10 -0
- package/lib/typescript/cdnAuthenticatedFetch.d.ts.map +1 -0
- package/lib/typescript/dispatchViewManagerCommandCompat.d.ts +1 -17
- package/lib/typescript/dispatchViewManagerCommandCompat.d.ts.map +1 -1
- package/lib/typescript/gridCdnAuth.d.ts +16 -21
- package/lib/typescript/gridCdnAuth.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/nexrad/nexradAndroidController.d.ts +39 -89
- package/lib/typescript/nexrad/nexradAndroidController.d.ts.map +1 -1
- package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts +2 -1
- package/lib/typescript/nexrad/nexradCrossSectionSampleAtLatLon.bundled.d.ts.map +1 -1
- package/lib/typescript/nexrad/nexradDiag.d.ts +13 -101
- package/lib/typescript/nexrad/nexradDiag.d.ts.map +1 -1
- package/lib/typescript/nexrad/nexradLevel2Keys.d.ts +36 -0
- package/lib/typescript/nexrad/nexradLevel2Keys.d.ts.map +1 -0
- package/lib/typescript/nexrad/nexradLutBuild.d.ts +3 -10
- package/lib/typescript/nexrad/nexradLutBuild.d.ts.map +1 -1
- package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts +4 -3
- package/lib/typescript/nexrad/nexradMapboxFrameOpts.bundled.d.ts.map +1 -1
- package/lib/typescript/nexrad/nexradSdkImports.d.ts +2 -0
- package/lib/typescript/nexrad/nexradSdkImports.d.ts.map +1 -0
- package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts +12 -7
- package/lib/typescript/nexrad/radarArchiveCore.bundled.d.ts.map +1 -1
- package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts +20 -20
- package/lib/typescript/nexrad/radarDecode.worker.bundled.d.ts.map +1 -1
- package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts +4 -3
- package/lib/typescript/nexrad/radarFrameGpuMatch.bundled.d.ts.map +1 -1
- package/lib/typescript/nexradNativeCommandIds.d.ts +2 -0
- package/lib/typescript/nexradNativeCommandIds.d.ts.map +1 -0
- package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts +6 -17
- package/lib/typescript/nws/NwsAlertsOverlay.native.d.ts.map +1 -1
- package/lib/typescript/nws/eventSourceRnPolyfill.d.ts +0 -3
- package/lib/typescript/nws/eventSourceRnPolyfill.d.ts.map +1 -1
- package/lib/typescript/nws/nwsAndroidConstants.d.ts +0 -5
- package/lib/typescript/nws/nwsAndroidConstants.d.ts.map +1 -1
- package/lib/typescript/satellite/satelliteAndroidController.d.ts +9 -47
- package/lib/typescript/satellite/satelliteAndroidController.d.ts.map +1 -1
- package/lib/typescript/satelliteBridgeDiag.d.ts +1 -5
- package/lib/typescript/satelliteBridgeDiag.d.ts.map +1 -1
- package/lib/typescript/satelliteRnDebug.d.ts +24 -30
- package/lib/typescript/satelliteRnDebug.d.ts.map +1 -1
- package/package.json +75 -74
- package/src/AguaceroContext.js +1 -7
- package/src/GridRenderLayer.js +1 -128
- package/src/MapManager.js +1 -277
- package/src/MapRegistry.js +1 -56
- package/src/NexradRadarLayer.android.js +1 -121
- package/src/NexradRadarLayer.ios.js +1 -115
- package/src/NexradSitesMapLayer.js +1 -75
- package/src/SatelliteLayer.android.js +1 -63
- package/src/SatelliteLayer.ios.js +1 -70
- package/src/StyleApplicator.js +1 -241
- package/src/WeatherLayerManager.js +1 -2045
- package/src/aguaceroCoreDebugHooks.js +1 -142
- package/src/aguaceroRnDebug.js +1 -336
- package/src/cdnAuthenticatedFetch.js +1 -0
- package/src/dispatchViewManagerCommandCompat.js +1 -100
- package/src/gridCdnAuth.js +1 -56
- package/src/index.js +1 -27
- package/src/nexrad/nexradAndroidController.js +1 -1078
- package/src/nexrad/nexradCrossSectionSampleAtLatLon.bundled.js +1 -91
- package/src/nexrad/nexradDiag.js +1 -150
- package/src/nexrad/nexradLevel2Keys.js +1 -0
- package/src/nexrad/nexradLutBuild.js +1 -126
- package/src/nexrad/nexradMapboxFrameOpts.bundled.js +1 -245
- package/src/nexrad/nexradSdkImports.js +1 -0
- package/src/nexrad/radarArchiveCore.bundled.js +1 -7085
- package/src/nexrad/radarDecode.worker.bundled.js +1 -813
- package/src/nexrad/radarFrameGpuMatch.bundled.js +1 -79
- package/src/nexradNativeCommandIds.js +1 -0
- package/src/nws/NwsAlertsOverlay.android.js +1 -1
- package/src/nws/NwsAlertsOverlay.ios.js +1 -1
- package/src/nws/NwsAlertsOverlay.js +1 -7
- package/src/nws/NwsAlertsOverlay.native.js +1 -463
- package/src/nws/eventSourceRnPolyfill.js +7 -193
- package/src/nws/nwsAndroidConstants.js +1 -8
- package/src/satellite/satelliteAndroidController.js +1 -257
- package/src/satelliteBridgeDiag.js +1 -15
- package/src/satelliteRnDebug.js +1 -269
- package/lib/commonjs/nexrad/nexradNativeCommandIds.js +0 -51
- package/lib/commonjs/nexrad/nexradNativeCommandIds.js.map +0 -1
- package/lib/module/nexrad/nexradNativeCommandIds.js +0 -44
- package/lib/module/nexrad/nexradNativeCommandIds.js.map +0 -1
- package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts +0 -9
- package/lib/typescript/nexrad/nexradNativeCommandIds.d.ts.map +0 -1
- package/src/nexrad/nexradNativeCommandIds.js +0 -44
- /package/lib/commonjs/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
- /package/lib/module/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
- /package/src/{nexrad/nexradSitesUs.json → nexradSitesUs.json} +0 -0
package/src/GridRenderLayer.js
CHANGED
|
@@ -1,128 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import React, { useRef, useImperativeHandle, forwardRef } from 'react';
|
|
4
|
-
import { UIManager, findNodeHandle, StyleSheet } from 'react-native';
|
|
5
|
-
import GridRenderView from './GridRenderLayerNativeComponent';
|
|
6
|
-
|
|
7
|
-
const NATIVE_COMPONENT_NAME = 'GridRenderLayer';
|
|
8
|
-
|
|
9
|
-
export const GridRenderLayer = forwardRef((props, ref) => {
|
|
10
|
-
const nativeRef = useRef(null);
|
|
11
|
-
|
|
12
|
-
const getCommandId = (commandName) => {
|
|
13
|
-
try {
|
|
14
|
-
const config = UIManager.getViewManagerConfig(NATIVE_COMPONENT_NAME);
|
|
15
|
-
return config?.Commands?.[commandName] ?? null;
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
useImperativeHandle(ref, () => ({
|
|
22
|
-
updateGeometry: (corners, gridDef) => {
|
|
23
|
-
if (!nativeRef.current) return;
|
|
24
|
-
const commandId = getCommandId('updateGeometry');
|
|
25
|
-
if (commandId == null) return;
|
|
26
|
-
const handle = findNodeHandle(nativeRef.current);
|
|
27
|
-
UIManager.dispatchViewManagerCommand(handle, commandId, [corners, gridDef]);
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
setVariable: (variableName) => {
|
|
31
|
-
if (!nativeRef.current) return;
|
|
32
|
-
const commandId = getCommandId('setVariable');
|
|
33
|
-
if (commandId == null) return;
|
|
34
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, [variableName]);
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
updateDataTextureFromFile: (filePath, nx, ny, scale, offset, missing, scaleType) => {
|
|
38
|
-
if (!nativeRef.current) return;
|
|
39
|
-
const commandId = getCommandId('updateDataTexture');
|
|
40
|
-
if (commandId == null) return;
|
|
41
|
-
UIManager.dispatchViewManagerCommand(
|
|
42
|
-
findNodeHandle(nativeRef.current),
|
|
43
|
-
commandId,
|
|
44
|
-
[filePath, Number(nx), Number(ny), Number(scale), Number(offset), Number(missing), scaleType || 'linear'],
|
|
45
|
-
);
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
updateDataTexture: (base64Data, nx, ny, scale, offset, missing, scaleType) => {
|
|
49
|
-
if (!nativeRef.current) return;
|
|
50
|
-
const commandId = getCommandId('updateDataTexture');
|
|
51
|
-
if (commandId == null) return;
|
|
52
|
-
UIManager.dispatchViewManagerCommand(
|
|
53
|
-
findNodeHandle(nativeRef.current),
|
|
54
|
-
commandId,
|
|
55
|
-
[base64Data, Number(nx), Number(ny), Number(scale), Number(offset), Number(missing), scaleType || 'linear'],
|
|
56
|
-
);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
updateColormapTexture: (colormapArray) => {
|
|
60
|
-
if (!nativeRef.current) return;
|
|
61
|
-
const commandId = getCommandId('updateColormapTexture');
|
|
62
|
-
if (commandId == null) return;
|
|
63
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, [colormapArray]);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
updateDataParameters: (scale, offset, missing, scaleType) => {
|
|
67
|
-
if (!nativeRef.current) return;
|
|
68
|
-
const commandId = getCommandId('updateDataParameters');
|
|
69
|
-
if (commandId == null) return;
|
|
70
|
-
UIManager.dispatchViewManagerCommand(
|
|
71
|
-
findNodeHandle(nativeRef.current),
|
|
72
|
-
commandId,
|
|
73
|
-
[Number(scale), Number(offset), Number(missing), Number(scaleType)],
|
|
74
|
-
);
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
setSmoothing: (enabled) => {
|
|
78
|
-
if (!nativeRef.current) return;
|
|
79
|
-
nativeRef.current.setNativeProps({ smoothing: enabled });
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
clear: () => {
|
|
83
|
-
if (!nativeRef.current) return;
|
|
84
|
-
const commandId = getCommandId('clear');
|
|
85
|
-
if (commandId == null) return;
|
|
86
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, []);
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
primeGpuCache: (frameInfo) => {
|
|
90
|
-
if (!nativeRef.current) return;
|
|
91
|
-
const commandId = getCommandId('primeGpuCache');
|
|
92
|
-
if (commandId == null) return;
|
|
93
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, [frameInfo]);
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
setActiveFrame: (cacheKey) => {
|
|
97
|
-
if (!nativeRef.current) return;
|
|
98
|
-
const commandId = getCommandId('setActiveFrame');
|
|
99
|
-
if (commandId == null) return;
|
|
100
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, [cacheKey]);
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
clearGpuCache: () => {
|
|
104
|
-
if (!nativeRef.current) return;
|
|
105
|
-
const commandId = getCommandId('clearGpuCache');
|
|
106
|
-
if (commandId == null) return;
|
|
107
|
-
UIManager.dispatchViewManagerCommand(findNodeHandle(nativeRef.current), commandId, []);
|
|
108
|
-
},
|
|
109
|
-
}));
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<GridRenderView
|
|
113
|
-
ref={nativeRef}
|
|
114
|
-
opacity={props.opacity}
|
|
115
|
-
dataRange={props.dataRange}
|
|
116
|
-
belowID={props.belowID}
|
|
117
|
-
smoothing={true}
|
|
118
|
-
style={styles.overlay}
|
|
119
|
-
pointerEvents="none"
|
|
120
|
-
/>
|
|
121
|
-
);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const styles = StyleSheet.create({
|
|
125
|
-
overlay: {
|
|
126
|
-
...StyleSheet.absoluteFillObject,
|
|
127
|
-
},
|
|
128
|
-
});
|
|
1
|
+
import f,{useRef as g,useImperativeHandle as h,forwardRef as C}from"react";import{UIManager as a,findNodeHandle as u,StyleSheet as p}from"react-native";import N from"./GridRenderLayerNativeComponent";const w="GridRenderLayer";export const GridRenderLayer=C((l,b)=>{const r=g(null),n=e=>{try{return a.getViewManagerConfig(w)?.Commands?.[e]??null}catch{return null}};return h(b,()=>({updateGeometry:(e,t)=>{if(!r.current)return;const c=n("updateGeometry");if(c==null)return;const o=u(r.current);a.dispatchViewManagerCommand(o,c,[e,t])},setVariable:e=>{if(!r.current)return;const t=n("setVariable");t!=null&&a.dispatchViewManagerCommand(u(r.current),t,[e])},updateDataTextureFromFile:(e,t,c,o,m,s,d)=>{if(!r.current)return;const i=n("updateDataTexture");i!=null&&a.dispatchViewManagerCommand(u(r.current),i,[e,Number(t),Number(c),Number(o),Number(m),Number(s),d||"linear"])},updateDataTexture:(e,t,c,o,m,s,d)=>{if(!r.current)return;const i=n("updateDataTexture");i!=null&&a.dispatchViewManagerCommand(u(r.current),i,[e,Number(t),Number(c),Number(o),Number(m),Number(s),d||"linear"])},updateColormapTexture:e=>{if(!r.current)return;const t=n("updateColormapTexture");t!=null&&a.dispatchViewManagerCommand(u(r.current),t,[e])},updateDataParameters:(e,t,c,o)=>{if(!r.current)return;const m=n("updateDataParameters");m!=null&&a.dispatchViewManagerCommand(u(r.current),m,[Number(e),Number(t),Number(c),Number(o)])},setSmoothing:e=>{r.current&&r.current.setNativeProps({smoothing:e})},clear:()=>{if(!r.current)return;const e=n("clear");e!=null&&a.dispatchViewManagerCommand(u(r.current),e,[])},primeGpuCache:e=>{if(!r.current)return;const t=n("primeGpuCache");t!=null&&a.dispatchViewManagerCommand(u(r.current),t,[e])},setActiveFrame:e=>{if(!r.current)return;const t=n("setActiveFrame");t!=null&&a.dispatchViewManagerCommand(u(r.current),t,[e])},clearGpuCache:()=>{if(!r.current)return;const e=n("clearGpuCache");e!=null&&a.dispatchViewManagerCommand(u(r.current),e,[])}})),f.createElement(N,{ref:r,opacity:l.opacity,dataRange:l.dataRange,belowID:l.belowID,smoothing:!0,style:V.overlay,pointerEvents:"none"})});const V=p.create({overlay:{...p.absoluteFillObject}});
|
package/src/MapManager.js
CHANGED
|
@@ -1,277 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import React, { useMemo, useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react';
|
|
4
|
-
import { View, StyleSheet, Text } from 'react-native';
|
|
5
|
-
import Mapbox from '@rnmapbox/maps';
|
|
6
|
-
import { THEME_CONFIGS } from '@aguacerowx/javascript-sdk';
|
|
7
|
-
import { StyleApplicator } from './StyleApplicator';
|
|
8
|
-
import { AguaceroContext } from './AguaceroContext';
|
|
9
|
-
import { mapRegistry } from './MapRegistry';
|
|
10
|
-
|
|
11
|
-
const BASE_STYLE_URL = 'mapbox://styles/aguacerowx/cmfvox8mq004u01qm5nlg7qkt';
|
|
12
|
-
|
|
13
|
-
// --- UTILITIES ---
|
|
14
|
-
function isObject(item) {
|
|
15
|
-
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function deepMerge(target, source) {
|
|
19
|
-
const output = { ...target };
|
|
20
|
-
if (isObject(target) && isObject(source)) {
|
|
21
|
-
Object.keys(source).forEach(key => {
|
|
22
|
-
if (isObject(source[key])) {
|
|
23
|
-
if (!(key in target)) {
|
|
24
|
-
Object.assign(output, { [key]: source[key] });
|
|
25
|
-
} else {
|
|
26
|
-
output[key] = deepMerge(target[key], source[key]);
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
Object.assign(output, { [key]: source[key] });
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return output;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @param {object} props
|
|
38
|
-
* @param {string} props.mapboxToken
|
|
39
|
-
* @param {object} [props.customStyles]
|
|
40
|
-
* @param {'light'|'dark'} [props.theme]
|
|
41
|
-
* @param {object} [props.mapOptions] - `style` / `styleURL` / `styleUrl` set the map style when no top-level custom style pair is used (mapsgl parity).
|
|
42
|
-
* @param {string} [props.styleURL] - Custom Mapbox style URL (alias: `styleUrl`).
|
|
43
|
-
* @param {string} [props.styleUrl]
|
|
44
|
-
* @param {string} [props.belowID] - Style layer id to insert Aguacero weather **below** (alias: `weatherBeforeLayerId`). With `styleURL`, required for correct stacking; may be set alone to override the default `AML_-_terrain` anchor on the default style.
|
|
45
|
-
* @param {string} [props.weatherBeforeLayerId]
|
|
46
|
-
* @param {import('react').ReactNode} [props.children] - Render inside Mapbox.MapView; use for WeatherLayerManager so map sources (e.g. NEXRAD site circles) register on the map.
|
|
47
|
-
*/
|
|
48
|
-
export const MapManager = forwardRef(({
|
|
49
|
-
mapboxToken,
|
|
50
|
-
customStyles,
|
|
51
|
-
theme = 'light',
|
|
52
|
-
mapOptions = {},
|
|
53
|
-
styleURL: styleURLProp,
|
|
54
|
-
styleUrl: styleUrlProp,
|
|
55
|
-
belowID: belowIDProp,
|
|
56
|
-
weatherBeforeLayerId: weatherBeforeLayerIdProp,
|
|
57
|
-
children,
|
|
58
|
-
}, ref) => {
|
|
59
|
-
const mapRef = useRef(null);
|
|
60
|
-
const cameraRef = useRef(null);
|
|
61
|
-
const [mapStyle, setMapStyle] = useState(null);
|
|
62
|
-
|
|
63
|
-
const { resolvedStyleURL, weatherBeforeLayerId } = useMemo(() => {
|
|
64
|
-
const mo = mapOptions || {};
|
|
65
|
-
let resolved = BASE_STYLE_URL;
|
|
66
|
-
if (mo.style !== undefined) {
|
|
67
|
-
resolved = mo.style;
|
|
68
|
-
} else if (mo.styleURL !== undefined) {
|
|
69
|
-
resolved = mo.styleURL;
|
|
70
|
-
} else if (mo.styleUrl !== undefined) {
|
|
71
|
-
resolved = mo.styleUrl;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let anchor = null;
|
|
75
|
-
const customStyleUrl = styleURLProp || styleUrlProp;
|
|
76
|
-
const customBeforeId = belowIDProp || weatherBeforeLayerIdProp;
|
|
77
|
-
if (customStyleUrl) {
|
|
78
|
-
if (customBeforeId && String(customBeforeId).trim()) {
|
|
79
|
-
resolved = customStyleUrl;
|
|
80
|
-
anchor = String(customBeforeId).trim();
|
|
81
|
-
} else if (mo.style === undefined && mo.styleURL === undefined && mo.styleUrl === undefined) {
|
|
82
|
-
resolved = BASE_STYLE_URL;
|
|
83
|
-
}
|
|
84
|
-
} else if (customBeforeId && String(customBeforeId).trim()) {
|
|
85
|
-
anchor = String(customBeforeId).trim();
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return { resolvedStyleURL: resolved, weatherBeforeLayerId: anchor };
|
|
89
|
-
}, [mapOptions, styleURLProp, styleUrlProp, belowIDProp, weatherBeforeLayerIdProp]);
|
|
90
|
-
|
|
91
|
-
// Expose camera and map methods via ref
|
|
92
|
-
useImperativeHandle(ref, () => ({
|
|
93
|
-
// Camera methods
|
|
94
|
-
flyTo: (config) => {
|
|
95
|
-
if (cameraRef.current) {
|
|
96
|
-
cameraRef.current.flyTo(config);
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
moveTo: (config) => {
|
|
100
|
-
if (cameraRef.current) {
|
|
101
|
-
cameraRef.current.moveTo(config);
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
zoomTo: (zoomLevel, duration = 2000) => {
|
|
105
|
-
if (cameraRef.current) {
|
|
106
|
-
cameraRef.current.zoomTo(zoomLevel, duration);
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
setCamera: (config) => {
|
|
110
|
-
if (cameraRef.current) {
|
|
111
|
-
cameraRef.current.setCamera(config);
|
|
112
|
-
}
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// Map methods
|
|
116
|
-
getCenter: async () => {
|
|
117
|
-
if (mapRef.current) {
|
|
118
|
-
return await mapRef.current.getCenter();
|
|
119
|
-
}
|
|
120
|
-
return null;
|
|
121
|
-
},
|
|
122
|
-
getZoom: async () => {
|
|
123
|
-
if (mapRef.current) {
|
|
124
|
-
return await mapRef.current.getZoom();
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
},
|
|
128
|
-
getCoordinateFromView: async (point) => {
|
|
129
|
-
if (mapRef.current) {
|
|
130
|
-
return await mapRef.current.getCoordinateFromView(point);
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
},
|
|
134
|
-
getPointInView: async (coordinate) => {
|
|
135
|
-
if (mapRef.current) {
|
|
136
|
-
return await mapRef.current.getPointInView(coordinate);
|
|
137
|
-
}
|
|
138
|
-
return null;
|
|
139
|
-
},
|
|
140
|
-
queryRenderedFeaturesAtPoint: async (point, filter, layerIds) => {
|
|
141
|
-
if (mapRef.current) {
|
|
142
|
-
return await mapRef.current.queryRenderedFeaturesAtPoint(point, filter, layerIds);
|
|
143
|
-
}
|
|
144
|
-
return null;
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
// Direct access to refs (for advanced use cases)
|
|
148
|
-
getMapRef: () => mapRef.current,
|
|
149
|
-
getCameraRef: () => cameraRef.current,
|
|
150
|
-
}), []);
|
|
151
|
-
|
|
152
|
-
// Register map with the global registry when it's ready
|
|
153
|
-
useEffect(() => {
|
|
154
|
-
if (mapRef.current) {
|
|
155
|
-
mapRegistry.setMap(mapRef.current);
|
|
156
|
-
}
|
|
157
|
-
}, []);
|
|
158
|
-
|
|
159
|
-
const contextValue = useMemo(() => ({
|
|
160
|
-
getMap: () => mapRef.current,
|
|
161
|
-
getCenter: () => {
|
|
162
|
-
return mapRef.current?._currentCenter || [-95.7129, 37.0902];
|
|
163
|
-
},
|
|
164
|
-
/** @type {string | null} Null with default Aguacero style — use `AML_-_terrain` for weather insert (see WeatherLayerManager). */
|
|
165
|
-
weatherBeforeLayerId,
|
|
166
|
-
resolvedStyleURL,
|
|
167
|
-
}), [weatherBeforeLayerId, resolvedStyleURL]);
|
|
168
|
-
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
let lightTheme = JSON.parse(JSON.stringify(THEME_CONFIGS.light));
|
|
171
|
-
let darkTheme = JSON.parse(JSON.stringify(THEME_CONFIGS.dark));
|
|
172
|
-
|
|
173
|
-
if (customStyles) {
|
|
174
|
-
if (customStyles.light) {
|
|
175
|
-
lightTheme = deepMerge(lightTheme, customStyles.light);
|
|
176
|
-
}
|
|
177
|
-
if (customStyles.dark) {
|
|
178
|
-
darkTheme = deepMerge(darkTheme, customStyles.dark);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
setMapStyle(theme === 'dark' ? darkTheme : lightTheme);
|
|
183
|
-
}, [customStyles, theme]);
|
|
184
|
-
|
|
185
|
-
useEffect(() => {
|
|
186
|
-
if (mapboxToken) {
|
|
187
|
-
Mapbox.setAccessToken(mapboxToken);
|
|
188
|
-
}
|
|
189
|
-
}, [mapboxToken]);
|
|
190
|
-
|
|
191
|
-
if (!mapboxToken) {
|
|
192
|
-
return (
|
|
193
|
-
<View style={[styles.container, styles.centerContent]}>
|
|
194
|
-
<Text style={styles.errorText}>Mapbox Token Missing</Text>
|
|
195
|
-
<Text style={styles.errorSubText}>Please provide the 'mapboxToken' prop.</Text>
|
|
196
|
-
</View>
|
|
197
|
-
);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const handleCameraChange = (event) => {
|
|
201
|
-
if (event?.properties?.center) {
|
|
202
|
-
const center = event.properties.center;
|
|
203
|
-
|
|
204
|
-
// Store the current center in the ref for immediate access
|
|
205
|
-
if (mapRef.current) {
|
|
206
|
-
mapRef.current._currentCenter = center;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
mapRegistry.notifyCameraChange(center);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
const handleMapPress = (payload) => {
|
|
214
|
-
mapRegistry.notifyMapPress(payload);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
return (
|
|
218
|
-
<View style={styles.container}>
|
|
219
|
-
<AguaceroContext.Provider value={contextValue}>
|
|
220
|
-
<Mapbox.MapView
|
|
221
|
-
ref={mapRef}
|
|
222
|
-
style={styles.map}
|
|
223
|
-
styleURL={resolvedStyleURL}
|
|
224
|
-
scaleBarEnabled={false}
|
|
225
|
-
onCameraChanged={handleCameraChange}
|
|
226
|
-
onPress={handleMapPress}
|
|
227
|
-
>
|
|
228
|
-
<Mapbox.Camera
|
|
229
|
-
ref={cameraRef}
|
|
230
|
-
defaultSettings={{
|
|
231
|
-
centerCoordinate: mapOptions.center || [-15.7129, 37.0902],
|
|
232
|
-
zoomLevel: mapOptions.zoom || 0,
|
|
233
|
-
pitch: mapOptions.pitch || 0,
|
|
234
|
-
bearing: mapOptions.bearing || 0,
|
|
235
|
-
minZoomLevel: mapOptions.minZoom || 2,
|
|
236
|
-
maxZoomLevel: mapOptions.maxZoom || 12,
|
|
237
|
-
}}
|
|
238
|
-
/>
|
|
239
|
-
|
|
240
|
-
{mapStyle && <StyleApplicator styles={mapStyle} />}
|
|
241
|
-
|
|
242
|
-
<Mapbox.VectorSource id="mapbox-dem" url="mapbox://mapbox.mapbox-terrain-dem-v1"/>
|
|
243
|
-
{children}
|
|
244
|
-
</Mapbox.MapView>
|
|
245
|
-
</AguaceroContext.Provider>
|
|
246
|
-
</View>
|
|
247
|
-
);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const styles = StyleSheet.create({
|
|
251
|
-
/**
|
|
252
|
-
* Full-bleed positioning so RNMapbox/Mapbox gets non-zero bounds on the first layout pass.
|
|
253
|
-
* A plain flex:1 sibling tree (e.g. map + absolute overlays under Expo Tabs) can still yield
|
|
254
|
-
* a transient 0×0 MapView, which triggers maps-core "Invalid size … fall back to {64, 64}".
|
|
255
|
-
*/
|
|
256
|
-
container: {
|
|
257
|
-
...StyleSheet.absoluteFillObject,
|
|
258
|
-
backgroundColor: '#1a1a2e',
|
|
259
|
-
},
|
|
260
|
-
centerContent: {
|
|
261
|
-
justifyContent: 'center',
|
|
262
|
-
alignItems: 'center',
|
|
263
|
-
},
|
|
264
|
-
map: {
|
|
265
|
-
...StyleSheet.absoluteFillObject,
|
|
266
|
-
},
|
|
267
|
-
errorText: {
|
|
268
|
-
color: '#FF6B6B',
|
|
269
|
-
fontSize: 22,
|
|
270
|
-
fontWeight: 'bold',
|
|
271
|
-
},
|
|
272
|
-
errorSubText: {
|
|
273
|
-
color: 'white',
|
|
274
|
-
fontSize: 16,
|
|
275
|
-
marginTop: 8,
|
|
276
|
-
}
|
|
277
|
-
});
|
|
1
|
+
import l,{useMemo as E,useEffect as g,useState as V,useRef as R,forwardRef as z,useImperativeHandle as Z}from"react";import{View as U,StyleSheet as f,Text as M}from"react-native";import y from"@rnmapbox/maps";import{THEME_CONFIGS as k}from"@aguacerowx/javascript-sdk";import{StyleApplicator as q}from"./StyleApplicator";import{AguaceroContext as N}from"./AguaceroContext";import{mapRegistry as d}from"./MapRegistry";const O="mapbox://styles/aguacerowx/cmfvox8mq004u01qm5nlg7qkt";function b(o){return o&&typeof o=="object"&&!Array.isArray(o)}function C(o,a){const c={...o};return b(o)&&b(a)&&Object.keys(a).forEach(t=>{b(a[t])?t in o?c[t]=C(o[t],a[t]):Object.assign(c,{[t]:a[t]}):Object.assign(c,{[t]:a[t]})}),c}export const MapManager=z(({mapboxToken:o,customStyles:a,theme:c="light",mapOptions:t={},styleURL:S,styleUrl:v,belowID:h,weatherBeforeLayerId:w,children:F},I)=>{const r=R(null),s=R(null),[x,P]=V(null),{resolvedStyleURL:p,weatherBeforeLayerId:T}=E(()=>{const e=t||{};let n=O;e.style!==void 0?n=e.style:e.styleURL!==void 0?n=e.styleURL:e.styleUrl!==void 0&&(n=e.styleUrl);let u=null;const L=S||v,i=h||w;return L?i&&String(i).trim()?(n=L,u=String(i).trim()):e.style===void 0&&e.styleURL===void 0&&e.styleUrl===void 0&&(n=O):i&&String(i).trim()&&(u=String(i).trim()),{resolvedStyleURL:n,weatherBeforeLayerId:u}},[t,S,v,h,w]);Z(I,()=>({flyTo:e=>{s.current&&s.current.flyTo(e)},moveTo:e=>{s.current&&s.current.moveTo(e)},zoomTo:(e,n=2e3)=>{s.current&&s.current.zoomTo(e,n)},setCamera:e=>{s.current&&s.current.setCamera(e)},getCenter:async()=>r.current?await r.current.getCenter():null,getZoom:async()=>r.current?await r.current.getZoom():null,getCoordinateFromView:async e=>r.current?await r.current.getCoordinateFromView(e):null,getPointInView:async e=>r.current?await r.current.getPointInView(e):null,queryRenderedFeaturesAtPoint:async(e,n,u)=>r.current?await r.current.queryRenderedFeaturesAtPoint(e,n,u):null,getMapRef:()=>r.current,getCameraRef:()=>s.current}),[]),g(()=>{r.current&&d.setMap(r.current)},[]);const j=E(()=>({getMap:()=>r.current,getCenter:()=>r.current?._currentCenter||[-95.7129,37.0902],weatherBeforeLayerId:T,resolvedStyleURL:p}),[T,p]);if(g(()=>{let e=JSON.parse(JSON.stringify(k.light)),n=JSON.parse(JSON.stringify(k.dark));a&&(a.light&&(e=C(e,a.light)),a.dark&&(n=C(n,a.dark))),P(c==="dark"?n:e)},[a,c]),g(()=>{o&&y.setAccessToken(o)},[o]),!o)return l.createElement(U,{style:[m.container,m.centerContent]},l.createElement(M,{style:m.errorText},"Mapbox Token Missing"),l.createElement(M,{style:m.errorSubText},"Please provide the 'mapboxToken' prop."));const A=e=>{if(e?.properties?.center){const n=e.properties.center;r.current&&(r.current._currentCenter=n),d.notifyCameraChange(n)}},B=e=>{d.notifyMapPress(e)};return l.createElement(U,{style:m.container},l.createElement(N.Provider,{value:j},l.createElement(y.MapView,{ref:r,style:m.map,styleURL:p,scaleBarEnabled:!1,onCameraChanged:A,onPress:B},l.createElement(y.Camera,{ref:s,defaultSettings:{centerCoordinate:t.center||[-15.7129,37.0902],zoomLevel:t.zoom||0,pitch:t.pitch||0,bearing:t.bearing||0,minZoomLevel:t.minZoom||2,maxZoomLevel:t.maxZoom||12}}),x&&l.createElement(q,{styles:x}),l.createElement(y.VectorSource,{id:"mapbox-dem",url:"mapbox://mapbox.mapbox-terrain-dem-v1"}),F)))});const m=f.create({container:{...f.absoluteFillObject,backgroundColor:"#1a1a2e"},centerContent:{justifyContent:"center",alignItems:"center"},map:{...f.absoluteFillObject},errorText:{color:"#FF6B6B",fontSize:22,fontWeight:"bold"},errorSubText:{color:"white",fontSize:16,marginTop:8}});
|
package/src/MapRegistry.js
CHANGED
|
@@ -1,56 +1 @@
|
|
|
1
|
-
|
|
2
|
-
class MapRegistry {
|
|
3
|
-
constructor() {
|
|
4
|
-
this.mapRef = null;
|
|
5
|
-
this.listeners = [];
|
|
6
|
-
/** @type {((payload: unknown) => void)[]} */
|
|
7
|
-
this.pressListeners = [];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
setMap(mapRef) {
|
|
11
|
-
this.mapRef = mapRef;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
getMap() {
|
|
15
|
-
return this.mapRef;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
addCameraListener(listener) {
|
|
19
|
-
this.listeners.push(listener);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
removeCameraListener(listener) {
|
|
23
|
-
const index = this.listeners.indexOf(listener);
|
|
24
|
-
if (index > -1) {
|
|
25
|
-
this.listeners.splice(index, 1);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
notifyCameraChange(center) {
|
|
30
|
-
this.listeners.forEach(listener => listener(center));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
addPressListener(listener) {
|
|
34
|
-
this.pressListeners.push(listener);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
removePressListener(listener) {
|
|
38
|
-
const index = this.pressListeners.indexOf(listener);
|
|
39
|
-
if (index > -1) {
|
|
40
|
-
this.pressListeners.splice(index, 1);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/** @param {unknown} payload - `@rnmapbox/maps` map press payload */
|
|
45
|
-
notifyMapPress(payload) {
|
|
46
|
-
this.pressListeners.forEach((listener) => {
|
|
47
|
-
try {
|
|
48
|
-
listener(payload);
|
|
49
|
-
} catch {
|
|
50
|
-
/* ignore */
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const mapRegistry = new MapRegistry();
|
|
1
|
+
class t{constructor(){this.mapRef=null,this.listeners=[],this.pressListeners=[]}setMap(s){this.mapRef=s}getMap(){return this.mapRef}addCameraListener(s){this.listeners.push(s)}removeCameraListener(s){const e=this.listeners.indexOf(s);e>-1&&this.listeners.splice(e,1)}notifyCameraChange(s){this.listeners.forEach(e=>e(s))}addPressListener(s){this.pressListeners.push(s)}removePressListener(s){const e=this.pressListeners.indexOf(s);e>-1&&this.pressListeners.splice(e,1)}notifyMapPress(s){this.pressListeners.forEach(e=>{try{e(s)}catch{}})}}export const mapRegistry=new t;
|
|
@@ -1,121 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { StyleSheet, UIManager, findNodeHandle } from 'react-native';
|
|
3
|
-
import NexradRadarLayerNative from './NexradRadarLayerNativeComponent';
|
|
4
|
-
import { nexradDiag, nexradPerfSpan } from './nexrad/nexradDiag';
|
|
5
|
-
import { resolveNexradCommandId } from './nexrad/nexradNativeCommandIds';
|
|
6
|
-
|
|
7
|
-
const NATIVE_COMPONENT_NAME = 'NexradRadarLayer';
|
|
8
|
-
|
|
9
|
-
function getCommandId(commandName) {
|
|
10
|
-
return resolveNexradCommandId(commandName);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const NexradRadarLayer = forwardRef((props, ref) => {
|
|
14
|
-
const nativeRef = useRef(null);
|
|
15
|
-
|
|
16
|
-
useImperativeHandle(ref, () => ({
|
|
17
|
-
uploadNexradFrame(json) {
|
|
18
|
-
const bridge = nexradPerfSpan('bridge.dispatchViewManagerCommand.uploadNexradFrame');
|
|
19
|
-
const id = getCommandId('uploadNexradFrame');
|
|
20
|
-
const handle = findNodeHandle(nativeRef.current);
|
|
21
|
-
if (id != null && handle != null) {
|
|
22
|
-
UIManager.dispatchViewManagerCommand(handle, id, [json]);
|
|
23
|
-
bridge.end({
|
|
24
|
-
jsonChars: typeof json === 'string' ? json.length : 0,
|
|
25
|
-
ok: true,
|
|
26
|
-
});
|
|
27
|
-
} else {
|
|
28
|
-
bridge.end({
|
|
29
|
-
jsonChars: typeof json === 'string' ? json.length : 0,
|
|
30
|
-
ok: false,
|
|
31
|
-
commandId: id,
|
|
32
|
-
hasHandle: handle != null,
|
|
33
|
-
hasRef: nativeRef.current != null,
|
|
34
|
-
});
|
|
35
|
-
nexradDiag('bridge.uploadNexradFrameBlocked', {
|
|
36
|
-
commandId: id,
|
|
37
|
-
hasHandle: handle != null,
|
|
38
|
-
hasRef: nativeRef.current != null,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
uploadNexradStyleOnly(json) {
|
|
43
|
-
const bridge = nexradPerfSpan('bridge.dispatchViewManagerCommand.uploadNexradStyleOnly');
|
|
44
|
-
const id = getCommandId('uploadNexradStyleOnly');
|
|
45
|
-
const handle = findNodeHandle(nativeRef.current);
|
|
46
|
-
if (id != null && handle != null) {
|
|
47
|
-
UIManager.dispatchViewManagerCommand(handle, id, [json]);
|
|
48
|
-
bridge.end({
|
|
49
|
-
jsonChars: typeof json === 'string' ? json.length : 0,
|
|
50
|
-
ok: true,
|
|
51
|
-
});
|
|
52
|
-
} else {
|
|
53
|
-
bridge.end({
|
|
54
|
-
jsonChars: typeof json === 'string' ? json.length : 0,
|
|
55
|
-
ok: false,
|
|
56
|
-
commandId: id,
|
|
57
|
-
hasHandle: handle != null,
|
|
58
|
-
});
|
|
59
|
-
nexradDiag('bridge.uploadNexradStyleOnlyBlocked', {
|
|
60
|
-
commandId: id,
|
|
61
|
-
hasHandle: handle != null,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
clearNexrad() {
|
|
66
|
-
const bridge = nexradPerfSpan('bridge.dispatchViewManagerCommand.clearNexrad');
|
|
67
|
-
const id = getCommandId('clearNexrad');
|
|
68
|
-
const handle = findNodeHandle(nativeRef.current);
|
|
69
|
-
if (id != null && handle != null) {
|
|
70
|
-
UIManager.dispatchViewManagerCommand(handle, id, []);
|
|
71
|
-
bridge.end({ ok: true });
|
|
72
|
-
} else {
|
|
73
|
-
bridge.end({ ok: false, commandId: id, hasHandle: handle != null });
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
activateNexradCachedFrame(nativeGpuCacheKey) {
|
|
77
|
-
const bridge = nexradPerfSpan('bridge.dispatchViewManagerCommand.activateNexradCachedFrame');
|
|
78
|
-
const id = getCommandId('activateNexradCachedFrame');
|
|
79
|
-
const handle = findNodeHandle(nativeRef.current);
|
|
80
|
-
if (id != null && handle != null && typeof nativeGpuCacheKey === 'string') {
|
|
81
|
-
UIManager.dispatchViewManagerCommand(handle, id, [nativeGpuCacheKey]);
|
|
82
|
-
bridge.end({
|
|
83
|
-
keyLen: nativeGpuCacheKey.length,
|
|
84
|
-
ok: true,
|
|
85
|
-
});
|
|
86
|
-
} else {
|
|
87
|
-
bridge.end({
|
|
88
|
-
keyLen: typeof nativeGpuCacheKey === 'string' ? nativeGpuCacheKey.length : 0,
|
|
89
|
-
ok: false,
|
|
90
|
-
commandId: id,
|
|
91
|
-
hasHandle: handle != null,
|
|
92
|
-
});
|
|
93
|
-
nexradDiag('bridge.activateNexradCachedFrameBlocked', {
|
|
94
|
-
commandId: id,
|
|
95
|
-
hasHandle: handle != null,
|
|
96
|
-
keyType: typeof nativeGpuCacheKey,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
}));
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<NexradRadarLayerNative
|
|
104
|
-
ref={nativeRef}
|
|
105
|
-
belowID={props.belowID}
|
|
106
|
-
style={styles.overlay}
|
|
107
|
-
pointerEvents="none"
|
|
108
|
-
collapsable={false}
|
|
109
|
-
/>
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const styles = StyleSheet.create({
|
|
114
|
-
overlay: {
|
|
115
|
-
...StyleSheet.absoluteFillObject,
|
|
116
|
-
},
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
NexradRadarLayer.displayName = 'NexradRadarLayer';
|
|
120
|
-
|
|
121
|
-
export default NexradRadarLayer;
|
|
1
|
+
import n,{forwardRef as s,useImperativeHandle as c,useRef as m}from"react";import{StyleSheet as t,UIManager as u,findNodeHandle as p}from"react-native";import i from"./NexradRadarLayerNativeComponent";import{resolveNexradCommandId as x}from"./nexradNativeCommandIds";const N="NexradRadarLayer";function l(r,o,a=[]){const e=x(o),d=p(r.current);return e!=null&&d!=null?(u.dispatchViewManagerCommand(d,e,a),!0):(__DEV__&&console.warn(`[Aguacero][NexradRadarLayer] ${o} blocked`,{commandId:e,hasHandle:d!=null,hasRef:r.current!=null,component:N}),!1)}export const NexradRadarLayer=s((r,o)=>{const a=m(null);return c(o,()=>({uploadNexradFrame(e){l(a,"uploadNexradFrame",[e])},uploadNexradStyleOnly(e){l(a,"uploadNexradStyleOnly",[e])},clearNexrad(){l(a,"clearNexrad",[])},activateNexradCachedFrame(e){typeof e=="string"&&l(a,"activateNexradCachedFrame",[e])}})),n.createElement(i,{ref:a,belowID:r.belowID,style:f.overlay,pointerEvents:"none",collapsable:!1})});const f=t.create({overlay:{...t.absoluteFillObject}});NexradRadarLayer.displayName="NexradRadarLayer";export default NexradRadarLayer;
|