@aguacerowx/react-native 0.0.39 → 0.0.41

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 (26) hide show
  1. package/ios/GridRenderLayer.swift +73 -29
  2. package/lib/commonjs/ios/GridRenderLayer.swift +73 -29
  3. package/lib/commonjs/package.json +1 -1
  4. package/lib/commonjs/src/WeatherLayerManager.js +0 -15
  5. package/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
  6. package/lib/module/ios/GridRenderLayer.swift +73 -29
  7. package/lib/module/lib/commonjs/package.json +1 -1
  8. package/lib/module/lib/commonjs/src/WeatherLayerManager.js +0 -15
  9. package/lib/module/lib/commonjs/src/WeatherLayerManager.js.map +1 -1
  10. package/lib/module/package.json +1 -1
  11. package/lib/module/src/WeatherLayerManager.js +0 -15
  12. package/lib/module/src/WeatherLayerManager.js.map +1 -1
  13. package/lib/typescript/src/WeatherLayerManager.d.ts.map +1 -1
  14. package/package.json +1 -1
  15. package/src/WeatherLayerManager.js +0 -16
  16. package/lib/module/lib/commonjs/ios/GridRenderLayerBridge.swift +0 -45
  17. package/lib/module/lib/commonjs/ios/GridRenderLayerManager.mm +0 -172
  18. package/lib/module/lib/commonjs/ios/GridRenderLayerView.h +0 -31
  19. package/lib/module/lib/commonjs/ios/GridRenderLayerView.m +0 -201
  20. package/lib/module/lib/commonjs/ios/InspectorDataCache.swift +0 -64
  21. package/lib/module/lib/commonjs/ios/InspectorModule.m +0 -10
  22. package/lib/module/lib/commonjs/ios/InspectorModule.swift +0 -113
  23. package/lib/module/lib/commonjs/ios/Shaders.metal +0 -320
  24. package/lib/module/lib/commonjs/ios/WeatherFrameProcessorModule.m +0 -16
  25. package/lib/module/lib/commonjs/ios/WeatherFrameProcessorModule.swift +0 -153
  26. package/lib/module/lib/commonjs/scripts/compile-shaders.sh +0 -39
