sparkling-method 2.0.0-rc.0 → 2.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (290) hide show
  1. package/README.md +39 -0
  2. package/android/build.gradle.kts +153 -0
  3. package/android/gradle.properties +1 -0
  4. package/android/proguard-rules.pro +21 -0
  5. package/android/src/androidTest/java/com/tiktok/sparkling/sparkling/methods/ExampleInstrumentedTest.kt +27 -0
  6. package/android/src/main/AndroidManifest.xml +5 -0
  7. package/android/src/main/java/com/tiktok/sparkling/method/protocol/BridgeContext.kt +74 -0
  8. package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImp.kt +47 -0
  9. package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImp.kt +233 -0
  10. package/android/src/main/java/com/tiktok/sparkling/method/protocol/InnerBridge.kt +134 -0
  11. package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeCall.kt +79 -0
  12. package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeResult.kt +68 -0
  13. package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcher.kt +198 -0
  14. package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManager.kt +16 -0
  15. package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcher.kt +56 -0
  16. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModel.kt +144 -0
  17. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptor.kt +30 -0
  18. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModel.kt +66 -0
  19. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModule.kt +31 -0
  20. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtol.kt +69 -0
  21. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModule.kt +31 -0
  22. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxViewImpl.kt +29 -0
  23. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegate.kt +147 -0
  24. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitor.kt +239 -0
  25. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/IBridgeMonitor.kt +17 -0
  26. package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntity.kt +22 -0
  27. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeCallback.kt +14 -0
  28. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeClient.kt +19 -0
  29. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeHandler.kt +23 -0
  30. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeLifeClient.kt +45 -0
  31. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeMethodCallback.kt +10 -0
  32. package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeProtocol.kt +22 -0
  33. package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConstants.kt +13 -0
  34. package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConverter.kt +147 -0
  35. package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/LogUtils.kt +37 -0
  36. package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/MonitorUtils.kt +41 -0
  37. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeLocalPool.kt +70 -0
  38. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeSettings.kt +19 -0
  39. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BusinessCallHandler.kt +100 -0
  40. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/CancelCallbackConfig.kt +13 -0
  41. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/DefaultCallHandler.kt +106 -0
  42. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/IBridgeMethod.kt +118 -0
  43. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/PiperDataExt.kt +71 -0
  44. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/SparklingBridge.kt +374 -0
  45. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/Utils.kt +89 -0
  46. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/interfaces/IBridgeNotFound.kt +11 -0
  47. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxDataProcessorForMap.kt +204 -0
  48. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxPlatformDataProcessor.kt +239 -0
  49. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebPlatformDataProcessor.kt +307 -0
  50. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebProcessorForMap.kt +227 -0
  51. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeMethodCallbackHelper.kt +29 -0
  52. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeProtocolConstants.kt +12 -0
  53. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtils.kt +684 -0
  54. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/IConvertUtils.kt +44 -0
  55. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/LogHelper.kt +30 -0
  56. package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/ThreadPool.kt +73 -0
  57. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgeCollections.kt +194 -0
  58. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgePlatformType.kt +13 -0
  59. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IBridgeContext.kt +137 -0
  60. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLBridgeMethod.kt +100 -0
  61. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodProvider.kt +13 -0
  62. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistry.kt +132 -0
  63. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCache.kt +150 -0
  64. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCacheManager.kt +34 -0
  65. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLProxyClient.kt +28 -0
  66. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IRegister.kt +21 -0
  67. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/LocalBridge.kt +70 -0
  68. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/ReadableMapImpl.kt +227 -0
  69. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/RegistryCache.kt +77 -0
  70. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManager.kt +50 -0
  71. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodIntEnum.kt +15 -0
  72. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodName.kt +17 -0
  73. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamField.kt +42 -0
  74. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamModel.kt +13 -0
  75. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodResultModel.kt +13 -0
  76. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodStringEnum.kt +15 -0
  77. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethod.kt +276 -0
  78. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodException.kt +10 -0
  79. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalInputParamException.kt +12 -0
  80. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOperationException.kt +12 -0
  81. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOutputParamException.kt +13 -0
  82. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IContainerIDProvider.kt +13 -0
  83. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/INameSpaceProvider.kt +13 -0
  84. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IPlatformDataProcessor.kt +19 -0
  85. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IReleasable.kt +13 -0
  86. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/BridgeCallThreadTypeConfig.kt +44 -0
  87. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/ContextProviderFactory.kt +133 -0
  88. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/CompletionBlock.kt +26 -0
  89. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLDynamic.kt +97 -0
  90. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseModel.kt +37 -0
  91. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseParamModel.kt +62 -0
  92. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseResultModel.kt +18 -0
  93. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/BridgeKTX.kt +37 -0
  94. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IAssignDir.kt +25 -0
  95. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodHelper.kt +44 -0
  96. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelArguments.kt +264 -0
  97. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelHelper.kt +194 -0
  98. package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/JsonUtils.kt +200 -0
  99. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntime.kt +11 -0
  100. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/CommonDependsProvider.kt +14 -0
  101. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostNetworkDepend.kt +19 -0
  102. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostPermissionDepend.kt +34 -0
  103. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostThreadPoolExecutorDepend.kt +12 -0
  104. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStreamConnection.kt +36 -0
  105. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStringConnection.kt +30 -0
  106. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/HttpRequest.kt +134 -0
  107. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/NetworkRequestImpl.kt +28 -0
  108. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/RequestJsonFormatOptionConstants.kt +10 -0
  109. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/BridgeAPIRequestUtils.kt +365 -0
  110. package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/HttpUrlBuilder.kt +97 -0
  111. package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
  112. package/android/src/main/res/drawable/ic_launcher_foreground.xml +30 -0
  113. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
  114. package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
  115. package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
  116. package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
  117. package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
  118. package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
  119. package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
  120. package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
  121. package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
  122. package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
  123. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
  124. package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
  125. package/android/src/main/res/values/colors.xml +10 -0
  126. package/android/src/main/res/values/strings.xml +3 -0
  127. package/android/src/test/java/com/tiktok/sparkling/method/TestApplication.kt +19 -0
  128. package/android/src/test/java/com/tiktok/sparkling/method/protocol/BridgeContextTest.kt +89 -0
  129. package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImpTest.kt +78 -0
  130. package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImpTest.kt +97 -0
  131. package/android/src/test/java/com/tiktok/sparkling/method/protocol/InnerBridgeTest.kt +105 -0
  132. package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeCallTest.kt +61 -0
  133. package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeResultTest.kt +74 -0
  134. package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcherTest.kt +96 -0
  135. package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManagerTest.kt +21 -0
  136. package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcherTest.kt +34 -0
  137. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModelTest.kt +60 -0
  138. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptorTest.kt +51 -0
  139. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModelTest.kt +65 -0
  140. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModuleTest.kt +57 -0
  141. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtocolTest.kt +10 -0
  142. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModuleTest.kt +37 -0
  143. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegateTest.kt +10 -0
  144. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitorTest.kt +10 -0
  145. package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntityTest.kt +43 -0
  146. package/android/src/test/java/com/tiktok/sparkling/method/registry/api/SparklingBridgeTest.kt +444 -0
  147. package/android/src/test/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtilsTest.kt +236 -0
  148. package/android/src/test/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryTest.kt +331 -0
  149. package/android/src/test/java/com/tiktok/sparkling/method/registry/core/LocalBridgeTest.kt +299 -0
  150. package/android/src/test/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManagerTest.kt +213 -0
  151. package/android/src/test/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethodTest.kt +307 -0
  152. package/android/src/test/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodExceptionTest.kt +311 -0
  153. package/android/src/test/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntimeTest.kt +54 -0
  154. package/android/src/test/resources/robolectric.properties +5 -0
  155. package/dist/index.d.ts +55 -2
  156. package/dist/index.d.ts.map +1 -1
  157. package/dist/index.js +181 -52
  158. package/dist/index.js.map +1 -1
  159. package/dist/types.d.ts +37 -0
  160. package/dist/types.d.ts.map +1 -0
  161. package/dist/types.js +5 -0
  162. package/dist/types.js.map +1 -0
  163. package/dist/typing.d.ts +44 -0
  164. package/ios/Sources/Core/DI/DIContainerProtocol.swift +27 -0
  165. package/ios/Sources/Core/DI/DIContainerProvider.swift +10 -0
  166. package/ios/Sources/Core/DI/DIProviderRegistry.swift +21 -0
  167. package/ios/Sources/Core/Definitions/CommonDefines.swift +17 -0
  168. package/ios/Sources/Core/Examples/SampleMethod+impl.swift +24 -0
  169. package/ios/Sources/Core/Examples/SampleMethod.swift +58 -0
  170. package/ios/Sources/Core/Models/MethodContext.swift +53 -0
  171. package/ios/Sources/Core/Models/MethodStatus.swift +146 -0
  172. package/ios/Sources/Core/Models/SPKAutoRegisteringMethod.swift +7 -0
  173. package/ios/Sources/Core/Pipe/MethodPipe+Internal.swift +87 -0
  174. package/ios/Sources/Core/Pipe/MethodPipe.swift +45 -0
  175. package/ios/Sources/Core/Pipe/MethodRegistry.swift +97 -0
  176. package/ios/Sources/Core/Protocols/DictionaryCodable.swift +10 -0
  177. package/ios/Sources/Core/Protocols/MethodModel.swift +143 -0
  178. package/ios/Sources/Core/Protocols/MethodPipeFacade.swift +16 -0
  179. package/ios/Sources/Core/Protocols/PipeContainer.swift +21 -0
  180. package/ios/Sources/Core/Protocols/PipeEngine.swift +10 -0
  181. package/ios/Sources/Core/Protocols/PipeMethod.swift +83 -0
  182. package/ios/Sources/Core/Protocols/PipeRuntime.swift +9 -0
  183. package/ios/Sources/Core/Utils/AnyCodableValue.swift +128 -0
  184. package/ios/Sources/Core/Utils/CoreUtils.swift +17 -0
  185. package/ios/Sources/Core/Utils/NSString+SPKBridgeAdditions.swift +35 -0
  186. package/ios/Sources/Core/Utils/ReadWriteLock.swift +33 -0
  187. package/ios/Sources/Core/Utils/SPKHttpResponseChromium.swift +24 -0
  188. package/ios/Sources/Core/Utils/SPKNetworkManager.swift +200 -0
  189. package/ios/Sources/Core/Utils/SPKReachability.swift +46 -0
  190. package/ios/Sources/DIProvider/DIContainer.swift +80 -0
  191. package/ios/Sources/DIProvider/DefaultDIContainerProvider.swift +21 -0
  192. package/ios/Sources/Debug/MethodPipe+Debug.swift +36 -0
  193. package/ios/Sources/Lynx/Definitions/LynxConstants.swift +19 -0
  194. package/ios/Sources/Lynx/Definitions/LynxPipeStatusCode.swift +26 -0
  195. package/ios/Sources/Lynx/Definitions/LynxTypealiases.swift +7 -0
  196. package/ios/Sources/Lynx/Engine/LynxConfig+SPKPipe.swift +31 -0
  197. package/ios/Sources/Lynx/Engine/LynxContext+SPKPipe.swift +21 -0
  198. package/ios/Sources/Lynx/Engine/LynxPipeEngine.swift +52 -0
  199. package/ios/Sources/Lynx/Engine/LynxPipeEnginePool.swift +41 -0
  200. package/ios/Sources/Lynx/Engine/LynxView+SPKPipe.swift +64 -0
  201. package/ios/Sources/Lynx/Engine/SPKLynxModuleService.swift +23 -0
  202. package/ios/Sources/Lynx/Models/LynxRecvMessage.swift +31 -0
  203. package/ios/Sources/Lynx/Models/LynxSendMessage.swift +55 -0
  204. package/ios/Sources/Lynx/Module/SPKLynxNativeModule.swift +41 -0
  205. package/ios/Sources/Lynx/Pipe/MethodPipe+Lynx.swift +53 -0
  206. package/ios/SparklingMethod.podspec +65 -0
  207. package/package.json +11 -29
  208. package/src/index.ts +240 -0
  209. package/src/types.ts +44 -0
  210. package/src/typing.d.ts +44 -0
  211. package/tsconfig.json +15 -0
  212. package/dist/codegen/definition-parser.d.ts +0 -5
  213. package/dist/codegen/definition-parser.d.ts.map +0 -1
  214. package/dist/codegen/definition-parser.js +0 -376
  215. package/dist/codegen/definition-parser.js.map +0 -1
  216. package/dist/codegen/index.d.ts +0 -3
  217. package/dist/codegen/index.d.ts.map +0 -1
  218. package/dist/codegen/index.js +0 -99
  219. package/dist/codegen/index.js.map +0 -1
  220. package/dist/codegen/kotlin.d.ts +0 -4
  221. package/dist/codegen/kotlin.d.ts.map +0 -1
  222. package/dist/codegen/kotlin.js +0 -273
  223. package/dist/codegen/kotlin.js.map +0 -1
  224. package/dist/codegen/metadata.d.ts +0 -4
  225. package/dist/codegen/metadata.d.ts.map +0 -1
  226. package/dist/codegen/metadata.js +0 -78
  227. package/dist/codegen/metadata.js.map +0 -1
  228. package/dist/codegen/swift.d.ts +0 -4
  229. package/dist/codegen/swift.d.ts.map +0 -1
  230. package/dist/codegen/swift.js +0 -145
  231. package/dist/codegen/swift.js.map +0 -1
  232. package/dist/codegen/template/android/kotlin-idl-template +0 -119
  233. package/dist/codegen/template/android/kotlin-impl-template +0 -0
  234. package/dist/codegen/template/ios/oc-idl-template +0 -0
  235. package/dist/codegen/template/ios/oc-impl-template +0 -0
  236. package/dist/codegen/template/ios/swift-idl-template +0 -83
  237. package/dist/codegen/template/ios/swift-impl-template +0 -0
  238. package/dist/codegen/template/ts/call-template +0 -0
  239. package/dist/codegen/template/ts/ts-idl-template +0 -66
  240. package/dist/codegen/template/ts/ts-impl-template +0 -78
  241. package/dist/codegen/template/ts/ts-index-template +0 -13
  242. package/dist/codegen/types.d.ts +0 -157
  243. package/dist/codegen/types.d.ts.map +0 -1
  244. package/dist/codegen/types.js +0 -3
  245. package/dist/codegen/types.js.map +0 -1
  246. package/dist/codegen/typescript.d.ts +0 -8
  247. package/dist/codegen/typescript.d.ts.map +0 -1
  248. package/dist/codegen/typescript.js +0 -232
  249. package/dist/codegen/typescript.js.map +0 -1
  250. package/dist/codegen/utils.d.ts +0 -10
  251. package/dist/codegen/utils.d.ts.map +0 -1
  252. package/dist/codegen/utils.js +0 -83
  253. package/dist/codegen/utils.js.map +0 -1
  254. package/dist/create/index.d.ts +0 -3
  255. package/dist/create/index.d.ts.map +0 -1
  256. package/dist/create/index.js +0 -44
  257. package/dist/create/index.js.map +0 -1
  258. package/dist/create/prompts.d.ts +0 -7
  259. package/dist/create/prompts.d.ts.map +0 -1
  260. package/dist/create/prompts.js +0 -61
  261. package/dist/create/prompts.js.map +0 -1
  262. package/dist/create/scaffold.d.ts +0 -9
  263. package/dist/create/scaffold.d.ts.map +0 -1
  264. package/dist/create/scaffold.js +0 -131
  265. package/dist/create/scaffold.js.map +0 -1
  266. package/dist/create/template/README.md +0 -17
  267. package/dist/create/template/android/.gitkeep +0 -1
  268. package/dist/create/template/ios/.gitkeep +0 -1
  269. package/dist/create/template/src/method.d.ts +0 -17
  270. package/dist/create/templates.d.ts +0 -5
  271. package/dist/create/templates.d.ts.map +0 -1
  272. package/dist/create/templates.js +0 -75
  273. package/dist/create/templates.js.map +0 -1
  274. package/dist/create/types.d.ts +0 -12
  275. package/dist/create/types.d.ts.map +0 -1
  276. package/dist/create/types.js +0 -3
  277. package/dist/create/types.js.map +0 -1
  278. package/dist/create/utils.d.ts +0 -3
  279. package/dist/create/utils.d.ts.map +0 -1
  280. package/dist/create/utils.js +0 -19
  281. package/dist/create/utils.js.map +0 -1
  282. package/dist/ui.d.ts +0 -13
  283. package/dist/ui.d.ts.map +0 -1
  284. package/dist/ui.js +0 -82
  285. package/dist/ui.js.map +0 -1
  286. package/dist/verbose.d.ts +0 -4
  287. package/dist/verbose.d.ts.map +0 -1
  288. package/dist/verbose.js +0 -25
  289. package/dist/verbose.js.map +0 -1
  290. package/templates/sparkling-app-template-android-groovy/android/sparkling-method-media/build.gradle +0 -44
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # sparkling-method
2
+
3
+ [![npm version](https://img.shields.io/npm/v/sparkling-method.svg)](https://npmjs.com/package/sparkling-method)
4
+ [![license](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](../../LICENSE)
5
+
6
+ SDK for building Sparkling methods that bridge JavaScript and native code through LynxPipe.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install sparkling-method@latest
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```typescript
17
+ import LynxPipe from 'sparkling-method';
18
+
19
+ // Callback-based call
20
+ LynxPipe.call('methodName', { param: 'value' }, (response) => {
21
+ console.log(response);
22
+ });
23
+
24
+ // Promise-based call
25
+ const result = await LynxPipe.callAsync('methodName', { param: 'value' });
26
+
27
+ // Event handling
28
+ const handler = LynxPipe.on('eventName', (data) => console.log(data));
29
+ LynxPipe.off('eventName', handler);
30
+ ```
31
+
32
+ ## API
33
+
34
+ | Method | Description |
35
+ |--------|-------------|
36
+ | `call(method, params, callback)` | Call native method with callback |
37
+ | `callAsync(method, params)` | Call native method with Promise |
38
+ | `on(event, callback)` | Subscribe to native event |
39
+ | `off(event, callback)` | Unsubscribe from native event |
@@ -0,0 +1,153 @@
1
+ import org.gradle.api.publish.PublishingExtension
2
+ import org.gradle.api.publish.maven.MavenPublication
3
+ import org.gradle.api.tasks.bundling.Jar
4
+
5
+ plugins {
6
+ alias(libs.plugins.android.library)
7
+ alias(libs.plugins.kotlin.android)
8
+ id("maven-publish")
9
+ jacoco
10
+ }
11
+
12
+ android {
13
+ namespace = "com.tiktok.sparkling.method"
14
+ compileSdk = 34
15
+
16
+ defaultConfig {
17
+ minSdk = 21
18
+ testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
19
+ }
20
+
21
+ buildTypes {
22
+ debug {
23
+ enableUnitTestCoverage = true
24
+ }
25
+ release {
26
+ isMinifyEnabled = false
27
+ proguardFiles(
28
+ getDefaultProguardFile("proguard-android-optimize.txt"),
29
+ "proguard-rules.pro"
30
+ )
31
+ }
32
+ }
33
+ compileOptions {
34
+ sourceCompatibility = JavaVersion.VERSION_11
35
+ targetCompatibility = JavaVersion.VERSION_11
36
+ }
37
+ kotlinOptions {
38
+ jvmTarget = "11"
39
+ }
40
+
41
+ testOptions {
42
+ unitTests {
43
+ isIncludeAndroidResources = true
44
+ all {
45
+ it.jvmArgs("-Xmx2048m", "-XX:MaxMetaspaceSize=512m")
46
+ it.systemProperty("robolectric.logging.enabled", "true")
47
+ }
48
+ }
49
+ }
50
+ }
51
+
52
+ dependencies {
53
+
54
+ implementation(libs.androidx.core.ktx)
55
+ implementation(libs.androidx.appcompat)
56
+ testImplementation(libs.junit)
57
+ androidTestImplementation(libs.androidx.junit)
58
+ androidTestImplementation(libs.androidx.espresso.core)
59
+
60
+ // Testing dependencies
61
+ testImplementation("io.mockk:mockk:1.13.8")
62
+ testImplementation("org.robolectric:robolectric:4.10.3")
63
+ testImplementation("org.bouncycastle:bcprov-jdk18on:1.75")
64
+ testImplementation("androidx.test:core:1.5.0")
65
+ testImplementation("androidx.test.ext:junit:1.1.5")
66
+ testImplementation("org.mockito:mockito-core:5.2.0")
67
+ testImplementation("org.mockito:mockito-inline:5.2.0")
68
+ testImplementation("androidx.test:runner:1.5.2")
69
+ testImplementation("androidx.test:rules:1.5.0")
70
+ // Removed PowerMock due to compatibility issues with Robolectric and Java 11
71
+
72
+ api(libs.lynx)
73
+ api("com.google.code.gson:gson:2.8.9")
74
+ }
75
+
76
+ tasks.register<JacocoReport>("jacocoTestReport") {
77
+ dependsOn(tasks.named("testDebugUnitTest"))
78
+
79
+ reports {
80
+ xml.required.set(true)
81
+ html.required.set(true)
82
+ }
83
+
84
+ val fileFilter = listOf(
85
+ "**/R.class",
86
+ "**/R$*.class",
87
+ "**/BuildConfig.*",
88
+ "**/Manifest*.*",
89
+ "**/*Test*.*",
90
+ "android/**/*.*"
91
+ )
92
+
93
+ val mainSrc = "${project.projectDir}/src/main/java"
94
+ sourceDirectories.setFrom(files(mainSrc))
95
+
96
+ val debugJavaTree = layout.buildDirectory.dir("intermediates/javac/debug").map { dir ->
97
+ dir.asFileTree.matching {
98
+ exclude(fileFilter)
99
+ }
100
+ }
101
+ val debugKotlinTree = layout.buildDirectory.dir("tmp/kotlin-classes/debug").map { dir ->
102
+ dir.asFileTree.matching {
103
+ exclude(fileFilter)
104
+ }
105
+ }
106
+ classDirectories.setFrom(debugJavaTree, debugKotlinTree)
107
+
108
+ val unitTestCoverageExec = layout.buildDirectory.file("outputs/unit_test_code_coverage/debugUnitTest/testDebugUnitTest.exec")
109
+ val jacocoExec = layout.buildDirectory.file("jacoco/testDebugUnitTest.exec")
110
+ executionData.setFrom(files(unitTestCoverageExec, jacocoExec))
111
+
112
+ onlyIf {
113
+ executionData.files.any { it.exists() }
114
+ }
115
+ outputs.upToDateWhen { false }
116
+ }
117
+
118
+ val publishingGroupId = (findProperty("SPARKLING_PUBLISHING_GROUP_ID") as? String)
119
+ ?: System.getenv("SPARKLING_PUBLISHING_GROUP_ID")
120
+ ?: "com.tiktok.sparkling"
121
+ val publishingVersion = (findProperty("SPARKLING_PUBLISHING_VERSION") as? String)
122
+ ?: System.getenv("SPARKLING_PUBLISHING_VERSION")
123
+ ?: "1.0.0"
124
+
125
+ val androidSourcesJar by tasks.register<Jar>("androidSourcesJar") {
126
+ archiveClassifier.set("sources")
127
+ from(android.sourceSets.getByName("main").java.srcDirs)
128
+ }
129
+
130
+ val emptyJavadocJar by tasks.register<Jar>("javadocJar") {
131
+ archiveClassifier.set("javadoc")
132
+ }
133
+
134
+ afterEvaluate {
135
+ extensions.configure<PublishingExtension>("publishing") {
136
+ publications {
137
+ create<MavenPublication>("release") {
138
+ groupId = publishingGroupId
139
+ artifactId = "sparkling-method"
140
+ version = publishingVersion
141
+
142
+ from(components["release"])
143
+ artifact(androidSourcesJar)
144
+ artifact(emptyJavadocJar)
145
+
146
+ pom {
147
+ name.set("sparkling-method")
148
+ description.set("Sparkling method Android SDK module")
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
@@ -0,0 +1 @@
1
+ SPARKLING_PUBLISHING_VERSION=2.0.0
@@ -0,0 +1,21 @@
1
+ # Add project specific ProGuard rules here.
2
+ # You can control the set of applied configuration files using the
3
+ # proguardFiles setting in build.gradle.
4
+ #
5
+ # For more details, see
6
+ # http://developer.android.com/guide/developing/tools/proguard.html
7
+
8
+ # If your project uses WebView with JS, uncomment the following
9
+ # and specify the fully qualified class name to the JavaScript interface
10
+ # class:
11
+ #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12
+ # public *;
13
+ #}
14
+
15
+ # Uncomment this to preserve the line number information for
16
+ # debugging stack traces.
17
+ #-keepattributes SourceFile,LineNumberTable
18
+
19
+ # If you keep the line number information, uncomment this to
20
+ # hide the original source file name.
21
+ #-renamesourcefileattribute SourceFile
@@ -0,0 +1,27 @@
1
+ // Copyright (c) 2022 TikTok Pte. Ltd.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ package com.tiktok.sparkling.sparkling.methods
5
+
6
+ import androidx.test.platform.app.InstrumentationRegistry
7
+ import androidx.test.ext.junit.runners.AndroidJUnit4
8
+
9
+ import org.junit.Test
10
+ import org.junit.runner.RunWith
11
+
12
+ import org.junit.Assert.*
13
+
14
+ /**
15
+ * Instrumented test, which will execute on an Android device.
16
+ *
17
+ * See [testing documentation](http://d.android.com/tools/testing).
18
+ */
19
+ @RunWith(AndroidJUnit4::class)
20
+ class ExampleInstrumentedTest {
21
+ @Test
22
+ fun useAppContext() {
23
+ // Context of the app under test.
24
+ val appContext = InstrumentationRegistry.getInstrumentation().targetContext
25
+ assertEquals("com.tiktok.sparkling.methods", appContext.packageName)
26
+ }
27
+ }
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+
5
+ </manifest>
@@ -0,0 +1,74 @@
1
+ // Copyright (c) 2022 TikTok Pte. Ltd.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+
6
+ package com.tiktok.sparkling.method.protocol
7
+
8
+ import com.tiktok.sparkling.method.registry.core.BridgePlatformType
9
+ import com.tiktok.sparkling.method.registry.api.BusinessCallHandler
10
+ import com.tiktok.sparkling.method.registry.api.DefaultCallHandler
11
+ import com.tiktok.sparkling.method.registry.api.SparklingBridge
12
+ import com.lynx.tasm.LynxBackgroundRuntime
13
+ import com.lynx.tasm.LynxView
14
+ import com.tiktok.sparkling.method.protocol.entity.BridgeCall
15
+ import com.tiktok.sparkling.method.protocol.handler.BridgeDispatcher
16
+ import com.tiktok.sparkling.method.protocol.impl.errors.JSBErrorReportModel
17
+ import com.tiktok.sparkling.method.protocol.impl.interceptor.BridgeMockInterceptor
18
+ import com.tiktok.sparkling.method.protocol.impl.monitor.IBridgeMonitor
19
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeLifeClient
20
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeProtocol
21
+
22
+ class BridgeContext {
23
+ companion object {
24
+ fun getPlatformByBridgeContext(bridgeContext: BridgeContext): BridgePlatformType {
25
+ return if (bridgeContext.platform == BridgePlatformType.LYNX) {
26
+ BridgePlatformType.LYNX
27
+ } else if (bridgeContext.platform == BridgePlatformType.WEB) {
28
+ BridgePlatformType.WEB
29
+ } else {
30
+ BridgePlatformType.ALL
31
+ }
32
+ }
33
+ }
34
+
35
+ var sparklingBridge: SparklingBridge? = null
36
+ var dispatcher: BridgeDispatcher? = null
37
+ var bridgeClient = DefaultBridgeClientImp(this)
38
+ val bridgeLifeClientImp = DefaultBridgeLifeClientImp(this)
39
+ var lynxView : LynxView? = null
40
+ var lynxBackgroundRuntime : LynxBackgroundRuntime? = null
41
+ var containerId : String? = ""
42
+ var protocols : MutableList<IBridgeProtocol> = mutableListOf()
43
+ var monitor : MutableSet<IBridgeMonitor> = mutableSetOf()
44
+ val defaultCallHandler: DefaultCallHandler = DefaultCallHandler()
45
+ var businessCallHandler: BusinessCallHandler? = null
46
+ var jsbMockInterceptor : BridgeMockInterceptor? = null // for JSB Mock
47
+ var platform: BridgePlatformType = BridgePlatformType.ALL
48
+
49
+
50
+ /**
51
+ * force on context error, only record view level message in jsbExtension
52
+ */
53
+ val errorReportModel: JSBErrorReportModel = JSBErrorReportModel()
54
+
55
+ fun registerProtocol(protocol: IBridgeProtocol){
56
+ protocols.add(protocol)
57
+ }
58
+
59
+ fun getNamespace() = businessCallHandler?.nameSpace
60
+
61
+ fun shouldHandleWithBusinessHandler(call: BridgeCall): Boolean {
62
+ return if (businessCallHandler != null && (call.nameSpace == getNamespace() || call.nameSpace.isEmpty())) {
63
+ businessCallHandler?.getBridge(this, call.bridgeName) != null
64
+ } else false
65
+ }
66
+
67
+ fun registerIBridgeLifeClient(bridgeLifeClient: IBridgeLifeClient) {
68
+ bridgeLifeClientImp.registerIBridgeLifeClient(bridgeLifeClient)
69
+ }
70
+
71
+ fun getCurrentUrl() : String? {
72
+ return this.lynxView?.templateUrl ?: this.lynxBackgroundRuntime?.lastScriptUrl
73
+ }
74
+ }
@@ -0,0 +1,47 @@
1
+ // Copyright (c) 2022 TikTok Pte. Ltd.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+
6
+ package com.tiktok.sparkling.method.protocol
7
+
8
+ import com.tiktok.sparkling.method.protocol.entity.BridgeCall
9
+ import com.tiktok.sparkling.method.protocol.entity.BridgeResult
10
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeClient
11
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeHandler
12
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeProtocol
13
+ import com.tiktok.sparkling.method.protocol.utils.LogUtils
14
+ import org.json.JSONObject
15
+
16
+ /**
17
+ * default implementation
18
+ */
19
+ class DefaultBridgeClientImp(val bridgeContext: BridgeContext): IBridgeClient {
20
+ private val TAG = "DefaultBridgeClientImp"
21
+
22
+ override fun shouldInterceptRequest(call: BridgeCall): BridgeResult? {
23
+ // TODO: implement by injection
24
+ return null
25
+ }
26
+
27
+ override fun onBridgeInvoked(protocol: IBridgeProtocol, detail: JSONObject) {
28
+ // FIXME pending
29
+ }
30
+
31
+ override fun onBridgeDispatched(call: BridgeCall) {
32
+ LogUtils.e(TAG, "onBridgeCallback: bridgeName: ${call.bridgeName}")
33
+ }
34
+
35
+ override fun onBridgeResultReceived(name: String, handler: IBridgeHandler, detail: JSONObject) {
36
+ LogUtils.e(TAG, "onBridgeCallback: bridgeName: $name")
37
+ }
38
+
39
+ override fun onBridgeCallback() {
40
+ LogUtils.e(TAG, "onBridgeCallback")
41
+ }
42
+
43
+ override fun onBridgeRejected() {
44
+ LogUtils.e(TAG, "onBridgeRejected")
45
+ }
46
+
47
+ }
@@ -0,0 +1,233 @@
1
+ // Copyright (c) 2023 TikTok Pte. Ltd.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+
5
+
6
+ package com.tiktok.sparkling.method.protocol
7
+
8
+ import com.tiktok.sparkling.method.registry.core.IDLBridgeMethod
9
+ import com.tiktok.sparkling.method.registry.api.containsPiperData
10
+ import com.lynx.react.bridge.JavaOnlyMap
11
+ import com.tiktok.sparkling.method.protocol.entity.BridgeCall
12
+ import com.tiktok.sparkling.method.protocol.entity.BridgeResult
13
+ import com.tiktok.sparkling.method.protocol.impl.lifecycle.fe.FeCallMonitorModel
14
+ import com.tiktok.sparkling.method.protocol.impl.monitor.MonitorEntity
15
+ import com.tiktok.sparkling.method.protocol.interfaces.IBridgeLifeClient
16
+ import com.tiktok.sparkling.method.protocol.interfaces.ShouldHandleBridgeCallResultModel
17
+ import com.tiktok.sparkling.method.protocol.utils.BridgeConstants
18
+ import com.tiktok.sparkling.method.protocol.utils.BridgeConverter
19
+
20
+ /**
21
+ */
22
+ class DefaultBridgeLifeClientImp(bridgeContext: BridgeContext) : IBridgeLifeClient() {
23
+
24
+ private var bridgeLifeClients = ArrayList<IBridgeLifeClient>()
25
+
26
+ fun registerIBridgeLifeClient(bridgeLifeClient: IBridgeLifeClient) {
27
+ bridgeLifeClients.add(bridgeLifeClient)
28
+ }
29
+
30
+
31
+ override fun shouldHandleBridgeCall(
32
+ call: BridgeCall,
33
+ bridgeContext: BridgeContext
34
+ ): ShouldHandleBridgeCallResultModel {
35
+ //call other lifeClient
36
+ bridgeLifeClients.forEach {
37
+ val currentHandleModel = it.shouldHandleBridgeCall(call, bridgeContext)
38
+ if (!currentHandleModel.shouldHandleBridgeCall) {
39
+ // TODO
40
+ }
41
+ }
42
+ return ShouldHandleBridgeCallResultModel(true, null)
43
+ }
44
+
45
+ override fun onBridgeCalledStart(bridgeCall: BridgeCall, bridgeContext: BridgeContext) {
46
+ val endConvertParamsTime = System.currentTimeMillis()
47
+ bridgeCall.jsbSDKErrorReportModel.apply {
48
+ setJsbBridgeSdk("SparklingBridge")
49
+ setJsbUrl(bridgeCall.url)
50
+ setJsbMethodName(bridgeCall.bridgeName)
51
+ setJsbEngine(bridgeCall.jsbEngine)
52
+ when (bridgeCall.platform) {
53
+ BridgeCall.PlatForm.Web -> Unit // TODO: Web related abilities will implement later
54
+ BridgeCall.PlatForm.Lynx -> setView(bridgeCall.context.lynxView)
55
+ else -> Unit
56
+ }
57
+ }
58
+
59
+ bridgeCall.feCallMonitorModel.view = bridgeContext.lynxView
60
+ bridgeCall.feCallMonitorModel.jsbNativeCallStart = System.currentTimeMillis()
61
+ bridgeCall.feCallMonitorModel.bridgeName = bridgeCall.bridgeName
62
+ bridgeCall.feCallMonitorModel.containerID = bridgeContext.containerId
63
+
64
+ when (bridgeCall.platform) {
65
+ BridgeCall.PlatForm.Web -> {
66
+ // TODO: Web related abilities will implement later
67
+ }
68
+
69
+ else -> {
70
+ (bridgeCall.params as? JavaOnlyMap)?.let { params ->
71
+ (params?.getMap("data") ?: params).getMap(FeCallMonitorModel._JSB_CALLER_INFO)
72
+ ?.asHashMap()?.forEach {
73
+ bridgeCall.feCallMonitorModel.addCategory(
74
+ "${FeCallMonitorModel.CALLER_PREFIX}${it.key}",
75
+ it.value
76
+ )
77
+ }
78
+ (params?.getMap("data") ?: params).getMap(FeCallMonitorModel._JSB_PERF_METRICS)
79
+ ?.asHashMap()?.let {
80
+ it.get(FeCallMonitorModel.JSB_FUNC_CALL_START).let {
81
+ if (it is Long) {
82
+ bridgeCall.feCallMonitorModel.jsbFuncCallStart = it
83
+ }
84
+ }
85
+ it.get(FeCallMonitorModel.JSB_FUNC_CALL_END).let {
86
+ if (it is Long) {
87
+ bridgeCall.feCallMonitorModel.jsbFuncCallEnd = it
88
+ }
89
+ }
90
+ }
91
+
92
+ }
93
+ }
94
+ }
95
+
96
+ //call other lifeClient
97
+ bridgeLifeClients.forEach {
98
+ it.onBridgeCalledStart(bridgeCall, bridgeContext)
99
+ }
100
+ }
101
+
102
+ override fun onBridgeImplHandleStart(call: BridgeCall?, bridgeContext: BridgeContext) {
103
+ //call other lifeClient
104
+ bridgeLifeClients.forEach {
105
+ it.onBridgeImplHandleStart(call, bridgeContext)
106
+ }
107
+ }
108
+
109
+ override fun onBridgeImplHandleEnd(call: BridgeCall?, bridgeContext: BridgeContext) {
110
+ //call other lifeClient
111
+ bridgeLifeClients.forEach {
112
+ it.onBridgeImplHandleEnd(call, bridgeContext)
113
+ }
114
+ }
115
+
116
+ override fun onBridgeCallbackCallStart(
117
+ result: BridgeResult,
118
+ call: BridgeCall,
119
+ mContext: BridgeContext
120
+ ) {
121
+ when (call.platform) {
122
+ BridgeCall.PlatForm.Web -> {
123
+ // TODO
124
+ }
125
+
126
+ BridgeCall.PlatForm.Lynx -> {
127
+
128
+ }
129
+
130
+ else -> {}
131
+ }
132
+
133
+
134
+ //call other lifeClient
135
+ bridgeLifeClients.forEach {
136
+ it.onBridgeCallbackCallStart(result, call, mContext)
137
+ }
138
+ }
139
+
140
+ override fun onBridgeCallbackInvokeStart(result: BridgeResult, call: BridgeCall) {
141
+
142
+ when (call.platform) {
143
+ BridgeCall.PlatForm.Web -> {
144
+ // TODO
145
+ }
146
+
147
+ BridgeCall.PlatForm.Lynx -> {
148
+ call.lynxCallbackMap?.let { map ->
149
+ val monitor = MonitorEntity().apply {
150
+ name = call?.bridgeName
151
+ url = call?.url
152
+ beginTime = call?.timestamp
153
+ endTime = System.currentTimeMillis()
154
+ if (map.hasKey("code")) {
155
+ val code = map.getInt("code", IDLBridgeMethod.UNKNOWN_ERROR)
156
+ if (code != IDLBridgeMethod.UNKNOWN_ERROR) this.code = code
157
+ }
158
+ message = map.getString("msg", "")
159
+
160
+ rawResult = BridgeConverter.revertJavaOnlyMap2JSONObject(map).apply {
161
+ put("usePiperData", map.containsPiperData())
162
+ put("bridgeCallThreadType", call.bridgeCallThreadType)
163
+ }
164
+ call.params?.let {
165
+ rawRequest =
166
+ BridgeConverter.revertJavaOnlyMap2JSONObject(call.params as JavaOnlyMap)
167
+ }
168
+ hitBusinessHandler = call?.hitBusinessHandler ?: false
169
+ nameSpace = call?.nameSpace
170
+ isRunInMainThread = call.isInMainThread
171
+ }
172
+ if (monitor.code == BridgeConstants.BRIDGE_CALL_SUCCESS) {
173
+ call.context.monitor.forEach {
174
+ it.onBridgeResolved(monitor)
175
+ }
176
+ } else {
177
+ call.context.monitor.forEach {
178
+ it.onBridgeRejected(monitor)
179
+ }
180
+ call.jsbSDKErrorReportModel.apply {
181
+ setJsbErrorCode(monitor.code)
182
+ putJsbExtension("error_message", monitor.message)
183
+ putJsbExtension("bridgeCallThreadType", call.bridgeCallThreadType)
184
+ }
185
+ call.jsbSDKErrorReportModel.reportJSBErrorModel(call.context.errorReportModel)
186
+ }
187
+ }
188
+ }
189
+
190
+ else -> {}
191
+ }
192
+
193
+
194
+ //call other lifeClient
195
+ bridgeLifeClients.forEach {
196
+ it.onBridgeCallbackInvokeStart(result, call)
197
+ }
198
+
199
+ call.feCallMonitorModel.jsbCallbackStart = System.currentTimeMillis()
200
+ }
201
+
202
+ override fun onBridgeCalledEnd(call: BridgeCall, bridgeContext: BridgeContext) {
203
+
204
+ when (call.platform) {
205
+ BridgeCall.PlatForm.Web -> {
206
+ // TODO
207
+ }
208
+ else -> {}
209
+ }
210
+
211
+ //call other lifeClient
212
+ bridgeLifeClients.forEach {
213
+ it.onBridgeCalledEnd(call, bridgeContext)
214
+ }
215
+ call.feCallMonitorModel.jsbCallbackEnd = System.currentTimeMillis()
216
+ call.feCallMonitorModel.reportFeCallInfo()
217
+ }
218
+
219
+ //Event
220
+ override fun onBridgeEventStart(eventName: String, data: Any?) {
221
+ //call other lifeClient
222
+ bridgeLifeClients.forEach {
223
+ it.onBridgeEventStart(eventName, data)
224
+ }
225
+ }
226
+
227
+ override fun onBridgeEventEnd(eventName: String, data: Any?) {
228
+ //call other lifeClient
229
+ bridgeLifeClients.forEach {
230
+ it.onBridgeEventEnd(eventName, data)
231
+ }
232
+ }
233
+ }