WXSDKEngine.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing,
  13. * software distributed under the License is distributed on an
  14. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  15. * KIND, either express or implied. See the License for the
  16. * specific language governing permissions and limitations
  17. * under the License.
  18. */
  19. #import <Foundation/Foundation.h>
  20. @class WXSDKInstance;
  21. @interface WXSDKEngine : NSObject
  22. /**
  23. * @abstract Register default modules/components/handlers, they will be registered only once.
  24. **/
  25. + (void)registerDefaults;
  26. /**
  27. * @abstract Register a module for a given name
  28. *
  29. * @param name The module name to register
  30. *
  31. * @param clazz The module class to register
  32. *
  33. **/
  34. + (void)registerModule:(NSString *)name withClass:(Class)clazz;
  35. /**
  36. * @abstract Registers a component for a given name
  37. *
  38. * @param name The component name to register
  39. *
  40. * @param clazz The WXComponent subclass to register
  41. *
  42. **/
  43. + (void)registerComponent:(NSString *)name withClass:(Class)clazz;
  44. /**
  45. * @abstract Registers a extendCallNative Class for a given name
  46. *
  47. * @param name The extendCallNative name to register
  48. *
  49. * @param clazz The extendCallNative subclass to register
  50. *
  51. **/
  52. + (void)registerExtendCallNative:(NSString *)name withClass:(Class)clazz;
  53. /**
  54. * @abstract Registers a component for a given name and specific properties
  55. *
  56. * @param name The component name to register
  57. *
  58. * @param clazz The WXComponent subclass to register
  59. *
  60. * @param properties properties to apply to the component
  61. *
  62. */
  63. + (void)registerComponent:(NSString *)name withClass:(Class)clazz withProperties:(NSDictionary *)properties;
  64. /**
  65. * @abstract Registers a component for a given name, options and js code
  66. *
  67. * @param name The service name to register
  68. *
  69. * @param options The service options to register
  70. *
  71. * @param serviceScript service js code to invoke
  72. *
  73. */
  74. + (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options;
  75. /**
  76. * @abstract Registers a component for a given name, options and js code
  77. *
  78. * @param name The service name to register
  79. *
  80. * @param options The service options to register
  81. *
  82. * @param serviceScript service js code to invoke
  83. *
  84. * @param completion Completion callback. JS is executed in asynchronously.
  85. *
  86. */
  87. + (void)registerService:(NSString *)name withScript:(NSString *)serviceScript withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;
  88. /**
  89. * @abstract Registers a component for a given name, options and js url
  90. *
  91. * @param name The service name to register
  92. *
  93. * @param options The service options to register
  94. *
  95. * @param serviceScriptUrl The service url to register
  96. *
  97. */
  98. + (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options;
  99. /**
  100. * @abstract Registers a component for a given name, options and js url
  101. *
  102. * @param name The service name to register
  103. *
  104. * @param options The service options to register
  105. *
  106. * @param serviceScriptUrl The service url to register
  107. *
  108. * @param completion Completion callback. JS is executed in asynchronously.
  109. *
  110. */
  111. + (void)registerService:(NSString *)name withScriptUrl:(NSURL *)serviceScriptUrl withOptions:(NSDictionary *)options completion:(void(^)(BOOL result))completion;
  112. /**
  113. * @abstract Registers a component for a given name, options and js code
  114. *
  115. * @param name The name of register service
  116. *
  117. */
  118. + (void)unregisterService:(NSString *)name;
  119. /**
  120. * @abstract Registers a handler for a given handler instance and specific protocol
  121. *
  122. * @param handler The handler instance to register
  123. *
  124. * @param protocol The protocol to confirm
  125. *
  126. */
  127. + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol;
  128. /**
  129. * @abstract Returns a given handler instance for specific protocol
  130. *
  131. * @param protocol The protocol to confirm
  132. *
  133. */
  134. + (id)handlerForProtocol:(Protocol *)protocol;
  135. /**
  136. * @abstract Initializes the global sdk environment
  137. *
  138. * @discussion Injects main.js in app bundle as default JSFramework script.
  139. *
  140. **/
  141. + (void)initSDKEnvironment;
  142. /**
  143. * @abstract Initializes the environment with a given JSFramework script.
  144. *
  145. **/
  146. + (void)initSDKEnvironment:(NSString *)script;
  147. /**
  148. * @abstract Unloads the bridge context
  149. *
  150. **/
  151. + (void)unload;
  152. /**
  153. * @abstract restart Weex Engine.
  154. **/
  155. + (void)restart;
  156. /**
  157. * @abstract restart Weex Engine with specify jsfm.
  158. **/
  159. + (void)restartWithScript:(NSString*)script;
  160. /**
  161. * @abstract Returns the version of SDK
  162. *
  163. **/
  164. + (NSString*)SDKEngineVersion;
  165. /**
  166. * @abstract The Instance at the top of the rendering stack.
  167. *
  168. **/
  169. + (WXSDKInstance *)topInstance;
  170. /**
  171. * @abstract Add custom environment variables
  172. * @discuss These variables can be obtained by $getConfig().env
  173. *
  174. **/
  175. + (void)setCustomEnvironment:(NSDictionary *)environment;
  176. + (NSDictionary *)customEnvironment;
  177. /**
  178. * @abstract Connects to websocket for collecting log
  179. *
  180. * @param URL The URL of websocket to connect
  181. *
  182. */
  183. + (void)connectDebugServer:(NSString*)URL;
  184. /**
  185. * @abstract Connects to websocket for devtool debug
  186. *
  187. * @param URL The URL of websocket to connect
  188. *
  189. */
  190. + (void)connectDevToolServer:(NSString *)URL;
  191. @end
  192. @interface WXSDKEngine (Deprecated)
  193. + (void)initSDKEnviroment DEPRECATED_MSG_ATTRIBUTE("To fix typo, use initSDKEnvironment method instead.");
  194. + (void)initSDKEnviroment:(NSString *)script DEPRECATED_MSG_ATTRIBUTE("To fix typo, use initSDKEnvironment: method instead.");
  195. @end