PDRCoreDefs.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // PDRCoreDefs.h
  3. // PDRCore
  4. //
  5. // Created by X on 14-2-11.
  6. // Copyright (c) 2014年 io.dcloud. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. UIKIT_EXTERN NSString *const PDRCoreOpenUrlNotification;
  11. UIKIT_EXTERN NSString *const PDRCoreOpenUniversalLinksNotification;
  12. UIKIT_EXTERN NSString *const PDRCoreRevDeviceToken;
  13. UIKIT_EXTERN NSString *const PDRCoreRegRemoteNotificationsError;
  14. #if __has_feature(objc_arc)
  15. #define H5_AUTORELEASE(exp) exp
  16. #define H5_RELEASE(exp) exp
  17. #define H5_RETAIN(exp) exp
  18. #else
  19. #define H5_AUTORELEASE(exp) [exp autorelease]
  20. #define H5_RELEASE(exp) [exp release]
  21. #define H5_RETAIN(exp) [exp retain]
  22. #endif
  23. #ifndef H5_STRONG
  24. #if __has_feature(objc_arc)
  25. #define H5_STRONG strong
  26. #else
  27. #define H5_STRONG retain
  28. #endif
  29. #endif
  30. #ifndef H5_WEAK
  31. #if __has_feature(objc_arc_weak)
  32. #define H5_WEAK weak
  33. #elif __has_feature(objc_arc)
  34. #define H5_WEAK unsafe_unretained
  35. #else
  36. #define H5_WEAK assign
  37. #endif
  38. #endif
  39. #if DEBUG
  40. #define H5CORE_LOG NSLog
  41. #else
  42. #define H5CORE_LOG
  43. #endif
  44. #define kPDRCoreAppWindowAnimationDefaltDuration .3f
  45. typedef NS_ENUM(NSInteger, PDRCoreRunMode) {
  46. /**
  47. 正常启动runtime
  48. 使用该方法启动runtime具有全部功能
  49. 包括具有应用管理、窗口管理、插件管理、权限管理、资源管理等功能
  50. */
  51. PDRCoreRunModeNormal = 0,
  52. /**
  53. 使用该方法启动的runtime不具有应用管理窗口管理功能
  54. 当需要显示页面时,需要自己创建PDRCoreAppFrame
  55. */
  56. PDRCoreRunModeWebviewClient = 1,
  57. /**
  58. 使用该方法启动的runtime具有正常启动所有功能但不包含启动图片
  59. 应用升级、应用copy运行逻辑,该启动会自动启动app管理器但
  60. 不会自动创建app,需要自己创建app
  61. */
  62. PDRCoreRunModeAppClient
  63. };
  64. /// 系统事件类型定义
  65. typedef NS_ENUM(NSInteger, PDRCoreSysEvent) {
  66. /// 网络状态改变事件 Reserved
  67. PDRCoreSysEventNetChange = 1,
  68. /// 程序进入后台事件
  69. PDRCoreSysEventEnterBackground,
  70. /// 程序进入前台事件
  71. PDRCoreSysEventEnterForeGround,
  72. /// 打开URL事件
  73. PDRCoreSysEventOpenURL,
  74. /// 打开URL事件带参数
  75. PDRCoreSysEventOpenURLWithOptions,
  76. /// 本地自定义消息提醒
  77. PDRCoreSysEventRevLocalNotification,
  78. /// APNS事件
  79. PDRCoreSysEventRevRemoteNotification,
  80. /// 获取到APNS DeviceToken事件
  81. PDRCoreSysEventRevDeviceToken,
  82. /// 获取到APNS错误
  83. PDRCoreSysEventRegRemoteNotificationsError,
  84. /// 低内存警告
  85. PDRCoreSysEventReceiveMemoryWarning,
  86. /// 屏幕旋转事件 Reserved
  87. PDRCoreSysEventInterfaceOrientation,
  88. /// 按键事件
  89. PDRCoreSysEventKeyEvent,
  90. /// 全屏
  91. PDRCoreSysEventEnterFullScreen,
  92. /// 点击了shortcut Reserved
  93. PDRCoreSysEventPeekQuickAction,
  94. /// 应用暂停,被其他应用覆盖
  95. PDRCoreSysEventResignActive,
  96. /// 应用被激活,重新处于活动状态
  97. PDRCoreSysEventBecomeActive,
  98. /// 系统主动触发状态栏隐藏显示
  99. PDRCoreSysEventStatusbarChange,
  100. /// 执行weex post mesasge
  101. PDRCoreSysEventWeexPostMessage,
  102. /// 打印weex log
  103. PDRCoreSysEventWeexOutputLog,
  104. /// 执行weex post mesasge
  105. PDRCoreSysEventPostMessageToWeexControl,
  106. ///通用链接
  107. PDRCoreSysEventContinueUserActivity,
  108. ///weex内核重新启动事件
  109. PDRCoreSysEventWeexSDKEngineRestart
  110. };
  111. /// app Statusbar style
  112. typedef enum {
  113. //深色背景样式(深色底白字,即状态栏前景文字为白色),此时background建议设置为深颜色
  114. PDRCoreStatusBarStyleLight,
  115. //浅色背景样色(浅色底黑字,即状态栏前景文字为黑色),此时background建设设置为浅颜色
  116. PDRCoreStatusBarStyleDark
  117. } PDRCoreStatusBarStyle;
  118. typedef NS_ENUM(NSInteger, PDRCoreStatusBarMode) {
  119. PDRCoreStatusBarModeNormal = 1,
  120. PDRCoreStatusBarModeImmersion
  121. };
  122. /// runtime错误码定义
  123. enum {
  124. PDRCoreSuccess = 0,
  125. PDRCoreNetObserverCreateError = 1,
  126. PDRCoreInvalidParamError,
  127. PDRCoreFileNotExistError,
  128. PDRCorePandoraApibundleMiss,
  129. PDRCoreStatusError,
  130. PDRCoreNetError,
  131. PDRCoreUnknownError,
  132. /// 资源管理器启动失败
  133. PDRCoreErrorResManagerBase = 10000,
  134. /// 应用管理类错误
  135. PDRCoreErrorAppManagerBase = 20000,
  136. PDRCoreErrorDownloadStreamJSON,
  137. PDRCoreErrorStreamJSONFormat,
  138. PDRCoreErrorDownloadIndexPage,
  139. PDRCoreErrorUsercancel,
  140. PDRCoreInvalidMainpageError,
  141. /// 无效的mainfest文件
  142. PDRCoreAppInvalidMainfestError
  143. };
  144. #define kAppManagerOpenAppMaxDefalut 3
  145. #define kWindowAppBarViewHeight (44)
  146. #define kWindowTitleNViewHeight (44)
  147. #define kWindowTitleNView_btn_W (41)
  148. #define kWindowStatusBarViewHeight (20)
  149. #define kWindowNavStatusbarViewHeight (([PTDeviceOSInfo deviceType]==PTDeviceTypeiPhoneX)?44:20)
  150. #define DCCoreWeexBridge ([PDRCore Instance].weexImport)
  151. @interface H5Server : NSObject
  152. + (NSString*)identifier;
  153. - (void)onCreate;
  154. - (void)onDestroy;
  155. @end
  156. typedef void (^H5CoreComplete)(id);