sparkling-method 2.0.0-rc.0 → 2.0.0-rc.1
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.
- package/README.md +39 -0
- package/android/build.gradle.kts +153 -0
- package/android/gradle.properties +1 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/androidTest/java/com/tiktok/sparkling/sparkling/methods/ExampleInstrumentedTest.kt +27 -0
- package/android/src/main/AndroidManifest.xml +5 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/BridgeContext.kt +74 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImp.kt +47 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImp.kt +233 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/InnerBridge.kt +134 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeCall.kt +79 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeResult.kt +68 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcher.kt +198 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManager.kt +16 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcher.kt +56 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModel.kt +144 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptor.kt +30 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModel.kt +66 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModule.kt +31 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtol.kt +69 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModule.kt +31 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxViewImpl.kt +29 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegate.kt +147 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitor.kt +239 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/IBridgeMonitor.kt +17 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntity.kt +22 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeCallback.kt +14 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeClient.kt +19 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeHandler.kt +23 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeLifeClient.kt +45 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeMethodCallback.kt +10 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeProtocol.kt +22 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConstants.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConverter.kt +147 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/LogUtils.kt +37 -0
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/MonitorUtils.kt +41 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeLocalPool.kt +70 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeSettings.kt +19 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BusinessCallHandler.kt +100 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/CancelCallbackConfig.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/DefaultCallHandler.kt +106 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/IBridgeMethod.kt +118 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/PiperDataExt.kt +71 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/SparklingBridge.kt +374 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/Utils.kt +89 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/interfaces/IBridgeNotFound.kt +11 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxDataProcessorForMap.kt +204 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxPlatformDataProcessor.kt +239 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebPlatformDataProcessor.kt +307 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebProcessorForMap.kt +227 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeMethodCallbackHelper.kt +29 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeProtocolConstants.kt +12 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtils.kt +684 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/IConvertUtils.kt +44 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/LogHelper.kt +30 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/ThreadPool.kt +73 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgeCollections.kt +194 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgePlatformType.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IBridgeContext.kt +137 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLBridgeMethod.kt +100 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodProvider.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistry.kt +132 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCache.kt +150 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCacheManager.kt +34 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLProxyClient.kt +28 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IRegister.kt +21 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/LocalBridge.kt +70 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/ReadableMapImpl.kt +227 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/RegistryCache.kt +77 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManager.kt +50 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodIntEnum.kt +15 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodName.kt +17 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamField.kt +42 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamModel.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodResultModel.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodStringEnum.kt +15 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethod.kt +276 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodException.kt +10 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalInputParamException.kt +12 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOperationException.kt +12 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOutputParamException.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IContainerIDProvider.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/INameSpaceProvider.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IPlatformDataProcessor.kt +19 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IReleasable.kt +13 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/BridgeCallThreadTypeConfig.kt +44 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/ContextProviderFactory.kt +133 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/CompletionBlock.kt +26 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLDynamic.kt +97 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseModel.kt +37 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseParamModel.kt +62 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseResultModel.kt +18 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/BridgeKTX.kt +37 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IAssignDir.kt +25 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodHelper.kt +44 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelArguments.kt +264 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelHelper.kt +194 -0
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/JsonUtils.kt +200 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntime.kt +11 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/CommonDependsProvider.kt +14 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostNetworkDepend.kt +19 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostPermissionDepend.kt +34 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostThreadPoolExecutorDepend.kt +12 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStreamConnection.kt +36 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStringConnection.kt +30 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/HttpRequest.kt +134 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/NetworkRequestImpl.kt +28 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/RequestJsonFormatOptionConstants.kt +10 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/BridgeAPIRequestUtils.kt +365 -0
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/HttpUrlBuilder.kt +97 -0
- package/android/src/main/res/drawable/ic_launcher_background.xml +170 -0
- package/android/src/main/res/drawable/ic_launcher_foreground.xml +30 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +6 -0
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +6 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-hdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-mdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/android/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp +0 -0
- package/android/src/main/res/values/colors.xml +10 -0
- package/android/src/main/res/values/strings.xml +3 -0
- package/android/src/test/java/com/tiktok/sparkling/method/TestApplication.kt +19 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/BridgeContextTest.kt +89 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImpTest.kt +78 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImpTest.kt +97 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/InnerBridgeTest.kt +105 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeCallTest.kt +61 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeResultTest.kt +74 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcherTest.kt +96 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManagerTest.kt +21 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcherTest.kt +34 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModelTest.kt +60 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptorTest.kt +51 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModelTest.kt +65 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModuleTest.kt +57 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtocolTest.kt +10 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModuleTest.kt +37 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegateTest.kt +10 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitorTest.kt +10 -0
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntityTest.kt +43 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/api/SparklingBridgeTest.kt +444 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtilsTest.kt +236 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryTest.kt +331 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/LocalBridgeTest.kt +299 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManagerTest.kt +213 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethodTest.kt +307 -0
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodExceptionTest.kt +311 -0
- package/android/src/test/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntimeTest.kt +54 -0
- package/android/src/test/resources/robolectric.properties +5 -0
- package/dist/index.d.ts +55 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +181 -52
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/dist/typing.d.ts +44 -0
- package/ios/Sources/Core/DI/DIContainerProtocol.swift +27 -0
- package/ios/Sources/Core/DI/DIContainerProvider.swift +10 -0
- package/ios/Sources/Core/DI/DIProviderRegistry.swift +21 -0
- package/ios/Sources/Core/Definitions/CommonDefines.swift +17 -0
- package/ios/Sources/Core/Examples/SampleMethod+impl.swift +24 -0
- package/ios/Sources/Core/Examples/SampleMethod.swift +58 -0
- package/ios/Sources/Core/Models/MethodContext.swift +53 -0
- package/ios/Sources/Core/Models/MethodStatus.swift +146 -0
- package/ios/Sources/Core/Models/SPKAutoRegisteringMethod.swift +7 -0
- package/ios/Sources/Core/Pipe/MethodPipe+Internal.swift +90 -0
- package/ios/Sources/Core/Pipe/MethodPipe.swift +45 -0
- package/ios/Sources/Core/Pipe/MethodRegistry.swift +97 -0
- package/ios/Sources/Core/Protocols/DictionaryCodable.swift +10 -0
- package/ios/Sources/Core/Protocols/MethodModel.swift +143 -0
- package/ios/Sources/Core/Protocols/MethodPipeFacade.swift +16 -0
- package/ios/Sources/Core/Protocols/PipeContainer.swift +21 -0
- package/ios/Sources/Core/Protocols/PipeEngine.swift +10 -0
- package/ios/Sources/Core/Protocols/PipeMethod.swift +83 -0
- package/ios/Sources/Core/Protocols/PipeRuntime.swift +9 -0
- package/ios/Sources/Core/Utils/AnyCodableValue.swift +128 -0
- package/ios/Sources/Core/Utils/CoreUtils.swift +17 -0
- package/ios/Sources/Core/Utils/NSString+SPKBridgeAdditions.swift +35 -0
- package/ios/Sources/Core/Utils/ReadWriteLock.swift +33 -0
- package/ios/Sources/Core/Utils/SPKHttpResponseChromium.swift +24 -0
- package/ios/Sources/Core/Utils/SPKNetworkManager.swift +200 -0
- package/ios/Sources/Core/Utils/SPKReachability.swift +46 -0
- package/ios/Sources/DIProvider/DIContainer.swift +80 -0
- package/ios/Sources/DIProvider/DefaultDIContainerProvider.swift +21 -0
- package/ios/Sources/Debug/MethodPipe+Debug.swift +36 -0
- package/ios/Sources/Lynx/Definitions/LynxConstants.swift +19 -0
- package/ios/Sources/Lynx/Definitions/LynxPipeStatusCode.swift +26 -0
- package/ios/Sources/Lynx/Definitions/LynxTypealiases.swift +7 -0
- package/ios/Sources/Lynx/Engine/LynxConfig+SPKPipe.swift +31 -0
- package/ios/Sources/Lynx/Engine/LynxContext+SPKPipe.swift +21 -0
- package/ios/Sources/Lynx/Engine/LynxPipeEngine.swift +52 -0
- package/ios/Sources/Lynx/Engine/LynxPipeEnginePool.swift +41 -0
- package/ios/Sources/Lynx/Engine/LynxView+SPKPipe.swift +64 -0
- package/ios/Sources/Lynx/Engine/SPKLynxModuleService.swift +23 -0
- package/ios/Sources/Lynx/Models/LynxRecvMessage.swift +31 -0
- package/ios/Sources/Lynx/Models/LynxSendMessage.swift +55 -0
- package/ios/Sources/Lynx/Module/SPKLynxNativeModule.swift +41 -0
- package/ios/Sources/Lynx/Pipe/MethodPipe+Lynx.swift +53 -0
- package/ios/SparklingMethod.podspec +65 -0
- package/package.json +11 -29
- package/src/index.ts +240 -0
- package/src/types.ts +44 -0
- package/src/typing.d.ts +44 -0
- package/tsconfig.json +15 -0
- package/dist/codegen/definition-parser.d.ts +0 -5
- package/dist/codegen/definition-parser.d.ts.map +0 -1
- package/dist/codegen/definition-parser.js +0 -376
- package/dist/codegen/definition-parser.js.map +0 -1
- package/dist/codegen/index.d.ts +0 -3
- package/dist/codegen/index.d.ts.map +0 -1
- package/dist/codegen/index.js +0 -99
- package/dist/codegen/index.js.map +0 -1
- package/dist/codegen/kotlin.d.ts +0 -4
- package/dist/codegen/kotlin.d.ts.map +0 -1
- package/dist/codegen/kotlin.js +0 -273
- package/dist/codegen/kotlin.js.map +0 -1
- package/dist/codegen/metadata.d.ts +0 -4
- package/dist/codegen/metadata.d.ts.map +0 -1
- package/dist/codegen/metadata.js +0 -78
- package/dist/codegen/metadata.js.map +0 -1
- package/dist/codegen/swift.d.ts +0 -4
- package/dist/codegen/swift.d.ts.map +0 -1
- package/dist/codegen/swift.js +0 -145
- package/dist/codegen/swift.js.map +0 -1
- package/dist/codegen/template/android/kotlin-idl-template +0 -119
- package/dist/codegen/template/android/kotlin-impl-template +0 -0
- package/dist/codegen/template/ios/oc-idl-template +0 -0
- package/dist/codegen/template/ios/oc-impl-template +0 -0
- package/dist/codegen/template/ios/swift-idl-template +0 -83
- package/dist/codegen/template/ios/swift-impl-template +0 -0
- package/dist/codegen/template/ts/call-template +0 -0
- package/dist/codegen/template/ts/ts-idl-template +0 -66
- package/dist/codegen/template/ts/ts-impl-template +0 -78
- package/dist/codegen/template/ts/ts-index-template +0 -13
- package/dist/codegen/types.d.ts +0 -157
- package/dist/codegen/types.d.ts.map +0 -1
- package/dist/codegen/types.js +0 -3
- package/dist/codegen/types.js.map +0 -1
- package/dist/codegen/typescript.d.ts +0 -8
- package/dist/codegen/typescript.d.ts.map +0 -1
- package/dist/codegen/typescript.js +0 -232
- package/dist/codegen/typescript.js.map +0 -1
- package/dist/codegen/utils.d.ts +0 -10
- package/dist/codegen/utils.d.ts.map +0 -1
- package/dist/codegen/utils.js +0 -83
- package/dist/codegen/utils.js.map +0 -1
- package/dist/create/index.d.ts +0 -3
- package/dist/create/index.d.ts.map +0 -1
- package/dist/create/index.js +0 -44
- package/dist/create/index.js.map +0 -1
- package/dist/create/prompts.d.ts +0 -7
- package/dist/create/prompts.d.ts.map +0 -1
- package/dist/create/prompts.js +0 -61
- package/dist/create/prompts.js.map +0 -1
- package/dist/create/scaffold.d.ts +0 -9
- package/dist/create/scaffold.d.ts.map +0 -1
- package/dist/create/scaffold.js +0 -131
- package/dist/create/scaffold.js.map +0 -1
- package/dist/create/template/README.md +0 -17
- package/dist/create/template/android/.gitkeep +0 -1
- package/dist/create/template/ios/.gitkeep +0 -1
- package/dist/create/template/src/method.d.ts +0 -17
- package/dist/create/templates.d.ts +0 -5
- package/dist/create/templates.d.ts.map +0 -1
- package/dist/create/templates.js +0 -75
- package/dist/create/templates.js.map +0 -1
- package/dist/create/types.d.ts +0 -12
- package/dist/create/types.d.ts.map +0 -1
- package/dist/create/types.js +0 -3
- package/dist/create/types.js.map +0 -1
- package/dist/create/utils.d.ts +0 -3
- package/dist/create/utils.d.ts.map +0 -1
- package/dist/create/utils.js +0 -19
- package/dist/create/utils.js.map +0 -1
- package/dist/ui.d.ts +0 -13
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js +0 -82
- package/dist/ui.js.map +0 -1
- package/dist/verbose.d.ts +0 -4
- package/dist/verbose.d.ts.map +0 -1
- package/dist/verbose.js +0 -25
- package/dist/verbose.js.map +0 -1
- package/templates/sparkling-app-template-android-groovy/android/sparkling-method-media/build.gradle +0 -44
|
@@ -0,0 +1,30 @@
|
|
|
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.impl.interceptor
|
|
7
|
+
|
|
8
|
+
import com.tiktok.sparkling.method.protocol.BridgeContext
|
|
9
|
+
import com.tiktok.sparkling.method.protocol.entity.BridgeCall
|
|
10
|
+
import com.tiktok.sparkling.method.protocol.entity.BridgeResult
|
|
11
|
+
import org.json.JSONObject
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* use for JSB Mock, only invoke in Debug mode
|
|
15
|
+
*/
|
|
16
|
+
open class BridgeMockInterceptor {
|
|
17
|
+
open fun interceptBridgeCall(originCall: BridgeCall): BridgeCall {
|
|
18
|
+
return originCall
|
|
19
|
+
}
|
|
20
|
+
open fun interceptBridgeResult(jsbCall: BridgeCall, originResult: BridgeResult): BridgeResult {
|
|
21
|
+
return originResult
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* skip real jsb call and invoke callback to FE when the BridgeResult != null
|
|
25
|
+
*/
|
|
26
|
+
open fun invokeBridgeResult(originCall: BridgeCall): BridgeResult? {
|
|
27
|
+
return null
|
|
28
|
+
}
|
|
29
|
+
open fun interceptJSBEvent(context: BridgeContext, event: String, data: JSONObject?) {}
|
|
30
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Copyright (c) 2024 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.impl.lifecycle.fe
|
|
7
|
+
|
|
8
|
+
import android.view.View
|
|
9
|
+
import com.tiktok.sparkling.method.protocol.utils.MonitorUtils
|
|
10
|
+
import org.json.JSONObject
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*/
|
|
14
|
+
class FeCallMonitorModel {
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
const val _JSB_CALLER_INFO = "_jsb_caller_info"
|
|
18
|
+
const val _JSB_PERF_METRICS = "_jsb_perf_metrics"
|
|
19
|
+
const val JSB_FUNC_CALL_END = "jsb_func_call_end"
|
|
20
|
+
const val JSB_FUNC_CALL_START = "jsb_func_call_start"
|
|
21
|
+
const val JS_JSSDK = "js_jssdk"
|
|
22
|
+
const val JS_CANCEL_CALLBACK = "js_cancel_callback"
|
|
23
|
+
const val CALLER_PREFIX = "caller_"
|
|
24
|
+
|
|
25
|
+
private const val JSB_FUNC_CALL = "jsb_func_call"
|
|
26
|
+
private const val JSB_CALLBACK_CALL = "jsb_callback_call"
|
|
27
|
+
private const val JSB_CALL = "jsb_call"
|
|
28
|
+
private const val JSB_CLIENT_CALL = "jsb_client_call"
|
|
29
|
+
private const val BRIDGE_METHOD_NAME = "bridge_method_name"
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
val JSB_FE_CALL_MONITOR_EVENT = "jsb_fe_call_monitor"
|
|
33
|
+
var view: View? = null
|
|
34
|
+
var bridgeName: String? = null
|
|
35
|
+
var containerID: String? = null
|
|
36
|
+
|
|
37
|
+
var jsbFuncCallStart: Long = 0
|
|
38
|
+
var jsbFuncCallEnd: Long = 0
|
|
39
|
+
var jsbCallbackStart: Long = 0
|
|
40
|
+
var jsbCallbackEnd: Long = 0
|
|
41
|
+
var jsbNativeCallStart: Long = 0
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
private var category = JSONObject()
|
|
45
|
+
|
|
46
|
+
fun addCategory(key: String, value: Any) {
|
|
47
|
+
category.put(key, value)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun reportFeCallInfo() {
|
|
51
|
+
MonitorUtils.customReport(
|
|
52
|
+
JSB_FE_CALL_MONITOR_EVENT, JSONObject().apply {
|
|
53
|
+
put(BRIDGE_METHOD_NAME, bridgeName)
|
|
54
|
+
|
|
55
|
+
if (jsbFuncCallStart == 0L) {
|
|
56
|
+
put(JSB_FUNC_CALL, -1)
|
|
57
|
+
put(JSB_CALL, -1)
|
|
58
|
+
} else {
|
|
59
|
+
put(JSB_FUNC_CALL, jsbFuncCallEnd - jsbFuncCallStart)
|
|
60
|
+
put(JSB_CALL, jsbCallbackEnd - jsbFuncCallStart)
|
|
61
|
+
}
|
|
62
|
+
put(JSB_CALLBACK_CALL, jsbCallbackEnd - jsbCallbackStart)
|
|
63
|
+
put(JSB_CLIENT_CALL, jsbCallbackEnd - jsbNativeCallStart)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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.impl.lynx
|
|
7
|
+
|
|
8
|
+
import com.lynx.jsbridge.LynxContextModule
|
|
9
|
+
import com.lynx.jsbridge.LynxMethod
|
|
10
|
+
import com.lynx.react.bridge.Callback
|
|
11
|
+
import com.lynx.react.bridge.ReadableMap
|
|
12
|
+
import com.lynx.tasm.behavior.LynxContext
|
|
13
|
+
|
|
14
|
+
class LynxBridgeDelegateModule(val context: LynxContext, val obj: Any?) :
|
|
15
|
+
LynxContextModule(context, obj) {
|
|
16
|
+
constructor(context: LynxContext) : this(context, null)
|
|
17
|
+
|
|
18
|
+
private val TAG = "LynxBridgeDelegateModule"
|
|
19
|
+
|
|
20
|
+
private val realLynxBridgeDelegate : RealLynxBridgeDelegate = RealLynxBridgeDelegate(obj)
|
|
21
|
+
|
|
22
|
+
companion object {
|
|
23
|
+
// here is the protocol of the front end of lynx, don't change it casually
|
|
24
|
+
const val NAME = "spkPipe"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@LynxMethod
|
|
28
|
+
fun call(bridgeName: String, params: ReadableMap? = null, callback: Callback? = null) {
|
|
29
|
+
realLynxBridgeDelegate.call(bridgeName, params, callback, "Lynx")
|
|
30
|
+
}
|
|
31
|
+
}
|
package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtol.kt
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
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.method.protocol.impl.lynx
|
|
5
|
+
|
|
6
|
+
import com.tiktok.sparkling.method.protocol.BridgeContext
|
|
7
|
+
import com.tiktok.sparkling.method.protocol.interfaces.IBridgeProtocol
|
|
8
|
+
import com.tiktok.sparkling.method.protocol.utils.BridgeConverter
|
|
9
|
+
import com.lynx.react.bridge.JavaOnlyArray
|
|
10
|
+
import com.tiktok.sparkling.method.protocol.entity.BridgeCall
|
|
11
|
+
import org.json.JSONObject
|
|
12
|
+
|
|
13
|
+
class LynxBridgeProtocol(val context: BridgeContext) : IBridgeProtocol(context) {
|
|
14
|
+
|
|
15
|
+
override fun sendEvent(name: String, params: Any?) {
|
|
16
|
+
if(params is JavaOnlyArray){
|
|
17
|
+
context.bridgeLifeClientImp.onBridgeEventStart(name, params)
|
|
18
|
+
sendEvent(name, (params as? JavaOnlyArray))
|
|
19
|
+
context.bridgeLifeClientImp.onBridgeEventEnd(name, params)
|
|
20
|
+
}else if (params is JSONObject?){
|
|
21
|
+
var array = JavaOnlyArray().apply {
|
|
22
|
+
pushMap(BridgeConverter.convertJSONObject2JavaOnlyMap(JSONObject().apply {
|
|
23
|
+
put("data",params)
|
|
24
|
+
put("containerID",context.containerId)
|
|
25
|
+
put("protocolVersion","1.0")
|
|
26
|
+
put("code", 1)
|
|
27
|
+
}))
|
|
28
|
+
}
|
|
29
|
+
context.bridgeLifeClientImp.onBridgeEventStart(name, array)
|
|
30
|
+
sendEvent(name,array)
|
|
31
|
+
context.bridgeLifeClientImp.onBridgeEventEnd(name, array)
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun sendJSRuntimeEvent(name: String, params: Any?) {
|
|
36
|
+
if(params is JavaOnlyArray){
|
|
37
|
+
context.bridgeLifeClientImp.onBridgeEventStart(name, params)
|
|
38
|
+
sendJSRuntimeEvent(name, (params as? JavaOnlyArray))
|
|
39
|
+
context.bridgeLifeClientImp.onBridgeEventEnd(name, params)
|
|
40
|
+
}else if (params is JSONObject?){
|
|
41
|
+
var array = JavaOnlyArray().apply {
|
|
42
|
+
pushMap(BridgeConverter.convertJSONObject2JavaOnlyMap(JSONObject().apply {
|
|
43
|
+
put("data",params)
|
|
44
|
+
put("containerID",context.containerId)
|
|
45
|
+
put("protocolVersion","1.0")
|
|
46
|
+
put("code", 1)
|
|
47
|
+
}))
|
|
48
|
+
}
|
|
49
|
+
context.bridgeLifeClientImp.onBridgeEventStart(name, array)
|
|
50
|
+
sendJSRuntimeEvent(name,array)
|
|
51
|
+
context.bridgeLifeClientImp.onBridgeEventEnd(name, array)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
private fun sendJSRuntimeEvent(method: String, params: JavaOnlyArray?) {
|
|
56
|
+
context.lynxBackgroundRuntime?.sendGlobalEvent(method, params)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private fun sendEvent(method: String, params: JavaOnlyArray?) {
|
|
60
|
+
context.lynxView?.sendGlobalEvent(method, params)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun init() {}
|
|
64
|
+
|
|
65
|
+
override fun createBridgeCall(msg: String): BridgeCall {
|
|
66
|
+
return BridgeCall(context)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright (c) 2024 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.impl.lynx
|
|
7
|
+
|
|
8
|
+
import android.content.Context
|
|
9
|
+
import com.lynx.jsbridge.LynxMethod
|
|
10
|
+
import com.lynx.jsbridge.LynxModule
|
|
11
|
+
import com.lynx.react.bridge.Callback
|
|
12
|
+
import com.lynx.react.bridge.ReadableMap
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*/
|
|
16
|
+
class LynxRuntimeBridgeDelegateModule(val context: Context, val obj: Any?) :
|
|
17
|
+
LynxModule(context, obj) {
|
|
18
|
+
|
|
19
|
+
private val TAG = "LynxRuntimeBridgeDelegateModule"
|
|
20
|
+
private val realLynxBridgeDelegate : RealLynxBridgeDelegate = RealLynxBridgeDelegate(obj)
|
|
21
|
+
companion object {
|
|
22
|
+
// here is the protocol of the front end of lynx, don't change it casually
|
|
23
|
+
const val NAME = "runtimeBridge"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@LynxMethod
|
|
27
|
+
fun call(bridgeName: String, params: ReadableMap? = null, callback: Callback? = null) {
|
|
28
|
+
realLynxBridgeDelegate.call(bridgeName, params, callback, "LynxRuntime")
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
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.impl.lynx
|
|
7
|
+
|
|
8
|
+
import com.tiktok.sparkling.method.protocol.BridgeContext
|
|
9
|
+
import com.lynx.tasm.LynxBackgroundRuntimeOptions
|
|
10
|
+
import com.lynx.tasm.LynxViewBuilder
|
|
11
|
+
|
|
12
|
+
class LynxViewImpl(context: BridgeContext){
|
|
13
|
+
private val TAG = "LynxViewImpl"
|
|
14
|
+
private val BRIDGE_NAME = "spkPipe"
|
|
15
|
+
private val mContext = context
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The correct LynxViewBuilder needs to be registered here
|
|
19
|
+
*/
|
|
20
|
+
fun init(builder: LynxViewBuilder):LynxViewBuilder{
|
|
21
|
+
builder.registerModule(BRIDGE_NAME, LynxBridgeDelegateModule::class.java,mContext)
|
|
22
|
+
return builder
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun initJSRuntime(options: LynxBackgroundRuntimeOptions): LynxBackgroundRuntimeOptions {
|
|
26
|
+
options.registerModule(LynxRuntimeBridgeDelegateModule.NAME, LynxRuntimeBridgeDelegateModule::class.java, mContext)
|
|
27
|
+
return options
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Copyright (c) 2024 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.impl.lynx
|
|
7
|
+
|
|
8
|
+
import com.tiktok.sparkling.method.protocol.BridgeContext
|
|
9
|
+
import com.tiktok.sparkling.method.protocol.impl.monitor.BridgeSDKMonitor
|
|
10
|
+
import com.tiktok.sparkling.method.protocol.interfaces.IBridgeCallback
|
|
11
|
+
import com.tiktok.sparkling.method.protocol.utils.BridgeConverter
|
|
12
|
+
import com.tiktok.sparkling.method.protocol.utils.LogUtils
|
|
13
|
+
import com.tiktok.sparkling.method.registry.core.IDLBridgeMethod
|
|
14
|
+
import com.tiktok.sparkling.method.registry.core.model.context.BridgeCallThreadTypeConfig
|
|
15
|
+
import com.tiktok.sparkling.method.registry.core.model.context.threadStringToThreadTypeEnum
|
|
16
|
+
import com.tiktok.sparkling.method.registry.api.SparklingBridge
|
|
17
|
+
import com.lynx.react.bridge.Callback
|
|
18
|
+
import com.lynx.react.bridge.JavaOnlyMap
|
|
19
|
+
import com.lynx.react.bridge.ReadableMap
|
|
20
|
+
import com.tiktok.sparkling.method.protocol.entity.BridgeCall
|
|
21
|
+
import com.tiktok.sparkling.method.protocol.entity.BridgeResult
|
|
22
|
+
import com.tiktok.sparkling.method.protocol.handler.BridgeThreadDispatcher
|
|
23
|
+
import org.json.JSONObject
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
class RealLynxBridgeDelegate(val obj: Any?) {
|
|
29
|
+
private val TAG = "RealLynxBridgeDelegate"
|
|
30
|
+
|
|
31
|
+
private val bridgeThreadDispatcher: BridgeThreadDispatcher = SparklingBridge.bridgeThreadDispatcher
|
|
32
|
+
|
|
33
|
+
fun call(
|
|
34
|
+
bridgeName: String,
|
|
35
|
+
params: ReadableMap? = null,
|
|
36
|
+
callback: Callback? = null,
|
|
37
|
+
fromEngine: String
|
|
38
|
+
) {
|
|
39
|
+
if (obj is BridgeContext) {
|
|
40
|
+
val call = BridgeCall(obj).apply {
|
|
41
|
+
this.callbackId = "lynx"
|
|
42
|
+
this.bridgeName = bridgeName
|
|
43
|
+
this.params = params
|
|
44
|
+
this.platform = BridgeCall.PlatForm.Lynx
|
|
45
|
+
this.jsbEngine = fromEngine
|
|
46
|
+
this.url = obj.getCurrentUrl() ?: ""
|
|
47
|
+
params?.let {
|
|
48
|
+
this.timestamp = it.getLong("__timestamp", System.currentTimeMillis())
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
val threadTypeParam =
|
|
52
|
+
if (params.getMap("data")?.hasKey("threadType") == true) {
|
|
53
|
+
params.getMap("data").getString("threadType", "")
|
|
54
|
+
} else {
|
|
55
|
+
params.getString("threadType", "")
|
|
56
|
+
}
|
|
57
|
+
if (threadTypeParam.isNotEmpty()) {
|
|
58
|
+
this.bridgeCallThreadType =
|
|
59
|
+
threadStringToThreadTypeEnum(threadTypeParam)
|
|
60
|
+
}
|
|
61
|
+
} catch (e: Exception) {
|
|
62
|
+
this.jsbSDKErrorReportModel.putJsbExtension(
|
|
63
|
+
"jsb_thread_type_getter_error",
|
|
64
|
+
e.message
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
// the params priority is higher than the BridgeCallThreadTypeConfig
|
|
68
|
+
if (this.bridgeCallThreadType == null) {
|
|
69
|
+
val threadConfig =
|
|
70
|
+
obj.sparklingBridge?.getBridgeSDKContext()?.getObject(
|
|
71
|
+
BridgeCallThreadTypeConfig::class.java
|
|
72
|
+
)
|
|
73
|
+
this.bridgeCallThreadType =
|
|
74
|
+
threadConfig?.getBridgeCallThreadType(this.bridgeName, this)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (obj.defaultCallHandler.isReleased()) {
|
|
80
|
+
LogUtils.d(TAG, "Bridge is released. bridgeName = $bridgeName")
|
|
81
|
+
onLynxBridgeResult(
|
|
82
|
+
BridgeResult.toJsonResult(
|
|
83
|
+
IDLBridgeMethod.BRIDGE_HAS_BEEN_RELEASED,
|
|
84
|
+
"Bridge is released, please check it with container's owner."
|
|
85
|
+
), call, obj, false, callback
|
|
86
|
+
)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
LogUtils.d(TAG, "Bridge is alive. bridgeName = $bridgeName")
|
|
90
|
+
|
|
91
|
+
obj.bridgeLifeClientImp.onBridgeCalledStart(call, obj)
|
|
92
|
+
|
|
93
|
+
bridgeThreadDispatcher.dispatchLynxBridgeThread(call) { isInMainThread ->
|
|
94
|
+
obj.dispatcher?.onDispatchBridgeMethod(call, object : IBridgeCallback {
|
|
95
|
+
override fun onBridgeResult(
|
|
96
|
+
result: BridgeResult,
|
|
97
|
+
call: BridgeCall?,
|
|
98
|
+
monitorBuilder: BridgeSDKMonitor.MonitorModel.Builder?
|
|
99
|
+
) {
|
|
100
|
+
onLynxBridgeResult(result, call, obj, isInMainThread, callback)
|
|
101
|
+
}
|
|
102
|
+
}, obj, null)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private fun onLynxBridgeResult(
|
|
110
|
+
result: BridgeResult,
|
|
111
|
+
call: BridgeCall?,
|
|
112
|
+
obj: BridgeContext,
|
|
113
|
+
isInMainThread: Boolean,
|
|
114
|
+
callback: Callback?
|
|
115
|
+
) {
|
|
116
|
+
LogUtils.d(TAG, "onBridgeResult,result:$result,call:$call")
|
|
117
|
+
|
|
118
|
+
call?.let { obj.bridgeLifeClientImp.onBridgeCallbackCallStart(result, it, obj) }
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
val map = if (result.parcel is JavaOnlyMap) {
|
|
122
|
+
result.parcel
|
|
123
|
+
} else if (result.parcel is JSONObject) {
|
|
124
|
+
BridgeConverter.convertJSONObject2JavaOnlyMap(result.parcel)
|
|
125
|
+
} else if (result.parcel is Map<*, *>) {
|
|
126
|
+
JavaOnlyMap.from(result.parcel)
|
|
127
|
+
} else {
|
|
128
|
+
JavaOnlyMap()
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
call?.apply {
|
|
132
|
+
this.lynxCallbackMap = map
|
|
133
|
+
this.isInMainThread = isInMainThread
|
|
134
|
+
}
|
|
135
|
+
if (call != null) {
|
|
136
|
+
obj.bridgeLifeClientImp.onBridgeCallbackInvokeStart(result, call)
|
|
137
|
+
}
|
|
138
|
+
callback?.invoke(map)
|
|
139
|
+
|
|
140
|
+
if (call != null) {
|
|
141
|
+
obj.bridgeLifeClientImp.onBridgeCalledEnd(call, obj)
|
|
142
|
+
}
|
|
143
|
+
} catch (e: Exception) {
|
|
144
|
+
e.printStackTrace()
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitor.kt
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
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.impl.monitor
|
|
7
|
+
|
|
8
|
+
import android.content.Context
|
|
9
|
+
import com.tiktok.sparkling.method.protocol.utils.MonitorUtils
|
|
10
|
+
import org.json.JSONObject
|
|
11
|
+
|
|
12
|
+
class BridgeSDKMonitor {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "BridgeSDKMonitor"
|
|
15
|
+
private const val SERVICE_NAME = "bridge_performance"
|
|
16
|
+
var channel_: String = ""
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
constructor(
|
|
20
|
+
context: Context,
|
|
21
|
+
appInfo: APPInfo4Monitor,
|
|
22
|
+
) {
|
|
23
|
+
val appVersion = appInfo.appVersion
|
|
24
|
+
val updateVersionCode = appInfo.update_version_code
|
|
25
|
+
val channel = appInfo.channel
|
|
26
|
+
val sdkVersion = appInfo.sdkVersion
|
|
27
|
+
channel_ = channel ?: ""
|
|
28
|
+
|
|
29
|
+
val header = JSONObject()
|
|
30
|
+
header.apply {
|
|
31
|
+
// optional,the major version number of the host
|
|
32
|
+
put("app_version", appVersion)
|
|
33
|
+
// optional, the minor version number of the host
|
|
34
|
+
put("update_version_code", updateVersionCode)
|
|
35
|
+
put("channel", channel)
|
|
36
|
+
// optional,sdk version
|
|
37
|
+
put("sdk_version", sdkVersion)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param serviceName event name
|
|
44
|
+
* @param category enumerable Key-Value
|
|
45
|
+
* @param metric not enumerable Key-Value
|
|
46
|
+
* @param logExtr Information fields that other users want to upload, can be queried by hive, and do not participate in the output of the report
|
|
47
|
+
*/
|
|
48
|
+
fun monitorEvent(data: MonitorModel) {
|
|
49
|
+
val category = JSONObject() // enumerable
|
|
50
|
+
val metric = JSONObject() // not enumerable
|
|
51
|
+
|
|
52
|
+
category.put("code", data.code)
|
|
53
|
+
category.put("url", data.url)
|
|
54
|
+
category.put("channel", data.channel)
|
|
55
|
+
category.put("method", data.method)
|
|
56
|
+
category.put("container_type", data.containerType)
|
|
57
|
+
|
|
58
|
+
metric.put("duration", data.duration)
|
|
59
|
+
metric.put("request_data_length", data.request_data_length)
|
|
60
|
+
metric.put("request_send_timestamp", data.request_send_timestamp)
|
|
61
|
+
metric.put("request_receive_timestamp", data.request_receive_timestamp)
|
|
62
|
+
metric.put("request_decode_duration", data.request_decode_duration)
|
|
63
|
+
metric.put("request_duration", data.request_duration)
|
|
64
|
+
|
|
65
|
+
metric.put("response_data_length", data.response_data_length)
|
|
66
|
+
metric.put("response_send_timestamp", data.response_send_timestamp)
|
|
67
|
+
metric.put("response_receive_timestamp", data.response_receive_timestamp)
|
|
68
|
+
metric.put("response_encode_duration", data.response_encode_duration)
|
|
69
|
+
metric.put("response_duration", data.response_duration)
|
|
70
|
+
|
|
71
|
+
MonitorUtils.customReport(SERVICE_NAME, category, metric, null)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
data class APPInfo4Monitor(
|
|
76
|
+
val appVersion: String? = null,
|
|
77
|
+
val update_version_code: String? = null,
|
|
78
|
+
val channel: String? = null,
|
|
79
|
+
val sdkVersion: String? = null
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
enum class ContainerType(val type: String) {
|
|
83
|
+
LYNX("lynx"), H5("h5")
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
data class MonitorModel(
|
|
87
|
+
val method: String?, // not enumerable
|
|
88
|
+
val code: Int?, // enumerable
|
|
89
|
+
val channel: String?, // enumerable
|
|
90
|
+
val containerType: String?, // enumerable
|
|
91
|
+
|
|
92
|
+
val duration: Long?, // not enumerable response.receive_timestamp - request.send_timestamp, unit: ms
|
|
93
|
+
val url: String?, // not enumerable
|
|
94
|
+
|
|
95
|
+
val request_data_length: Int?, // input parameter data size, unit: byte
|
|
96
|
+
val request_send_timestamp: Long?, // send time of fe, unit: ms
|
|
97
|
+
val request_receive_timestamp: Long?, // client receiving timing, unit: ms
|
|
98
|
+
val request_decode_duration: Long?, // data deserialization time, unit: ms
|
|
99
|
+
val request_duration: Long?, // receive_timestamp - send_timestamp, unit: ms
|
|
100
|
+
|
|
101
|
+
val response_data_length: Int?, // return parameter data size, unit: byte
|
|
102
|
+
val response_encode_duration: Long?, // data serialization time, unit:ms
|
|
103
|
+
val response_send_timestamp: Long?, // client sending timing, unit: ms
|
|
104
|
+
val response_receive_timestamp: Long?, // front-end reception timing, unit: ms
|
|
105
|
+
val response_duration: Long? // receive_timestamp - send_timestamp, unit: ms
|
|
106
|
+
) {
|
|
107
|
+
|
|
108
|
+
class Builder() {
|
|
109
|
+
private var method: String? = null
|
|
110
|
+
private var code: Int? = null
|
|
111
|
+
private var channel: String? = null
|
|
112
|
+
private var containerType: String? = null
|
|
113
|
+
|
|
114
|
+
private var duration: Long? = null
|
|
115
|
+
private var url: String? = null
|
|
116
|
+
|
|
117
|
+
private var request_data_length: Int? = null
|
|
118
|
+
private var request_send_timestamp: Long? = null
|
|
119
|
+
private var request_receive_timestamp: Long? = null
|
|
120
|
+
private var request_decode_duration: Long? = null
|
|
121
|
+
private var request_duration: Long? = null
|
|
122
|
+
|
|
123
|
+
private var response_data_length: Int? = null
|
|
124
|
+
private var response_encode_duration: Long? = null
|
|
125
|
+
private var response_send_timestamp: Long? = null
|
|
126
|
+
private var response_receive_timestamp: Long? = null
|
|
127
|
+
private var response_duration: Long? = null
|
|
128
|
+
|
|
129
|
+
fun setMethod(str: String): Builder {
|
|
130
|
+
this.method = str
|
|
131
|
+
return this
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
fun setURL(url: String): Builder {
|
|
135
|
+
this.url = url
|
|
136
|
+
return this
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
fun setCode(code: Int): Builder {
|
|
140
|
+
this.code = code
|
|
141
|
+
return this
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
fun setChannel(channel: String): Builder {
|
|
145
|
+
this.channel = channel
|
|
146
|
+
return this
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
fun setContainerType(type: String): Builder {
|
|
150
|
+
this.containerType = type
|
|
151
|
+
return this
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
fun setDuration(): Builder {
|
|
155
|
+
if (response_receive_timestamp != null && request_send_timestamp != null)
|
|
156
|
+
this.duration = response_receive_timestamp!! - request_send_timestamp!!
|
|
157
|
+
return this
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
fun setRequestDataLength(length: Int): Builder {
|
|
161
|
+
this.request_data_length = length
|
|
162
|
+
return this
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
fun setRequestSendTimestamp(ts: Long): Builder {
|
|
166
|
+
this.request_send_timestamp = ts
|
|
167
|
+
return this
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
fun setRequestReceiveTimestamp(ts: Long): Builder {
|
|
171
|
+
this.request_receive_timestamp = ts
|
|
172
|
+
return this
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
fun setRequestDuration(): Builder {
|
|
176
|
+
if (request_receive_timestamp != null && request_send_timestamp != null)
|
|
177
|
+
this.request_duration = request_receive_timestamp!! - request_send_timestamp!!
|
|
178
|
+
return this
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
fun setRequestDecodeDuration(duration: Long): Builder {
|
|
182
|
+
this.request_decode_duration = duration
|
|
183
|
+
return this
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
///
|
|
187
|
+
|
|
188
|
+
fun setResponseDataLength(length: Int): Builder {
|
|
189
|
+
this.response_data_length = length
|
|
190
|
+
return this
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
fun setResponseSendTimestamp(ts: Long): Builder {
|
|
194
|
+
this.response_send_timestamp = ts
|
|
195
|
+
return this
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
fun setResponseReceiveTimestamp(ts: Long): Builder {
|
|
199
|
+
this.response_receive_timestamp = ts
|
|
200
|
+
return this
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
fun setResponseDuration(): Builder {
|
|
204
|
+
if (response_receive_timestamp != null && response_send_timestamp != null)
|
|
205
|
+
this.response_duration =
|
|
206
|
+
response_receive_timestamp!! - response_send_timestamp!!
|
|
207
|
+
return this
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
fun setResponseEncodeDuration(duration: Long): Builder {
|
|
211
|
+
this.response_encode_duration = duration
|
|
212
|
+
return this
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
fun build(): MonitorModel {
|
|
216
|
+
return MonitorModel(
|
|
217
|
+
method,
|
|
218
|
+
code,
|
|
219
|
+
channel,
|
|
220
|
+
containerType,
|
|
221
|
+
duration,
|
|
222
|
+
url,
|
|
223
|
+
request_data_length,
|
|
224
|
+
request_send_timestamp,
|
|
225
|
+
request_receive_timestamp,
|
|
226
|
+
request_decode_duration,
|
|
227
|
+
request_duration,
|
|
228
|
+
response_data_length,
|
|
229
|
+
response_encode_duration,
|
|
230
|
+
response_send_timestamp,
|
|
231
|
+
response_receive_timestamp,
|
|
232
|
+
response_duration
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
}
|
package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/IBridgeMonitor.kt
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
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.impl.monitor
|
|
7
|
+
|
|
8
|
+
import android.util.Log
|
|
9
|
+
import org.json.JSONObject
|
|
10
|
+
|
|
11
|
+
interface IBridgeMonitor {
|
|
12
|
+
fun onBridgeRejected(entity: MonitorEntity)
|
|
13
|
+
fun onBridgeResolved(entity: MonitorEntity)
|
|
14
|
+
fun onBridgeEvent(eventName: String, data: JSONObject?) {
|
|
15
|
+
Log.d("IBridgeMonitor", "eventName = $eventName, data = ${data.toString()}")
|
|
16
|
+
}
|
|
17
|
+
}
|
package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntity.kt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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.impl.monitor
|
|
7
|
+
|
|
8
|
+
import org.json.JSONObject
|
|
9
|
+
|
|
10
|
+
class MonitorEntity {
|
|
11
|
+
var name:String? = null
|
|
12
|
+
var code:Int? = null
|
|
13
|
+
var message:String? = null
|
|
14
|
+
var url:String? = null
|
|
15
|
+
var beginTime:Long? = null
|
|
16
|
+
var endTime:Long? = null
|
|
17
|
+
var rawResult: JSONObject? = null
|
|
18
|
+
var rawRequest: JSONObject? = null
|
|
19
|
+
var hitBusinessHandler: Boolean = false
|
|
20
|
+
var nameSpace: String? = null
|
|
21
|
+
var isRunInMainThread: Boolean = true
|
|
22
|
+
}
|