123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- #ifdef SHOULD_COMPILE_LOOKIN_SERVER
- //
- // LookinMessageProtocol.h
- // Lookin
- //
- // Created by Li Kai on 2018/8/6.
- // https://lookin.work
- //
- #import "TargetConditionals.h"
- #if TARGET_OS_IPHONE
- #import <UIKit/UIKit.h>
- #elif TARGET_OS_MAC
- #import <Appkit/Appkit.h>
- #endif
- #include <stdint.h>
- #pragma mark - Version
- /// current connection protocol version of LookinServer
- static const int LOOKIN_SERVER_VERSION = 7;
- /// current release version of LookinServer
- static NSString * const LOOKIN_SERVER_READABLE_VERSION = @"1.1.5";
- /// current connection protocol version of LookinClient
- static const int LOOKIN_CLIENT_VERSION = 7;
- /// the minimum connection protocol version supported by current LookinClient
- static const int LOOKIN_SUPPORTED_SERVER_MIN = 7;
- /// the maximum connection protocol version supported by current LookinClient
- static const int LOOKIN_SUPPORTED_SERVER_MAX = 7;
- /// Legacy code. No effect actually.
- static BOOL LOOKIN_SERVER_IS_EXPERIMENTAL = NO;
- static BOOL LOOKIN_CLIENT_IS_EXPERIMENTAL = NO;
- static const int LOOKIN_SERVER_SETUP_TYPE = 1;
- static NSString * const LOOKIN_SERVER_FRAMEWORK_URL = @"https://lookin.work/download/framework/LookinServer-1-0-0.zip";
- #pragma mark - Connection
- /// LookinServer 在真机上会依次尝试监听 47175 ~ 47179 这几个端口
- static const int LookinUSBDeviceIPv4PortNumberStart = 47175;
- static const int LookinUSBDeviceIPv4PortNumberEnd = 47179;
- /// LookinServer 在模拟器中会依次尝试监听 47164 ~ 47169 这几个端口
- static const int LookinSimulatorIPv4PortNumberStart = 47164;
- static const int LookinSimulatorIPv4PortNumberEnd = 47169;
- enum {
- /// 确认两端是否可以响应通讯
- LookinRequestTypePing = 200,
- /// 请求 App 的截图、设备型号等信息
- LookinRequestTypeApp = 201,
- /// 请求 Hierarchy 信息
- LookinRequestTypeHierarchy = 202,
- /// 请求 screenshots 和 attrGroups 信息
- LookinRequestTypeHierarchyDetails = 203,
- /// 请求修改某个 Attribute 的值
- LookinRequestTypeModification = 204,
- /// 修改某个 attr 后,请求一系列最新的 Screenshots、属性值等信息
- LookinRequestTypeAttrModificationPatch = 205,
- /// 执行某个方法
- LookinRequestTypeInvokeMethod = 206,
- /**
- @request: @{@"oid":}
- @response: LookinObject *
- */
- LookinRequestTypeFetchObject = 207,
-
- LookinRequestTypeFetchImageViewImage = 208,
-
- LookinRequestTypeModifyRecognizerEnable = 209,
-
- /// 请求 attribute group list
- LookinRequestTypeAllAttrGroups = 210,
-
- /// 请求 iOS App 里所有的 class 名字列表和监听中的方法列表
- LookinRequestTypeClassesAndMethodTraceLit = 212,
-
- /// 请求 iOS App 里某个 class 的所有 selector 名字列表(包括 superclass)
- LookinRequestTypeAllSelectorNames = 213,
-
- // 增加 methodTrace
- LookinRequestTypeAddMethodTrace = 214,
- // 删除 methodTrace
- LookinRequestTypeDeleteMethodTrace = 215,
- LookinPush_BringForwardScreenshotTask = 303,
- // 用户在 Lookin 客户端取消了之前 HierarchyDetails 的拉取
- LookinPush_CanceHierarchyDetails = 304,
-
- /// iOS 端推送 method trace 信息
- LookinPush_MethodTraceRecord = 403
- };
- static NSString * const LookinParam_ViewLayerTag = @"tag";
- static NSString * const LookinParam_SelectorName = @"sn";
- static NSString * const LookinParam_MethodType = @"mt";
- static NSString * const LookinParam_SelectorClassName = @"scn";
- static NSString * const LookinStringFlag_VoidReturn = @"LOOKIN_TAG_RETURN_VALUE_VOID";
- #pragma mark - Error
- static NSString * const LookinErrorDomain = @"LookinError";
- enum {
- LookinErrCode_Default = -400,
- /// Lookin 内部业务逻辑错误
- LookinErrCode_Inner = -401,
- /// PeerTalk 内部错误
- LookinErrCode_PeerTalk = -402,
- /// 连接不存在或已断开
- LookinErrCode_NoConnect = -403,
- /// ping 失败了,原因是 ping 请求超时
- LookinErrCode_PingFailForTimeout = -404,
- /// 请求超时未返回
- LookinErrCode_Timeout = -405,
- /// 有相同 Type 的新请求被发出,因此旧请求被丢弃
- LookinErrCode_Discard = -406,
- /// ping 失败了,原因是 app 主动报告自身正处于后台模式
- LookinErrCode_PingFailForBackgroundState = -407,
-
- /// 没有找到对应的对象,可能已被释放
- LookinErrCode_ObjectNotFound = -500,
- /// 不支持修改当前类型的 LookinCodingValueType
- LookinErrCode_ModifyValueTypeInvalid = -501,
- LookinErrCode_Exception = -502,
-
- // LookinServer 版本过高,要升级 client
- LookinErrCode_ServerVersionTooHigh = -600,
- // LookinServer 版本过低,要升级 server
- LookinErrCode_ServerVersionTooLow = -601,
- // LookinServer 是私有版本,但 client 是现网版本
- LookinErrCode_ServerIsPrivate = -602,
- // LookinServer 是现网版本,但 client 是私有版本
- LookinErrCode_ClientIsPrivate = - 603,
-
- // 不支持的文件类型
- LookinErrCode_UnsupportedFileType = -700,
- };
- #define LookinErr_ObjNotFound [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_ObjectNotFound userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"Failed to get target object in iOS app", nil), NSLocalizedRecoverySuggestionErrorKey:NSLocalizedString(@"Perhaps the related object was deallocated. You can reload Lookin to get newest data.", nil)}]
- #define LookinErr_NoConnect [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_NoConnect userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"The operation failed due to disconnection with the iOS app.", nil)}]
- #define LookinErr_Inner [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_Inner userInfo:@{NSLocalizedDescriptionKey:NSLocalizedString(@"The operation failed due to an inner error.", nil)}]
- #define LookinErrorMake(errorTitle, errorDetail) [NSError errorWithDomain:LookinErrorDomain code:LookinErrCode_Default userInfo:@{NSLocalizedDescriptionKey:errorTitle, NSLocalizedRecoverySuggestionErrorKey:errorDetail}]
- #define LookinErrorText_Timeout NSLocalizedString(@"Perhaps your iOS app is paused with breakpoint in Xcode, blocked by other tasks in main thread, or moved to background state.", nil)
- #pragma mark - Colors
- #if TARGET_OS_IPHONE
- #define LookinColor UIColor
- #define LookinInsets UIEdgeInsets
- #define LookinImage UIImage
- #elif TARGET_OS_MAC
- #define LookinColor NSColor
- #define LookinInsets NSEdgeInsets
- #define LookinImage NSImage
- #endif
- #define LookinColorRGBAMake(r, g, b, a) [LookinColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
- #define LookinColorMake(r, g, b) [LookinColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
- #pragma mark - Preview
- /// SCNNode 所允许的图片的最大的长和宽,单位是 px,这个值是 Scenekit 自身指定的
- /// Max pixel size of a SCNNode object. It is designated by SceneKit.
- static const double LookinNodeImageMaxLengthInPx = 16384;
- typedef NS_OPTIONS(NSUInteger, LookinPreviewBitMask) {
- LookinPreviewBitMask_None = 0,
-
- LookinPreviewBitMask_Selectable = 1 << 1,
- LookinPreviewBitMask_Unselectable = 1 << 2,
-
- LookinPreviewBitMask_HasLight = 1 << 3,
- LookinPreviewBitMask_NoLight = 1 << 4
- };
- #endif /* SHOULD_COMPILE_LOOKIN_SERVER */
|