2015-03-23 23:28:42 +03:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
*/
|
2015-02-20 07:10:52 +03:00
|
|
|
|
2015-03-02 02:33:55 +03:00
|
|
|
#import <tgmath.h>
|
|
|
|
|
2015-02-20 07:10:52 +03:00
|
|
|
#import <CoreGraphics/CoreGraphics.h>
|
|
|
|
#import <Foundation/Foundation.h>
|
2015-09-22 20:43:56 +03:00
|
|
|
#import <UIKit/UIKit.h>
|
2015-02-20 07:10:52 +03:00
|
|
|
|
|
|
|
#import "RCTAssert.h"
|
2015-04-21 15:26:51 +03:00
|
|
|
#import "RCTDefines.h"
|
2015-02-20 07:10:52 +03:00
|
|
|
|
2015-07-16 19:34:28 +03:00
|
|
|
// JSON serialization/deserialization
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN NSString *RCTJSONStringify(id jsonObject, NSError **error);
|
|
|
|
RCT_EXTERN id RCTJSONParse(NSString *jsonString, NSError **error);
|
2015-06-04 02:57:08 +03:00
|
|
|
RCT_EXTERN id RCTJSONParseMutable(NSString *jsonString, NSError **error);
|
2015-02-20 07:10:52 +03:00
|
|
|
|
2015-05-06 10:11:31 +03:00
|
|
|
// Strip non JSON-safe values from an object graph
|
|
|
|
RCT_EXTERN id RCTJSONClean(id object);
|
|
|
|
|
2015-07-16 19:34:28 +03:00
|
|
|
// Get MD5 hash of a string
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN NSString *RCTMD5Hash(NSString *string);
|
2015-02-20 07:10:52 +03:00
|
|
|
|
|
|
|
// Get screen metrics in a thread-safe way
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN CGFloat RCTScreenScale(void);
|
|
|
|
RCT_EXTERN CGSize RCTScreenSize(void);
|
2015-02-20 07:10:52 +03:00
|
|
|
|
|
|
|
// Round float coordinates to nearest whole screen pixel (not point)
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value);
|
|
|
|
RCT_EXTERN CGFloat RCTCeilPixelValue(CGFloat value);
|
|
|
|
RCT_EXTERN CGFloat RCTFloorPixelValue(CGFloat value);
|
2015-02-20 07:10:52 +03:00
|
|
|
|
|
|
|
// Method swizzling
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN void RCTSwapClassMethods(Class cls, SEL original, SEL replacement);
|
|
|
|
RCT_EXTERN void RCTSwapInstanceMethods(Class cls, SEL original, SEL replacement);
|
2015-02-20 07:10:52 +03:00
|
|
|
|
|
|
|
// Module subclass support
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN BOOL RCTClassOverridesClassMethod(Class cls, SEL selector);
|
|
|
|
RCT_EXTERN BOOL RCTClassOverridesInstanceMethod(Class cls, SEL selector);
|
2015-03-02 02:33:55 +03:00
|
|
|
|
2015-03-11 22:06:03 +03:00
|
|
|
// Creates a standardized error object
|
2015-04-21 15:26:51 +03:00
|
|
|
RCT_EXTERN NSDictionary *RCTMakeError(NSString *message, id toStringify, NSDictionary *extraData);
|
|
|
|
RCT_EXTERN NSDictionary *RCTMakeAndLogError(NSString *message, id toStringify, NSDictionary *extraData);
|
2015-07-13 20:33:39 +03:00
|
|
|
RCT_EXTERN NSDictionary *RCTJSErrorFromNSError(NSError *error);
|
2015-04-27 13:50:07 +03:00
|
|
|
|
|
|
|
// Returns YES if React is running in a test environment
|
|
|
|
RCT_EXTERN BOOL RCTRunningInTestEnvironment(void);
|
2015-05-22 17:17:08 +03:00
|
|
|
|
2015-09-22 20:43:56 +03:00
|
|
|
// Returns YES if React is running in an iOS App Extension
|
|
|
|
RCT_EXTERN BOOL RCTRunningInAppExtension(void);
|
|
|
|
|
|
|
|
// Returns the shared UIApplication instance, or nil if running in an App Extension
|
|
|
|
RCT_EXTERN UIApplication *RCTSharedApplication(void);
|
|
|
|
|
2015-11-05 14:49:41 +03:00
|
|
|
// Returns the current main window, useful if you need to access the root view
|
|
|
|
// or view controller, e.g. to present a modal view controller or alert.
|
|
|
|
RCT_EXTERN UIWindow *RCTKeyWindow(void);
|
|
|
|
|
2015-09-22 20:43:56 +03:00
|
|
|
// Return a UIAlertView initialized with the given values
|
|
|
|
// or nil if running in an app extension
|
2015-11-04 01:45:46 +03:00
|
|
|
RCT_EXTERN UIAlertView *RCTAlertView(NSString *title,
|
|
|
|
NSString *message,
|
|
|
|
id delegate,
|
|
|
|
NSString *cancelButtonTitle,
|
|
|
|
NSArray<NSString *> *otherButtonTitles);
|
2015-09-22 20:43:56 +03:00
|
|
|
|
2015-05-22 17:17:08 +03:00
|
|
|
// Return YES if image has an alpha component
|
|
|
|
RCT_EXTERN BOOL RCTImageHasAlpha(CGImageRef image);
|
2015-06-09 16:46:49 +03:00
|
|
|
|
2015-07-07 18:47:23 +03:00
|
|
|
// Create an NSError in the RCTErrorDomain
|
2015-06-09 22:25:24 +03:00
|
|
|
RCT_EXTERN NSError *RCTErrorWithMessage(NSString *message);
|
|
|
|
|
|
|
|
// Convert nil values to NSNull, and vice-versa
|
2015-06-09 16:46:49 +03:00
|
|
|
RCT_EXTERN id RCTNilIfNull(id value);
|
2015-07-13 20:33:39 +03:00
|
|
|
RCT_EXTERN id RCTNullIfNil(id value);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-25 02:34:56 +03:00
|
|
|
|
2015-07-13 20:33:39 +03:00
|
|
|
// Convert data to a Base64-encoded data URL
|
|
|
|
RCT_EXTERN NSURL *RCTDataURL(NSString *mimeType, NSData *data);
|
2015-07-16 19:34:28 +03:00
|
|
|
|
|
|
|
// Gzip functionality - compression level in range 0 - 1 (-1 for default)
|
|
|
|
RCT_EXTERN NSData *RCTGzipData(NSData *data, float level);
|
2015-10-12 14:14:21 +03:00
|
|
|
|
|
|
|
// Returns the relative path within the main bundle for an absolute URL
|
|
|
|
// (or nil, if the URL does not specify a path within the main bundle)
|
|
|
|
RCT_EXTERN NSString *RCTBundlePathForURL(NSURL *URL);
|
|
|
|
|
|
|
|
// Determines if a given image URL actually refers to an XCAsset
|
|
|
|
RCT_EXTERN BOOL RCTIsXCAssetURL(NSURL *imageURL);
|