1 // Copyright 2022-present 650 Industries. All rights reserved. 2 3 #import <Foundation/Foundation.h> 4 #import <ExpoModulesCore/EXJavaScriptObject.h> 5 6 #ifdef __cplusplus 7 #import <jsi/jsi.h> 8 namespace jsi = facebook::jsi; 9 #endif // __cplusplus 10 11 @class EXJavaScriptRuntime; 12 13 /** 14 Represents any JavaScript value. Its purpose is to exposes `facebook::jsi::Value` API back to Swift. 15 */ 16 NS_SWIFT_NAME(JavaScriptValue) 17 @interface EXJavaScriptValue : NSObject 18 19 #ifdef __cplusplus 20 - (nonnull instancetype)initWithRuntime:(nonnull EXJavaScriptRuntime *)runtime 21 value:(std::shared_ptr<jsi::Value>)value; 22 #endif // __cplusplus 23 24 #pragma mark - Type checking 25 26 - (BOOL)isUndefined; 27 - (BOOL)isNull; 28 - (BOOL)isBool; 29 - (BOOL)isNumber; 30 - (BOOL)isString; 31 - (BOOL)isSymbol; 32 - (BOOL)isObject; 33 - (BOOL)isFunction; 34 35 + (nonnull NSString *)kindOf:(nonnull EXJavaScriptValue *)value; 36 37 #pragma mark - Type casting 38 39 - (nullable id)getRaw; 40 - (BOOL)getBool; 41 - (NSInteger)getInt; 42 - (double)getDouble; 43 - (nonnull NSString *)getString; 44 - (nonnull NSArray<EXJavaScriptValue *> *)getArray; 45 - (nonnull NSDictionary<NSString *, id> *)getDictionary; 46 - (nonnull EXJavaScriptObject *)getObject; 47 48 #pragma mark - Helpers 49 50 - (nonnull NSString *)toString; 51 52 @end 53