@@ -1,201 +0,0 @@
1
- #import "GridRenderLayerView.h"
2
- #import <React/RCTLog.h>
3
- #import <objc/runtime.h>
4
-
5
- // Import Swift bridging header
6
- #if __has_include("aguacerowx_react_native-Swift.h")
7
- #import "aguacerowx_react_native-Swift.h"
8
- #else
9
- #import <aguacerowx_react_native/aguacerowx_react_native-Swift.h>
10
- #endif
11
-
12
- // Import MapboxMaps to get MapView definition
13
- @import MapboxMaps;
14
-
15
- @interface GridRenderLayerView ()
16
- @property (nonatomic, assign) BOOL isLayerAdded;
17
- @end
18
-
19
- @implementation GridRenderLayerView
20
- - (instancetype)init {
21
- self = [super init];
22
- if (self) {
23
- _layerId = [NSString stringWithFormat:@"weather-layer-%@", [[NSUUID UUID] UUIDString]];
24
- _layerInstance = [[GridRenderLayer alloc] initWithId:_layerId];
25
- _isLayerAdded = NO;
26
- }
27
- return self;
28
- }
29
-
30
- #pragma mark - Property Setters
31
-
32
- - (void)setOpacity:(float)opacity {
33
- [self.layerInstance setOpacityWithValue:opacity];
34
- }
35
-
36
- - (void)setDataRange:(NSArray *)dataRange {
37
- if (dataRange && dataRange.count == 2) {
38
- [self.layerInstance setDataRangeWithValue:dataRange];
39
- } else {
40
- RCTLogError(@"❌ [GridRenderLayerView] Invalid dataRange: %@", dataRange);
41
- }
42
- }
43
-
44
- - (void)setSmoothing:(BOOL)smoothing {
45
- [self.layerInstance setSmoothingWithValue:smoothing];
46
- }
47
-
48
- - (void)setBelowID:(NSString *)belowID {
49
- _belowID = belowID;
50
- }
51
-
52
- // ADD THIS METHOD
53
- - (void)setVariable:(NSString *)variable {
54
- [self.layerInstance setVariableWithVariable:variable];
55
- }
56
-
57
- #pragma mark - View Lifecycle
58
-
59
- - (void)didMoveToWindow {
60
- [super didMoveToWindow];
61
- if (self.window && !self.isLayerAdded) {
62
- [self findMapViewAndAddLayerInView:self.window];
63
- }
64
- }
65
-
66
- - (void)layoutSubviews {
67
- [super layoutSubviews];
68
-
69
- static dispatch_once_t onceToken;
70
- dispatch_once(&onceToken, ^{
71
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
72
- if (!self.isLayerAdded) {
73
- UIView *searchRoot = self.window ? self.window : self.superview;
74
- if (searchRoot) {
75
- [self findMapViewAndAddLayerInView:searchRoot];
76
- }
77
- }
78
- });
79
- });
80
- }
81
-
82
- - (void)findMapViewAndAddLayerInView:(UIView *)view {
83
- if (!view || self.isLayerAdded) {
84
- return;
85
- }
86
-
87
- NSString *className = NSStringFromClass([view class]);
88
-
89
- if ([className isEqualToString:@"RNMBXMapView"]) {
90
- if (view.subviews.count > 0) {
91
- UIView *firstSubview = view.subviews[0];
92
- NSString *subviewClass = NSStringFromClass([firstSubview class]);
93
- if ([subviewClass containsString:@"MapboxMaps.MapView"] || [subviewClass isEqualToString:@"MapView"]) {
94
- self.mapView = (MapView *)firstSubview;
95
- [self waitForStyleLoadAndAddLayer];
96
- return;
97
- }
98
- }
99
-
100
- RCTLogError(@"❌ [GridRenderLayerView] RNMBXMapView found but MapboxMaps.MapView not in expected location");
101
- return;
102
- }
103
-
104
- for (UIView *subview in view.subviews) {
105
- [self findMapViewAndAddLayerInView:subview];
106
- if (self.isLayerAdded) {
107
- return;
108
- }
109
- }
110
- }
111
-
112
- - (void)waitForStyleLoadAndAddLayer {
113
- if (!self.mapView) {
114
- return;
115
- }
116
-
117
- NSString *targetLayer = self.belowID ?: @"AML_-_terrain";
118
-
119
- // Check if the target layer already exists
120
- if ([GridRenderLayerBridge layerExistsIn:self.mapView layerId:targetLayer]) {
121
- [self addLayerToMap];
122
- return;
123
- }
124
-
125
- [self pollForLayerExistence];
126
- }
127
-
128
- - (void)pollForLayerExistence {
129
- if (self.isLayerAdded || !self.mapView) {
130
- return;
131
- }
132
-
133
- NSString *targetLayer = self.belowID ?: @"AML_-_terrain";
134
-
135
- if ([GridRenderLayerBridge layerExistsIn:self.mapView layerId:targetLayer]) {
136
- [self addLayerToMap];
137
- return;
138
- }
139
-
140
- // Try again in 100ms
141
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
142
- [self pollForLayerExistence];
143
- });
144
- }
145
-
146
- - (void)addLayerToMap {
147
- if (!self.mapView || self.isLayerAdded) {
148
- return;
149
- }
150
-
151
- id customLayer = [self.layerInstance getHostWrapper];
152
-
153
- if (!customLayer) {
154
- RCTLogError(@"❌ [GridRenderLayerView] Failed to get hostWrapper");
155
- return;
156
- }
157
-
158
- BOOL success = [GridRenderLayerBridge addCustomLayerTo:self.mapView
159
- layerHost:customLayer
160
- layerId:self.layerId
161
- belowLayerId:self.belowID];
162
-
163
- if (success) {
164
- self.isLayerAdded = YES;
165
-
166
- [[NSNotificationCenter defaultCenter] addObserverForName:@"TriggerMapRepaint"
167
- object:nil
168
- queue:[NSOperationQueue mainQueue]
169
- usingBlock:^(NSNotification *note) {
170
- if (self.mapView) {
171
- [GridRenderLayerBridge triggerRepaintOn:self.mapView];
172
- }
173
- }];
174
- } else {
175
- RCTLogError(@"❌ [GridRenderLayerView] Failed to add layer via Swift bridge");
176
- }
177
- }
178
-
179
- - (void)removeFromSuperview {
180
- if (self.mapView && self.isLayerAdded) {
181
- [GridRenderLayerBridge removeCustomLayerFrom:self.mapView layerId:self.layerId];
182
- }
183
- [super removeFromSuperview];
184
- }
185
-
186
- - (void)dealloc {
187
- RCTLogInfo(@"🔴 [GridRenderLayerView] dealloc called");
188
-
189
- // Remove notification observer
190
- [[NSNotificationCenter defaultCenter] removeObserver:self];
191
-
192
- // Clear the layer instance
193
- if (_layerInstance) {
194
- [_layerInstance clear];
195
- _layerInstance = nil;
196
- }
197
-
198
- _mapView = nil;
199
- }
200
-
201
- @end
@@ -1,64 +0,0 @@
1
- import Foundation
2
-
3
- final class InspectorDataCache {
4
- static let shared = InspectorDataCache()
5
- private let queue = DispatchQueue(label: "com.aguacerowx.InspectorDataCacheQueue", attributes: .concurrent)
6
-
7
- private var _filePath: String?
8
- private var _nx: Int = 0
9
- private var _ny: Int = 0
10
- private var _scale: Float = 1.0
11
- private var _offset: Float = 0.0
12
- private var _missing: Float = 127.0
13
- private var _scaleType: Int = 0
14
-
15
- private init() {}
16
-
17
- var filePath: String? { queue.sync { _filePath } }
18
- var nx: Int { queue.sync { _nx } }
19
- var ny: Int { queue.sync { _ny } }
20
- var scale: Float { queue.sync { _scale } }
21
- var offset: Float { queue.sync { _offset } }
22
- var missing: Float { queue.sync { _missing } }
23
- var scaleType: Int { queue.sync { _scaleType } }
24
-
25
- // Keep this signature so existing callers don't break - just ignore the data param
26
- func update(data: Data?, nx: Int, ny: Int, scale: Float, offset: Float, missing: Float, scaleType: Int = 0) {
27
- queue.async(flags: .barrier) {
28
- self._nx = nx
29
- self._ny = ny
30
- self._scale = scale
31
- self._offset = offset
32
- self._missing = missing
33
- self._scaleType = scaleType
34
- }
35
- }
36
-
37
- func updateFilePath(_ path: String) {
38
- queue.async(flags: .barrier) {
39
- self._filePath = path
40
- }
41
- }
42
-
43
- // Convenience: update everything at once
44
- func updateWithFilePath(filePath: String, nx: Int, ny: Int, scale: Float, offset: Float, missing: Float, scaleType: Int = 0) {
45
- queue.async(flags: .barrier) {
46
- self._filePath = filePath
47
- self._nx = nx
48
- self._ny = ny
49
- self._scale = scale
50
- self._offset = offset
51
- self._missing = missing
52
- self._scaleType = scaleType
53
- }
54
- }
55
-
56
- func clear() {
57
- queue.async(flags: .barrier) {
58
- self._filePath = nil
59
- self._nx = 0
60
- self._ny = 0
61
- self._scaleType = 0
62
- }
63
- }
64
- }
@@ -1,10 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
-
3
- @interface RCT_EXTERN_MODULE(InspectorModule, NSObject)
4
-
5
- RCT_EXTERN_METHOD(getValueAtGridIndex:(nonnull NSNumber *)i
6
- j:(nonnull NSNumber *)j
7
- resolver:(RCTPromiseResolveBlock)resolve
8
- rejecter:(RCTPromiseRejectBlock)reject)
9
-
10
- @end
@@ -1,113 +0,0 @@
1
- import Foundation
2
- import React
3
- import libzstd
4
-
5
- @objc(InspectorModule)
6
- class InspectorModule: NSObject {
7
-
8
- @objc(getValueAtGridIndex:j:resolver:rejecter:)
9
- func getValueAtGridIndex(
10
- i: NSNumber,
11
- j: NSNumber,
12
- resolve: @escaping RCTPromiseResolveBlock,
13
- reject: @escaping RCTPromiseRejectBlock
14
- ) {
15
- DispatchQueue.global(qos: .userInitiated).async {
16
- let cache = InspectorDataCache.shared
17
-
18
- guard let filePath = cache.filePath else {
19
- resolve(nil)
20
- return
21
- }
22
-
23
- let nx = cache.nx
24
- let ny = cache.ny
25
- let scale = cache.scale
26
- let offset = cache.offset
27
- let missing = cache.missing
28
- let scaleType = cache.scaleType
29
-
30
- let iVal = i.intValue
31
- let jVal = j.intValue
32
- let index = jVal * nx + iVal
33
-
34
- guard index >= 0 && index < (nx * ny) else {
35
- print("🔍 [Inspector] ERROR: Index out of bounds")
36
- resolve(nil)
37
- return
38
- }
39
-
40
- // Read and decompress the file
41
- guard let fileData = try? Data(contentsOf: URL(fileURLWithPath: filePath)) else {
42
- print("🔍 [Inspector] ERROR: Could not read file at \(filePath)")
43
- resolve(nil)
44
- return
45
- }
46
-
47
- guard var decompressed = self.decompressZstd(data: fileData) else {
48
- print("🔍 [Inspector] ERROR: Failed to decompress")
49
- resolve(nil)
50
- return
51
- }
52
-
53
- // Reconstruct delta encoding (same as GridRenderLayer)
54
- self.reconstructInPlace(data: &decompressed)
55
-
56
- guard index < decompressed.count else {
57
- resolve(nil)
58
- return
59
- }
60
-
61
- let rawByte = decompressed[index]
62
- // After reconstructInPlace, bytes are raw signed values stored as UInt8
63
- // The value is the signed Int8 interpretation
64
- let signedQuantizedValue = Int(Int8(bitPattern: rawByte))
65
- let missingQuantized = Int(round(missing))
66
-
67
- if abs(signedQuantizedValue - missingQuantized) < 1 {
68
- resolve(nil)
69
- return
70
- }
71
-
72
- let intermediateValue = Double(signedQuantizedValue) * Double(scale) + Double(offset)
73
- let finalValue = scaleType == 1 ? intermediateValue * abs(intermediateValue) : intermediateValue
74
-
75
- resolve(finalValue)
76
- }
77
- }
78
-
79
- // Reconstruct delta encoding only (no +128 shift, we want signed values)
80
- private func reconstructInPlace(data: inout Data) {
81
- let count = data.count
82
- guard count > 0 else { return }
83
- data.withUnsafeMutableBytes { rawBuffer in
84
- guard let ptr = rawBuffer.baseAddress?.assumingMemoryBound(to: UInt8.self) else { return }
85
- var running = Int8(bitPattern: ptr[0])
86
- // Leave ptr[0] as-is (it's already the first value)
87
- for i in 1..<count {
88
- let delta = Int8(bitPattern: ptr[i])
89
- running = running &+ delta
90
- ptr[i] = UInt8(bitPattern: running)
91
- }
92
- }
93
- }
94
-
95
- private func decompressZstd(data: Data) -> Data? {
96
- let decompressedSize = data.withUnsafeBytes { ptr in
97
- ZSTD_getFrameContentSize(ptr.baseAddress, data.count)
98
- }
99
- guard Int64(bitPattern: decompressedSize) > 0 else { return nil }
100
-
101
- var decompressedData = Data(count: Int(decompressedSize))
102
- let result = decompressedData.withUnsafeMutableBytes { decompPtr in
103
- data.withUnsafeBytes { compPtr in
104
- Int(ZSTD_decompress(decompPtr.baseAddress, Int(decompressedSize), compPtr.baseAddress, data.count))
105
- }
106
- }
107
- guard result > 0 && result == decompressedData.count else { return nil }
108
- return decompressedData
109
- }
110
-
111
- @objc
112
- static func requiresMainQueueSetup() -> Bool { return false }
113
- }