-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
runner
authored and
runner
committed
Mar 21, 2022
1 parent
b3d4a74
commit dddce04
Showing
269 changed files
with
10,724 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
#import "UADSApiToken.h" | ||
#import "USRVWebViewCallback.h" | ||
#import "UADSTokenStorage.h" | ||
#import "UADSHeaderBiddingTokenReaderBuilder.h" | ||
|
||
@implementation UADSApiToken | ||
|
||
+ (void)WebViewExposed_createTokens: (NSArray *)tokens callback: (USRVWebViewCallback *)callback { | ||
[[UADSTokenStorage sharedInstance] createTokens: tokens]; | ||
[self.tokenStorage createTokens: tokens]; | ||
[callback invoke: nil]; | ||
} | ||
|
||
+ (void)WebViewExposed_appendTokens: (NSArray *)tokens callback: (USRVWebViewCallback *)callback { | ||
[[UADSTokenStorage sharedInstance] appendTokens: tokens]; | ||
[self.tokenStorage appendTokens: tokens]; | ||
[callback invoke: nil]; | ||
} | ||
|
||
+ (void)WebViewExposed_deleteTokens: (USRVWebViewCallback *)callback { | ||
[[UADSTokenStorage sharedInstance] deleteTokens]; | ||
[self.tokenStorage deleteTokens]; | ||
[callback invoke: nil]; | ||
} | ||
|
||
+ (void)WebViewExposed_setPeekMode: (NSNumber *)value callback: (USRVWebViewCallback *)callback { | ||
[[UADSTokenStorage sharedInstance] setPeekMode: [value boolValue]]; | ||
[self.tokenStorage setPeekMode: [value boolValue]]; | ||
[callback invoke: nil]; | ||
} | ||
|
||
+ (id<UADSHeaderBiddingTokenCRUD>)tokenStorage { | ||
return UADSHeaderBiddingTokenReaderBuilder.sharedInstance.defaultReader; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,29 @@ | ||
#import "UADSTokenStorageEventProtocol.h" | ||
#import "UADSHeaderBiddingTokenReaderBase.h" | ||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol UADSHeaderBiddingTokenCRUD <NSObject> | ||
- (void)createTokens: (NSArray<NSString *> *)tokens; | ||
- (void)appendTokens: (NSArray<NSString *> *)tokens; | ||
- (NSString *) getToken; | ||
- (void) deleteTokens; | ||
- (void)setPeekMode: (BOOL)mode; | ||
- (void)setInitToken: (nullable NSString *)token; | ||
|
||
@end | ||
|
||
@interface UADSTokenStorage : NSObject<UADSHeaderBiddingTokenCRUD> | ||
|
||
@interface UADSTokenStorage : NSObject | ||
|
||
+ (instancetype)sharedInstance; | ||
|
||
- (instancetype)initWithEventHandler: (id<UADSTokenStorageEventProtocol>)eventHandler; | ||
|
||
- (void)createTokens: (NSArray<NSString *> *)tokens; | ||
- (void)appendTokens: (NSArray<NSString *> *)tokens; | ||
- (NSString *) getToken; | ||
- (void) deleteTokens; | ||
- (void)setPeekMode: (BOOL)mode; | ||
|
||
- (void)setInitToken: (nullable NSString *)token; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
SourceCode/Private/Core/Categories/NSBundle + TypecastGet.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@protocol UADSPlistReader <NSObject> | ||
|
||
- (NSString *)getStringValueForKey: (NSString *)key; | ||
|
||
@end | ||
|
||
@interface NSBundle (TypecastGet)<UADSPlistReader> | ||
- (NSString *)getStringValueForKey: (NSString *)key; | ||
+ (NSString *)getBuiltSDKVersion; | ||
+ (NSString *)getFromMainBundleValueForKey: (NSString *)key; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
19 changes: 19 additions & 0 deletions
19
SourceCode/Private/Core/Categories/NSBundle + TypecastGet.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#import "NSBundle + TypecastGet.h" | ||
#import "UADSTools.h" | ||
|
||
@implementation NSBundle (TypecastGet) | ||
- (NSString *)getStringValueForKey: (NSString *)key { | ||
id obj = [self objectForInfoDictionaryKey: key]; | ||
|
||
return typecast(obj, [NSString class]); | ||
} | ||
|
||
+ (NSString *)getFromMainBundleValueForKey: (NSString *)key { | ||
return [[self mainBundle] getStringValueForKey: key]; | ||
} | ||
|
||
+ (NSString *)getBuiltSDKVersion { | ||
return [self getFromMainBundleValueForKey: @"DTSDKName"]; | ||
} | ||
|
||
@end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
SourceCode/Private/Core/Categories/NSDictionary/NSDictionary+Filter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSDictionary<__covariant KeyType, __covariant ObjectType> (Filter) | ||
|
||
- (NSDictionary *)uads_filter: (BOOL(NS_NOESCAPE ^)(KeyType key, ObjectType obj))block; | ||
- (NSDictionary *)uads_mapKeys: (KeyType(NS_NOESCAPE ^)(KeyType key))block; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
26 changes: 26 additions & 0 deletions
26
SourceCode/Private/Core/Categories/NSDictionary/NSDictionary+Filter.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#import "NSDictionary+Filter.h" | ||
|
||
@implementation NSDictionary (Filter) | ||
- (NSDictionary *)uads_filter: (BOOL(NS_NOESCAPE ^)(id key, id obj))block; { | ||
NSMutableDictionary *newDictionary = [NSMutableDictionary new]; | ||
|
||
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) { | ||
if (block(key, obj)) { | ||
newDictionary[key] = obj; | ||
} | ||
}]; | ||
|
||
return newDictionary; | ||
} | ||
|
||
- (NSDictionary *)uads_mapKeys: (id(NS_NOESCAPE ^)(id key))block { | ||
NSMutableDictionary *newDictionary = [NSMutableDictionary new]; | ||
|
||
[self enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) { | ||
newDictionary[block(key)] = obj; | ||
}]; | ||
|
||
return newDictionary; | ||
} | ||
|
||
@end |
12 changes: 12 additions & 0 deletions
12
SourceCode/Private/Core/Categories/NSDictionary/NSDictionary+JSONString.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface NSDictionary (JSONString) | ||
- (NSString *) jsonEncodedString; | ||
- (NSData *_Nullable)jsonData; | ||
- (NSString *) queryString; | ||
- (BOOL) isEmpty; | ||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
49 changes: 49 additions & 0 deletions
49
SourceCode/Private/Core/Categories/NSDictionary/NSDictionary+JSONString.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#import "NSDictionary+JSONString.h" | ||
|
||
@implementation NSDictionary (JSONString) | ||
- (NSString *)jsonEncodedString { | ||
NSData *jsonData = [self jsonData]; | ||
|
||
if (!jsonData) { | ||
return @""; | ||
} | ||
|
||
return [[NSString alloc] initWithData: jsonData | ||
encoding: NSUTF8StringEncoding]; | ||
} | ||
|
||
- (NSData *)jsonData { | ||
NSError *err; | ||
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: self | ||
options: 0 | ||
error: &err]; | ||
|
||
if (err) { | ||
return nil; | ||
} | ||
|
||
GUARD_OR_NIL(jsonData) | ||
return jsonData; | ||
} | ||
|
||
- (NSString *)queryString { | ||
__block NSString *queryString = @""; | ||
__block BOOL first = true; | ||
|
||
[self enumerateKeysAndObjectsUsingBlock: ^(id _Nonnull key, id _Nonnull obj, BOOL *_Nonnull stop) { | ||
if (first) { | ||
queryString = [NSString stringWithFormat: @"?%@%@=%@", queryString, key, obj]; | ||
first = false; | ||
} else { | ||
queryString = [NSString stringWithFormat: @"%@&%@=%@", queryString, key, obj]; | ||
} | ||
}]; | ||
|
||
return queryString; | ||
} | ||
|
||
- (BOOL)isEmpty { | ||
return self.count <= 0; | ||
} | ||
|
||
@end |
11 changes: 11 additions & 0 deletions
11
SourceCode/Private/Core/Categories/NSDictionary/NSDictionary+Merge.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@interface NSDictionary (Merge) | ||
|
||
+ (NSDictionary *)unityads_dictionaryByMerging: (NSDictionary *)primary secondary: (NSDictionary *)secondary; | ||
|
||
- (NSDictionary *)uads_newdictionaryByMergingWith: (NSDictionary *)dictionary; | ||
|
||
- (NSDictionary *)uads_flatUsingSeparator: (NSString *)separator | ||
includeTopLevelKeys: (NSArray<NSString *> *)topLevelToInclude | ||
andReduceKeys: (NSArray<NSString *> *)reduceKeys | ||
andSkipKeys: (NSArray<NSString *> *)keysToSkip; | ||
@end |
Oops, something went wrong.