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 23 /** 24 \return the underlying `jsi::Value`. 25 */ 26 - (nonnull jsi::Value *)get; 27 #endif // __cplusplus 28 29 #pragma mark - Type checking 30 31 - (BOOL)isUndefined; 32 - (BOOL)isNull; 33 - (BOOL)isBool; 34 - (BOOL)isNumber; 35 - (BOOL)isString; 36 - (BOOL)isSymbol; 37 - (BOOL)isObject; 38 - (BOOL)isFunction; 39 40 + (nonnull NSString *)kindOf:(nonnull EXJavaScriptValue *)value; 41 42 #pragma mark - Type casting 43 44 - (nullable id)getRaw; 45 - (BOOL)getBool; 46 - (NSInteger)getInt; 47 - (double)getDouble; 48 - (nonnull NSString *)getString; 49 - (nonnull NSArray<EXJavaScriptValue *> *)getArray; 50 - (nonnull NSDictionary<NSString *, id> *)getDictionary; 51 - (nonnull EXJavaScriptObject *)getObject; 52 53 #pragma mark - Helpers 54 55 - (nonnull NSString *)toString; 56 57 @end 58