Skip to content

Commit

Permalink
Merge branch 'main' into feature/arvinwli_viewpager_throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinwli authored Oct 31, 2023
2 parents 6ddf3ea + ca3807a commit a8e04fb
Show file tree
Hide file tree
Showing 79 changed files with 1,291 additions and 1,232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "HippyPageCacheContainerView.h"
#import "HippyPageCacheView.h"
#import "HippyPageCache.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"

@interface HippyPageCacheContainerView ()<HippyPageCacheManagerObserverProtocol> {
__weak UIView *_lastPageCacheView; //never removed from superview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#import <hippy/HippyBridge.h>
#import <hippy/HippyRootView.h>
#import <hippy/HippyLog.h>
#import <hippy/HippyAsserts.h>
#import <hippy/HippyAssert.h>
#import <hippy/UIView+Hippy.h>

static NSString *const engineKey = @"Demo";
Expand Down
2 changes: 1 addition & 1 deletion framework/examples/ios-demo/HippyDemo/TestModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#import "HippyRedBox.h"
#import "DemoConfigs.h"
#import "HippyMethodInterceptorProtocol.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"

static NSString *const engineKey = @"Demo";

Expand Down
4 changes: 2 additions & 2 deletions framework/examples/ios-demo/podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ install! 'cocoapods',
:deterministic_uuids => false,
:generate_multiple_pod_projects => true

#use_frameworks! :linkage => :static # 静态库framework格式
#ENV["use_frameworks"] = "true" # for hippy when set use_frameworks!
use_frameworks! :linkage => :static # 静态库framework格式
ENV["use_frameworks"] = "true" # for hippy when set use_frameworks!

workspace 'HippyDemo.xcworkspace'

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/HippyDeviceBaseInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#import <UIKit/UIApplication.h>
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"
#import "HippyDeviceBaseInfo.h"
#import "HippyEventDispatcher.h"
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/HippyDisplayLink.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/CADisplayLink.h>

#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyBridgeModule.h"
#import "HippyFrameUpdate.h"
#import "HippyModuleData.h"
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/HippyKeyCommands.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#import "HippyKeyCommands.h"
#import <UIKit/UIKit.h>
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyDefines.h"
#import "HippyUtils.h"

Expand Down
4 changes: 2 additions & 2 deletions framework/ios/base/bridge/HippyBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#import "HippyRedBox.h"
#import "HippyTurboModule.h"
#import "HippyUtils.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyConvert.h"
#import "HippyDefaultImageProvider.h"
#import "HippyI18nUtils.h"
Expand Down Expand Up @@ -79,7 +79,7 @@
NSString *const HippyJavaScriptDidLoadNotification = @"HippyJavaScriptDidLoadNotification";
NSString *const HippyJavaScriptDidFailToLoadNotification = @"HippyJavaScriptDidFailToLoadNotification";
NSString *const HippyDidInitializeModuleNotification = @"HippyDidInitializeModuleNotification";
NSString *const HippySDKVersion = @"unspecified";
NSString *const HippySDKVersion = @HIPPY_STR(HIPPY_VERSION);


static NSString *const HippyNativeGlobalKeyOS = @"OS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import <JavaScriptCore/JavaScriptCore.h>

#import "NSObject+JSValue.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyJSCContextWrapper.h"
#import "HippyJSStackFrame.h"

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/executors/HippyJSExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#import <UIKit/UIDevice.h>
#import "VFSUriHandler.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyBundleURLProvider.h"
#import "HippyContextWrapper.h"
#import "HippyDefines.h"
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/modules/HippyEventDispatcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#import "HippyEventDispatcher.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"

const NSInteger HippyTextUpdateLagWarningThreshold = 3;
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/modules/HippyModuleData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "HippyModuleData.h"
#import "HippyBridge.h"
#import "HippyModuleMethod.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyLog.h"
#import "HippyUtils.h"

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/base/modules/HippyModuleMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "HippyBridge.h"
#import "HippyTurboModuleManager.h"
#import "HippyUtils.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyConvert.h"
#import "HippyLog.h"
#import "HippyParserUtils.h"
Expand Down
6 changes: 3 additions & 3 deletions framework/ios/base/modules/HippyModulesSetup.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyBridge.h"
#import "HippyModuleData.h"
#import "HippyModulesSetup.h"
Expand Down Expand Up @@ -176,7 +176,7 @@ - (void)setupModulesCompletion:(dispatch_block_t)completion {
// Check for name collisions between preregistered modules
HippyModuleData *moduleData = moduleDataByName[moduleName];
if (moduleData) {
HippyLogError(@"Attempted to register HippyBridgeModule class %@ for the "
HippyLogWarn(@"Attempted to register HippyBridgeModule class %@ for the "
"name '%@', but name was already registered by class %@",
moduleClass, moduleName, moduleData.moduleClass);
continue;
Expand All @@ -202,7 +202,7 @@ - (void)setupModulesCompletion:(dispatch_block_t)completion {
continue;
} else if ([moduleData.moduleClass new] != nil) {
// Both modules were non-nil, so it's unclear which should take precedence
HippyLogError(@"Attempted to register HippyBridgeModule class %@ for the "
HippyLogWarn(@"Attempted to register HippyBridgeModule class %@ for the "
"name '%@', but name was already registered by class %@",
moduleClass, moduleName, moduleData.moduleClass);
}
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/debug/websocket/HippySRWebSocket.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#import <CommonCrypto/CommonDigest.h>

#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyLog.h"
#import "HippySRSIMDHelpers.h"

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/dev/HippyDevMenu.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import "HippyEventDispatcher.h"
#import "HippyKeyCommands.h"
#import "HippyWebSocketProxy.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"
#import "HippyDefines.h"

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/dev/HippyRedBox.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import "HippyRedBox.h"
#import "HippyUtils.h"
#import "HippyWeakProxy.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyConvert.h"
#import "HippyJSStackFrame.h"
#import "HippyLog.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#import "HippyEventObserverModule.h"
#import "HippyEventDispatcher.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"

@implementation HippyEventObserverModule {
NSMutableDictionary *_config;
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/exception/HippyExceptionModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "HippyExceptionModule.h"
#import "HippyBridge.h"
#import "HippyDefines.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"

@implementation HippyExceptionModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "HippyBridge.h"
#import "HippyDefines.h"
#import "HippyUtils.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyConvert.h"
#import "HippyLog.h"
#import "HippyUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/netinfo/HippyNetInfo.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "HippyNetInfo.h"
#import "HippyNetInfoIntenal.h"

#import "HippyAsserts.h"
#import "HippyAssert.h"

@interface HippyNetInfo ()<HippyNetworkTypeChangedDelegate> {
}
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/netinfo/HippyNetInfoIntenal.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#import <SystemConfiguration/SystemConfiguration.h>

#import "HippyNetInfoIntenal.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"

#include <netinet/in.h>

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/network/HippyNetWork.mm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#import "HippyBridge+VFSLoader.h"
#import "HippyDefines.h"
#import "HippyNetWork.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"

static NSStringEncoding GetStringEncodingFromURLResponse(NSURLResponse *response) {
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/turbo/HippyOCTurboModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#import "HippyOCTurboModule+Inner.h"
#import "HippyTurboModuleManager.h"
#import "HippyJSExecutor.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyLog.h"
#import "HippyUtils.h"
#import "NSObject+CtxValue.h"
Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/turbo/HippyTurboModuleManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#import "HippyJSExecutor.h"
#import "HippyModuleData.h"
#import "HippyTurboModuleManager.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"

#include <unordered_map>

Expand Down
2 changes: 1 addition & 1 deletion framework/ios/module/turbo/NSObject+HippyTurbo.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#import "HippyModuleMethod.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyUtils.h"
#import "NSObject+HippyTurbo.h"

Expand Down
6 changes: 3 additions & 3 deletions framework/ios/utils/NSObject+CtxValue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
*/

#import "NSObject+CtxValue.h"
#import "HippyAsserts.h"

#import "HippyAssert.h"
#import "HippyLog.h"
#include "driver/napi/js_ctx.h"
#include "driver/napi/js_ctx_value.h"
#include "footstone/string_view.h"
Expand All @@ -32,7 +32,7 @@ @implementation NSObject (CtxValue)

- (CtxValuePtr)convertToCtxValue:(const CtxPtr &)context; {
@autoreleasepool {
HippyAssert(NO, @"%@ must implemente convertToCtxValue method", NSStringFromClass([self class]));
HippyLogWarn(@"%@ must implemente convertToCtxValue method", NSStringFromClass([self class]));
std::unordered_map<CtxValuePtr, CtxValuePtr> valueMap;
return context->CreateObject(valueMap);
}
Expand Down
3 changes: 3 additions & 0 deletions hippy.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ Pod::Spec.new do |s|
base.source_files = ['modules/ios/base/*.{h,m,mm}', 'modules/ios/logutils/*.{h,mm}']
base.public_header_files = ['modules/ios/base/*.h', 'modules/ios/logutils/*.h']
base.dependency 'hippy/Footstone'
base.pod_target_xcconfig = {
'GCC_PREPROCESSOR_DEFINITIONS' => 'HIPPY_VERSION=' + s.version.to_s,
}
puts 'hippy subspec \'base\' read end'
end

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* limitations under the License.
*/

#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyLog.h"

NSString *const HippyErrorDomain = @"HippyErrorDomain";
Expand Down
5 changes: 5 additions & 0 deletions modules/ios/base/HippyDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@
#define HIPPY_CONCAT2(A, B) A##B
#define HIPPY_CONCAT(A, B) HIPPY_CONCAT2(A, B)

/**
* Convert number macro to string
*/
#define HIPPY_STR(x) HIPPY_STR_EXPAND(x)
#define HIPPY_STR_EXPAND(x) #x

/**
* Throw an assertion for unimplemented methods.
Expand Down
18 changes: 16 additions & 2 deletions modules/ios/base/HippyLog.mm
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ void HippyAddLogFunction(HippyLogFunction logFunction) {
}
}

/**
* returns the topmost stacked log function for the current thread, which
* may not be the same as the current value of HippyCurrentLogFunction.
*/
static HippyLogFunction HippyGetLocalLogFunction() {
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
NSArray<HippyLogFunction> *functionStack = threadDictionary[HippyLogFunctionStack];
HippyLogFunction logFunction = functionStack.lastObject;
if (logFunction) {
return logFunction;
}
return HippyGetLogFunction();
}

void HippyPerformBlockWithLogFunction(void (^block)(void), HippyLogFunction logFunction) {
NSMutableDictionary *threadDictionary = [NSThread currentThread].threadDictionary;
NSMutableArray<HippyLogFunction> *functionStack = threadDictionary[HippyLogFunctionStack];
Expand All @@ -96,7 +110,7 @@ void HippyPerformBlockWithLogFunction(void (^block)(void), HippyLogFunction logF
}

void HippyPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) {
HippyLogFunction logFunction = HippyGetLogFunction();
HippyLogFunction logFunction = HippyGetLocalLogFunction();
if (logFunction) {
HippyPerformBlockWithLogFunction(block,
^(HippyLogLevel level, HippyLogSource source,
Expand Down Expand Up @@ -153,7 +167,7 @@ void HippyPerformBlockWithLogPrefix(void (^block)(void), NSString *prefix) {
}

void HippyLogNativeInternal(HippyLogLevel level, const char *fileName, int lineNumber, NSString *format, ...) {
HippyLogFunction logFunction = HippyGetLogFunction();
HippyLogFunction logFunction = HippyGetLocalLogFunction();
BOOL log = HIPPY_DEBUG || (logFunction != nil);
if (log && level >= HippyGetLogThreshold()) {
// Get message
Expand Down
12 changes: 12 additions & 0 deletions modules/ios/base/HippyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,16 @@ HIPPY_EXTERN NSString *HippySchemeFromURLString(NSString *urlString);
//Get String Encoding From HTTP URL Response
HIPPY_EXTERN NSStringEncoding HippyGetStringEncodingFromURLResponse(NSURLResponse *response);


#pragma mark -

/// 工具类
@interface HippyUtils : NSObject

/// SDK版本号
+ (NSString *)sdkVersion;

@end


NS_ASSUME_NONNULL_END
13 changes: 12 additions & 1 deletion modules/ios/base/HippyUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

#import "HippyUtils.h"
#import "HippyAsserts.h"
#import "HippyAssert.h"
#import "HippyLog.h"
#import <objc/message.h>
#import <CommonCrypto/CommonCrypto.h>
Expand Down Expand Up @@ -698,3 +698,14 @@ id HippyJSONClean(id object) {

return HippyMakeError(errorMessage, nil, errorInfo);
}


#pragma mark -

@implementation HippyUtils

+ (NSString *)sdkVersion {
return @(HIPPY_STR(HIPPY_VERSION));
}

@end
Loading

0 comments on commit a8e04fb

Please sign in to comment.