| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | // | 
					
						
							|  |  |  | //  ReactStubs.swift | 
					
						
							|  |  |  | //  TestRecorder | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | //  Created by Rafael Bastos on 11/07/2024. | 
					
						
							|  |  |  | //  Copyright © 2024 mrousavy. All rights reserved. | 
					
						
							|  |  |  | // | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import UIKit | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum RCTLogLevel: String { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   case trace | 
					
						
							|  |  |  |   case info | 
					
						
							|  |  |  |   case warning | 
					
						
							|  |  |  |   case error | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | enum RCTLogSource { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   case native | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func RCTDefaultLogFunction(_ level: RCTLogLevel, _ source: RCTLogSource, _ file: String, _ line: NSNumber, _ message: String) { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   print(level.rawValue, "-", message) | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typealias RCTDirectEventBlock = (Any?) -> Void | 
					
						
							|  |  |  | typealias RCTPromiseResolveBlock = (Any?) -> Void | 
					
						
							|  |  |  | typealias RCTPromiseRejectBlock = (String, String, NSError?) -> Void | 
					
						
							|  |  |  | typealias RCTResponseSenderBlock = (Any) -> Void | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func NSNull() -> [String: String] { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   return [:] | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func makeReactError(_ cameraError: CameraError, cause: NSError?) -> [String: Any] { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   var causeDictionary: [String: Any]? | 
					
						
							|  |  |  |   if let cause = cause { | 
					
						
							|  |  |  |     causeDictionary = [ | 
					
						
							|  |  |  |       "cause": "\(cause.domain): \(cause.code) \(cause.description)", | 
					
						
							|  |  |  |       "userInfo": cause.userInfo | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  |     ] | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   } | 
					
						
							|  |  |  |   return [ | 
					
						
							|  |  |  |     "error": "\(cameraError.code): \(cameraError.message)", | 
					
						
							|  |  |  |     "extra": [ | 
					
						
							|  |  |  |       "code": cameraError.code, | 
					
						
							|  |  |  |       "message": cameraError.message, | 
					
						
							|  |  |  |       "cause": causeDictionary ?? NSNull(), | 
					
						
							|  |  |  |     ] | 
					
						
							|  |  |  |   ] | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func makeReactError(_ cameraError: CameraError) -> [String: Any] { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   return makeReactError(cameraError, cause: nil) | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RCTFPSGraph: UIView { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   convenience init(frame: CGRect, color: UIColor) { | 
					
						
							|  |  |  |     self.init(frame: frame) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   func onTick(_ tick: CFTimeInterval) { | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | func RCTTempFilePath(_ ext: String, _ error: ErrorPointer) -> String? { | 
					
						
							| 
									
										
										
										
											2024-07-16 08:17:06 +01:00
										 |  |  |   let directory = NSTemporaryDirectory().appending("ReactNative") | 
					
						
							|  |  |  |   let fm = FileManager.default | 
					
						
							|  |  |  |   if fm.fileExists(atPath: directory) { | 
					
						
							|  |  |  |     try! fm.removeItem(atPath: directory) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   if !fm.fileExists(atPath: directory) { | 
					
						
							|  |  |  |     try! fm.createDirectory(atPath: directory, withIntermediateDirectories: true) | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return directory | 
					
						
							|  |  |  |     .appending("/").appending(UUID().uuidString) | 
					
						
							|  |  |  |     .appending(".").appending(ext) | 
					
						
							| 
									
										
										
										
											2024-07-12 08:53:47 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-07-16 09:50:21 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class RCTViewManager: NSObject { | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   var methodQueue: DispatchQueue! { nil } | 
					
						
							|  |  |  |   class func requiresMainQueueSetup() -> Bool { false } | 
					
						
							|  |  |  |   func view() -> UIView! { nil } | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   struct Bridge { | 
					
						
							|  |  |  |     let uiManager = UIManager() | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   struct UIManager { | 
					
						
							|  |  |  |     func view(forReactTag: NSNumber) -> UIView! { | 
					
						
							|  |  |  |       nil | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   let bridge: Bridge = Bridge() | 
					
						
							|  |  |  | } |