Skip to content

Commit

Permalink
iOS impl wip
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis committed Jan 26, 2024
1 parent 92b8126 commit 76541fd
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 66 deletions.
104 changes: 87 additions & 17 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ PODS:
- CocoaAsyncSocket (7.6.5)
- DoubleConversion (1.1.6)
- FBLazyVector (0.73.2)
- FBReactNativeSpec (0.73.2):
- RCT-Folly (= 2022.05.16.00)
- RCTRequired (= 0.73.2)
- RCTTypeSafety (= 0.73.2)
- React-Core (= 0.73.2)
- React-jsi (= 0.73.2)
- ReactCommon/turbomodule/core (= 0.73.2)
- Flipper (0.201.0):
- Flipper-Folly (~> 2.6)
- Flipper-Boost-iOSX (1.76.0.1.11)
Expand Down Expand Up @@ -116,17 +109,21 @@ PODS:
- React-callinvoker (0.73.2)
- React-Codegen (0.73.2):
- DoubleConversion
- FBReactNativeSpec
- glog
- hermes-engine
- RCT-Folly
- RCTRequired
- RCTTypeSafety
- React-Core
- React-debug
- React-Fabric
- React-FabricImage
- React-graphics
- React-jsi
- React-jsiexecutor
- React-NativeModulesApple
- React-rncore
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- React-Core (0.73.2):
Expand Down Expand Up @@ -939,13 +936,32 @@ PODS:
- React-jsi (= 0.73.2)
- React-perflogger (= 0.73.2)
- React-jsinspector (0.73.2)
- React-jsitracing (0.73.2):
- React-jsi
- React-logger (0.73.2):
- glog
- React-Mapbuffer (0.73.2):
- glog
- React-debug
- react-native-blurhash (1.1.11):
- glog
- hermes-engine
- RCT-Folly (= 2022.05.16.00)
- RCTRequired
- RCTTypeSafety
- React-Codegen
- React-Core
- React-debug
- React-Fabric
- React-graphics
- React-ImageManager
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
- React-utils
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- React-nativeconfig (0.73.2)
- React-NativeModulesApple (0.73.2):
- glog
Expand Down Expand Up @@ -974,13 +990,21 @@ PODS:
- RCTTypeSafety
- React-Core
- React-CoreModules
- React-debug
- React-Fabric
- React-graphics
- React-hermes
- React-nativeconfig
- React-NativeModulesApple
- React-RCTFabric
- React-RCTImage
- React-RCTNetwork
- React-rendererdebug
- React-RuntimeApple
- React-RuntimeCore
- React-RuntimeHermes
- React-runtimescheduler
- React-utils
- ReactCommon
- React-RCTBlob (0.73.2):
- hermes-engine
Expand Down Expand Up @@ -1058,8 +1082,42 @@ PODS:
- RCT-Folly (= 2022.05.16.00)
- React-debug
- React-rncore (0.73.2)
- React-RuntimeApple (0.73.2):
- hermes-engine
- RCT-Folly/Fabric (= 2022.05.16.00)
- React-callinvoker
- React-Core/Default
- React-CoreModules
- React-cxxreact
- React-jserrorhandler
- React-jsi
- React-jsiexecutor
- React-Mapbuffer
- React-NativeModulesApple
- React-RCTFabric
- React-RuntimeCore
- React-runtimeexecutor
- React-RuntimeHermes
- React-utils
- React-RuntimeCore (0.73.2):
- glog
- hermes-engine
- RCT-Folly/Fabric (= 2022.05.16.00)
- React-cxxreact
- React-jserrorhandler
- React-jsi
- React-jsiexecutor
- React-runtimeexecutor
- React-runtimescheduler
- React-runtimeexecutor (0.73.2):
- React-jsi (= 0.73.2)
- React-RuntimeHermes (0.73.2):
- hermes-engine
- RCT-Folly/Fabric (= 2022.05.16.00)
- React-jsi
- React-jsitracing
- React-nativeconfig
- React-utils
- React-runtimescheduler (0.73.2):
- glog
- hermes-engine
Expand Down Expand Up @@ -1120,7 +1178,6 @@ DEPENDENCIES:
- boost (from `../node_modules/react-native/third-party-podspecs/boost.podspec`)
- DoubleConversion (from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`)
- FBLazyVector (from `../node_modules/react-native/Libraries/FBLazyVector`)
- FBReactNativeSpec (from `../node_modules/react-native/React/FBReactNativeSpec`)
- Flipper (= 0.201.0)
- Flipper-Boost-iOSX (= 1.76.0.1.11)
- Flipper-DoubleConversion (= 3.2.0.1)
Expand Down Expand Up @@ -1167,6 +1224,7 @@ DEPENDENCIES:
- React-jsi (from `../node_modules/react-native/ReactCommon/jsi`)
- React-jsiexecutor (from `../node_modules/react-native/ReactCommon/jsiexecutor`)
- React-jsinspector (from `../node_modules/react-native/ReactCommon/jsinspector-modern`)
- React-jsitracing (from `../node_modules/react-native/ReactCommon/hermes/executor/`)
- React-logger (from `../node_modules/react-native/ReactCommon/logger`)
- React-Mapbuffer (from `../node_modules/react-native/ReactCommon`)
- react-native-blurhash (from `../node_modules/react-native-blurhash`)
Expand All @@ -1186,7 +1244,10 @@ DEPENDENCIES:
- React-RCTVibration (from `../node_modules/react-native/Libraries/Vibration`)
- React-rendererdebug (from `../node_modules/react-native/ReactCommon/react/renderer/debug`)
- React-rncore (from `../node_modules/react-native/ReactCommon`)
- React-RuntimeApple (from `../node_modules/react-native/ReactCommon/react/runtime/platform/ios`)
- React-RuntimeCore (from `../node_modules/react-native/ReactCommon/react/runtime`)
- React-runtimeexecutor (from `../node_modules/react-native/ReactCommon/runtimeexecutor`)
- React-RuntimeHermes (from `../node_modules/react-native/ReactCommon/react/runtime`)
- React-runtimescheduler (from `../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler`)
- React-utils (from `../node_modules/react-native/ReactCommon/react/utils`)
- ReactCommon/turbomodule/core (from `../node_modules/react-native/ReactCommon`)
Expand Down Expand Up @@ -1215,8 +1276,6 @@ EXTERNAL SOURCES:
:podspec: "../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec"
FBLazyVector:
:path: "../node_modules/react-native/Libraries/FBLazyVector"
FBReactNativeSpec:
:path: "../node_modules/react-native/React/FBReactNativeSpec"
glog:
:podspec: "../node_modules/react-native/third-party-podspecs/glog.podspec"
hermes-engine:
Expand Down Expand Up @@ -1260,6 +1319,8 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/jsiexecutor"
React-jsinspector:
:path: "../node_modules/react-native/ReactCommon/jsinspector-modern"
React-jsitracing:
:path: "../node_modules/react-native/ReactCommon/hermes/executor/"
React-logger:
:path: "../node_modules/react-native/ReactCommon/logger"
React-Mapbuffer:
Expand Down Expand Up @@ -1298,8 +1359,14 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/react/renderer/debug"
React-rncore:
:path: "../node_modules/react-native/ReactCommon"
React-RuntimeApple:
:path: "../node_modules/react-native/ReactCommon/react/runtime/platform/ios"
React-RuntimeCore:
:path: "../node_modules/react-native/ReactCommon/react/runtime"
React-runtimeexecutor:
:path: "../node_modules/react-native/ReactCommon/runtimeexecutor"
React-RuntimeHermes:
:path: "../node_modules/react-native/ReactCommon/react/runtime"
React-runtimescheduler:
:path: "../node_modules/react-native/ReactCommon/react/renderer/runtimescheduler"
React-utils:
Expand All @@ -1314,7 +1381,6 @@ SPEC CHECKSUMS:
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
FBLazyVector: fbc4957d9aa695250b55d879c1d86f79d7e69ab4
FBReactNativeSpec: 86de768f89901ef6ed3207cd686362189d64ac88
Flipper: c7a0093234c4bdd456e363f2f19b2e4b27652d44
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30
Expand All @@ -1333,7 +1399,7 @@ SPEC CHECKSUMS:
RCTTypeSafety: a759e3b086eccf3e2cbf2493d22f28e082f958e6
React: 805f5dd55bbdb92c36b4914c64aaae4c97d358dc
React-callinvoker: 6a697867607c990c2c2c085296ee32cfb5e47c01
React-Codegen: c4447ffa339f4e7a22e0c9c800eec9084f31899c
React-Codegen: f3cb992539e5c21675f087e536d64b1f2a448655
React-Core: 49f66fecc7695464e9b7bc7dc7cd9473d2c60584
React-CoreModules: 710e7c557a1a8180bd1645f5b4bf79f4bd3f5417
React-cxxreact: 345857b5e4be000c0527df78be3b41a0677a20ce
Expand All @@ -1347,15 +1413,16 @@ SPEC CHECKSUMS:
React-jsi: a182068133f80918cd0eec77875abaf943a0b6be
React-jsiexecutor: dacd00ce8a18fc00a0ae6c25e3015a6437e5d2e8
React-jsinspector: 03644c063fc3621c9a4e8bf263a8150909129618
React-jsitracing: 7c77101b38fcc8fa7f198de7e1d834350a85af90
React-logger: 66b168e2b2bee57bd8ce9e69f739d805732a5570
React-Mapbuffer: 9ee041e1d7be96da6d76a251f92e72b711c651d6
react-native-blurhash: a59e6bf8117a0304488ed576abd440f4b0777a8c
react-native-blurhash: 39527d2330f83336178eee39a7780035c5881d70
React-nativeconfig: d753fbbc8cecc8ae413d615599ac378bbf6999bb
React-NativeModulesApple: 964f4eeab1b4325e8b6a799cf4444c3fd4eb0a9c
React-perflogger: 29efe63b7ef5fbaaa50ef6eaa92482f98a24b97e
React-RCTActionSheet: 69134c62aefd362027b20da01cd5d14ffd39db3f
React-RCTAnimation: 3b5a57087c7a5e727855b803d643ac1d445488f5
React-RCTAppDelegate: a3ce9b69c0620a1717d08e826d4dc7ad8a3a3cae
React-RCTAppDelegate: cb1a9a8447ddad006f934988016390f4df472e74
React-RCTBlob: 26ea660f2be1e6de62f2d2ad9a9c7b9bfabb786f
React-RCTFabric: bb6dbbff2f80b9489f8b2f1d2554aa040aa2e3cd
React-RCTImage: 27b27f4663df9e776d0549ed2f3536213e793f1b
Expand All @@ -1365,8 +1432,11 @@ SPEC CHECKSUMS:
React-RCTText: 73006e95ca359595c2510c1c0114027c85a6ddd3
React-RCTVibration: 599f427f9cbdd9c4bf38959ca020e8fef0717211
React-rendererdebug: f2946e0a1c3b906e71555a7c4a39aa6a6c0e639b
React-rncore: 74030de0ffef7b1a3fb77941168624534cc9ae7f
React-rncore: 6e3139cf51cea08068f008da426821d1deaa24b9
React-RuntimeApple: 08c29690996ed935e35054965bcfb70ebea67318
React-RuntimeCore: 5b73f40b46d78a825cf71714e1e5044d389702d6
React-runtimeexecutor: 2d1f64f58193f00a3ad71d3f89c2bfbfe11cf5a5
React-RuntimeHermes: 01dcb5a4e9073496f6f981a8648843771e3f6516
React-runtimescheduler: df8945a656356ff10f58f65a70820478bfcf33ad
React-utils: f5bc61e7ea3325c0732ae2d755f4441940163b85
ReactCommon: 45b5d4f784e869c44a6f5a8fad5b114ca8f78c53
Expand Down
12 changes: 10 additions & 2 deletions example/ios/example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -572,13 +572,17 @@
);
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_CFLAGS = "$(inherited)";
OTHER_CFLAGS = (
"$(inherited)",
"-DRN_FABRIC_ENABLED",
);
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down Expand Up @@ -644,13 +648,17 @@
"\"$(inherited)\"",
);
MTL_ENABLE_DEBUG_INFO = NO;
OTHER_CFLAGS = "$(inherited)";
OTHER_CFLAGS = (
"$(inherited)",
"-DRN_FABRIC_ENABLED",
);
OTHER_CPLUSPLUSFLAGS = (
"$(OTHER_CFLAGS)",
"-DFOLLY_NO_CONFIG",
"-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1",
"-DFOLLY_CFG_NO_COROUTINES=1",
"-DRN_FABRIC_ENABLED",
);
OTHER_LDFLAGS = (
"$(inherited)",
Expand Down
11 changes: 2 additions & 9 deletions ios/BlurhashCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,7 @@ final class BlurhashCache {
self.decodePunch = decodePunch
}

init(blurhash: NSString?, decodeWidth: NSNumber, decodeHeight: NSNumber, decodePunch: NSNumber) {
self.blurhash = blurhash as String?
self.decodeWidth = decodeWidth.intValue
self.decodeHeight = decodeHeight.intValue
self.decodePunch = decodePunch.floatValue
}

final func isDifferent(blurhash: NSString, decodeWidth: NSNumber, decodeHeight: NSNumber, decodePunch: NSNumber) -> Bool {
return self.blurhash != blurhash as String || self.decodeWidth != decodeWidth.intValue || self.decodeHeight != decodeHeight.intValue || self.decodePunch != decodePunch.floatValue
final func isDifferent(blurhash: String, decodeWidth: Int, decodeHeight: Int, decodePunch: Float) -> Bool {
return self.blurhash != blurhash || self.decodeWidth != decodeWidth || self.decodeHeight != decodeHeight || self.decodePunch != decodePunch
}
}
9 changes: 9 additions & 0 deletions ios/BlurhashModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <React/RCTBridgeModule.h>

NS_ASSUME_NONNULL_BEGIN

@interface BlurhashModule : NSObject <RCTBridgeModule>

@end

NS_ASSUME_NONNULL_END
40 changes: 40 additions & 0 deletions ios/BlurhashModule.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#import "BlurhashModule.h"

#import <React/RCTUtils.h>
#import <UIKit/UIKit.h>
#ifdef RCT_NEW_ARCH_ENABLED
#import <blurhash_codegen/blurhash_codegen.h>
#endif

#ifdef RCT_NEW_ARCH_ENABLED
using namespace facebook::react;

@interface BlurhashModule () <NativeBlurhashModuleSpec>
@end
#endif

@implementation BlurhashModule

RCT_EXPORT_MODULE()

- (void)createBlurhashFromImage:(NSString *)imageUri
componentsX:(double)componentsX
componentsY:(double)componentsY
resolve:(RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject {
}

- (void)clearCosineCache {
// Not implemented on iOS.
}

#ifdef RCT_NEW_ARCH_ENABLED

- (std::shared_ptr<TurboModule>)getTurboModule:
(const ObjCTurboModule::InitParams &)params {
return std::make_shared<NativeBlurhashModuleSpecJSI>(params);
}

#endif

@end
Loading

0 comments on commit 76541fd

Please sign in to comment.