sparkling-method 2.1.0-rc.2 → 2.1.0-rc.24
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/ios/Sources/Core/DI/DIContainerProtocol.swift +1 -1
- package/ios/Sources/Core/DI/DIProviderRegistry.swift +1 -1
- package/ios/Sources/Core/Examples/SampleMethod+impl.swift +3 -3
- package/ios/Sources/Core/Examples/SampleMethod.swift +7 -7
- package/ios/Sources/Core/Models/MethodContext.swift +5 -5
- package/ios/Sources/Core/Models/MethodStatus.swift +24 -24
- package/ios/Sources/Core/Pipe/MethodPipe+Internal.swift +9 -8
- package/ios/Sources/Core/Pipe/MethodPipe.swift +8 -8
- package/ios/Sources/Core/Pipe/MethodRegistry.swift +26 -25
- package/ios/Sources/Core/Protocols/MethodModel.swift +41 -36
- package/ios/Sources/Core/Protocols/PipeMethod.swift +13 -13
- package/ios/Sources/Core/Utils/AnyCodableValue.swift +6 -6
- package/ios/Sources/Core/Utils/NSString+SPKBridgeAdditions.swift +2 -2
- package/ios/Sources/Core/Utils/ReadWriteLock.swift +6 -6
- package/ios/Sources/Core/Utils/SPKHttpResponseChromium.swift +3 -3
- package/ios/Sources/Core/Utils/SPKNetworkManager.swift +50 -46
- package/ios/Sources/Core/Utils/SPKReachability.swift +16 -12
- package/ios/Sources/DIProvider/DIContainer.swift +9 -9
- package/ios/Sources/DIProvider/DefaultDIContainerProvider.swift +3 -3
- package/ios/Sources/Debug/MethodPipe+Debug.swift +6 -4
- package/ios/Sources/Lynx/Definitions/LynxPipeStatusCode.swift +7 -7
- package/ios/Sources/Lynx/Engine/LynxConfig+SPKPipe.swift +5 -5
- package/ios/Sources/Lynx/Engine/LynxContext+SPKPipe.swift +2 -2
- package/ios/Sources/Lynx/Engine/LynxPipeEngine.swift +5 -5
- package/ios/Sources/Lynx/Engine/LynxPipeEnginePool.swift +5 -5
- package/ios/Sources/Lynx/Engine/LynxView+SPKPipe.swift +3 -3
- package/ios/Sources/Lynx/Engine/SPKLynxModuleService.swift +8 -4
- package/ios/Sources/Lynx/Models/LynxRecvMessage.swift +3 -3
- package/ios/Sources/Lynx/Models/LynxSendMessage.swift +7 -7
- package/ios/Sources/Lynx/Module/SPKLynxNativeModule.swift +7 -7
- package/ios/Sources/Lynx/Pipe/MethodPipe+Lynx.swift +11 -9
- package/ios/SparklingMethod.podspec +12 -12
- package/package.json +7 -2
- package/android/build.gradle.kts +0 -245
- package/android/gradle.properties +0 -1
- package/android/proguard-rules.pro +0 -21
- package/android/src/androidTest/java/com/tiktok/sparkling/sparkling/methods/ExampleInstrumentedTest.kt +0 -27
- package/android/src/main/AndroidManifest.xml +0 -5
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/BridgeContext.kt +0 -74
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImp.kt +0 -47
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImp.kt +0 -233
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/InnerBridge.kt +0 -134
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeCall.kt +0 -79
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/entity/BridgeResult.kt +0 -68
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcher.kt +0 -198
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManager.kt +0 -16
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcher.kt +0 -56
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModel.kt +0 -144
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptor.kt +0 -30
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModel.kt +0 -66
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModule.kt +0 -31
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtol.kt +0 -69
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModule.kt +0 -31
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxViewImpl.kt +0 -29
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegate.kt +0 -147
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitor.kt +0 -239
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/IBridgeMonitor.kt +0 -17
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntity.kt +0 -22
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeCallback.kt +0 -14
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeClient.kt +0 -19
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeHandler.kt +0 -23
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeLifeClient.kt +0 -45
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeMethodCallback.kt +0 -10
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/interfaces/IBridgeProtocol.kt +0 -22
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConstants.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/BridgeConverter.kt +0 -147
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/LogUtils.kt +0 -37
- package/android/src/main/java/com/tiktok/sparkling/method/protocol/utils/MonitorUtils.kt +0 -41
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeLocalPool.kt +0 -70
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BridgeSettings.kt +0 -19
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/BusinessCallHandler.kt +0 -100
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/CancelCallbackConfig.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/DefaultCallHandler.kt +0 -106
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/IBridgeMethod.kt +0 -118
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/PiperDataExt.kt +0 -71
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/SparklingBridge.kt +0 -374
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/Utils.kt +0 -89
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/interfaces/IBridgeNotFound.kt +0 -11
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxDataProcessorForMap.kt +0 -204
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/LynxPlatformDataProcessor.kt +0 -239
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebPlatformDataProcessor.kt +0 -307
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/processor/WebProcessorForMap.kt +0 -227
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeMethodCallbackHelper.kt +0 -29
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/BridgeProtocolConstants.kt +0 -12
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtils.kt +0 -684
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/IConvertUtils.kt +0 -44
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/LogHelper.kt +0 -30
- package/android/src/main/java/com/tiktok/sparkling/method/registry/api/util/ThreadPool.kt +0 -73
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgeCollections.kt +0 -194
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/BridgePlatformType.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IBridgeContext.kt +0 -137
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLBridgeMethod.kt +0 -100
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodProvider.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistry.kt +0 -132
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCache.kt +0 -150
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryCacheManager.kt +0 -34
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IDLProxyClient.kt +0 -28
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/IRegister.kt +0 -21
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/LocalBridge.kt +0 -70
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/ReadableMapImpl.kt +0 -227
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/RegistryCache.kt +0 -77
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManager.kt +0 -50
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodIntEnum.kt +0 -15
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodName.kt +0 -14
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamField.kt +0 -42
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodParamModel.kt +0 -10
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodResultModel.kt +0 -10
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/annotation/IDLMethodStringEnum.kt +0 -15
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethod.kt +0 -276
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodException.kt +0 -10
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalInputParamException.kt +0 -12
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOperationException.kt +0 -12
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/exception/IllegalOutputParamException.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IContainerIDProvider.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/INameSpaceProvider.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IPlatformDataProcessor.kt +0 -19
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/interfaces/IReleasable.kt +0 -13
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/BridgeCallThreadTypeConfig.kt +0 -44
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/context/ContextProviderFactory.kt +0 -133
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/CompletionBlock.kt +0 -26
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLDynamic.kt +0 -97
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseModel.kt +0 -37
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseParamModel.kt +0 -62
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/model/idl/IDLMethodBaseResultModel.kt +0 -18
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/BridgeKTX.kt +0 -37
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IAssignDir.kt +0 -25
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodHelper.kt +0 -44
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelArguments.kt +0 -264
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/IDLMethodResultModelHelper.kt +0 -194
- package/android/src/main/java/com/tiktok/sparkling/method/registry/core/utils/JsonUtils.kt +0 -200
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntime.kt +0 -11
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/CommonDependsProvider.kt +0 -14
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostNetworkDepend.kt +0 -19
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostPermissionDepend.kt +0 -34
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/common/IHostThreadPoolExecutorDepend.kt +0 -12
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStreamConnection.kt +0 -36
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/AbsStringConnection.kt +0 -30
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/HttpRequest.kt +0 -134
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/NetworkRequestImpl.kt +0 -28
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/network/RequestJsonFormatOptionConstants.kt +0 -10
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/BridgeAPIRequestUtils.kt +0 -365
- package/android/src/main/java/com/tiktok/sparkling/method/runtime/depend/utils/HttpUrlBuilder.kt +0 -97
- package/android/src/main/res/drawable/ic_launcher_background.xml +0 -170
- package/android/src/main/res/drawable/ic_launcher_foreground.xml +0 -30
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +0 -6
- package/android/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +0 -6
- 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 +0 -10
- package/android/src/main/res/values/strings.xml +0 -3
- package/android/src/test/java/com/tiktok/sparkling/method/TestApplication.kt +0 -19
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/BridgeContextTest.kt +0 -89
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeClientImpTest.kt +0 -78
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/DefaultBridgeLifeClientImpTest.kt +0 -97
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/InnerBridgeTest.kt +0 -105
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeCallTest.kt +0 -61
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/entity/BridgeResultTest.kt +0 -74
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeDispatcherTest.kt +0 -96
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeFactoryManagerTest.kt +0 -21
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/handler/BridgeThreadDispatcherTest.kt +0 -34
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/errors/JSBErrorReportModelTest.kt +0 -60
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/interceptor/BridgeMockInterceptorTest.kt +0 -51
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lifecycle/fe/FeCallMonitorModelTest.kt +0 -65
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeDelegateModuleTest.kt +0 -57
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxBridgeProtocolTest.kt +0 -10
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/LynxRuntimeBridgeDelegateModuleTest.kt +0 -37
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/lynx/RealLynxBridgeDelegateTest.kt +0 -10
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/BridgeSDKMonitorTest.kt +0 -10
- package/android/src/test/java/com/tiktok/sparkling/method/protocol/impl/monitor/MonitorEntityTest.kt +0 -43
- package/android/src/test/java/com/tiktok/sparkling/method/registry/api/SparklingBridgeTest.kt +0 -444
- package/android/src/test/java/com/tiktok/sparkling/method/registry/api/util/DataConvertUtilsTest.kt +0 -236
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/IDLMethodRegistryTest.kt +0 -331
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/LocalBridgeTest.kt +0 -299
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/SparklingBridgeManagerTest.kt +0 -213
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/base/AbsSparklingIDLMethodTest.kt +0 -307
- package/android/src/test/java/com/tiktok/sparkling/method/registry/core/exception/IDLMethodExceptionTest.kt +0 -311
- package/android/src/test/java/com/tiktok/sparkling/method/runtime/depend/BridgeBaseRuntimeTest.kt +0 -54
- package/android/src/test/resources/robolectric.properties +0 -5
- package/src/index.ts +0 -240
- package/src/types.ts +0 -44
- package/src/typing.d.ts +0 -44
- package/tsconfig.json +0 -15
|
@@ -12,7 +12,7 @@ import Foundation
|
|
|
12
12
|
@objc public protocol CompletionHandlerProtocol {
|
|
13
13
|
func handleCompletion(status: MethodStatus, result: SPKMethodModel?)
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
// Method name, subclasses must override
|
|
17
17
|
@objc open var methodName: String {
|
|
18
18
|
fatalError("Subclasses must override 'methodName'")
|
|
@@ -20,61 +20,61 @@ import Foundation
|
|
|
20
20
|
open class func methodName() -> String {
|
|
21
21
|
fatalError("Subclasses must override 'methodName'")
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
// Whether it's a global method, default is true
|
|
25
25
|
@objc open class var isGlobal: Bool {
|
|
26
26
|
return true
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
|
|
29
29
|
// Parameter model type
|
|
30
30
|
@objc open var paramsModelClass: AnyClass {
|
|
31
31
|
fatalError("Subclasses must override 'paramsModelType'")
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Result model type
|
|
35
35
|
@objc open var resultModelClass: AnyClass {
|
|
36
36
|
fatalError("Subclasses must override 'resultModelType'")
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
// Empty constructor, must use required modifier to support instance creation via metatype
|
|
40
40
|
@objc required public override init() {
|
|
41
41
|
super.init()
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
// Main call method, subclasses must implement - Using Objective-C compatible way
|
|
45
45
|
@objc dynamic open func call(withParamModel paramModel: Any, completionHandler: CompletionHandlerProtocol) {
|
|
46
46
|
fatalError("Subclasses must override 'call(withParamModel:completionHandler:)")
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
// Convenience method for Swift calls
|
|
50
50
|
public func call(withParamModel paramModel: Any, completionHandler: @escaping (_ status: MethodStatus, _ result: SPKMethodModel?) -> Void) {
|
|
51
51
|
let handler = ClosureCompletionHandler(closure: completionHandler)
|
|
52
52
|
call(withParamModel: paramModel, completionHandler: handler)
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// CompletionHandlerProtocol implementation that wraps a closure
|
|
56
56
|
private class ClosureCompletionHandler: NSObject, CompletionHandlerProtocol {
|
|
57
57
|
private let closure: (_ status: MethodStatus, _ result: SPKMethodModel?) -> Void
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
init(closure: @escaping (_ status: MethodStatus, _ result: SPKMethodModel?) -> Void) {
|
|
60
60
|
self.closure = closure
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
func handleCompletion(status: MethodStatus, result: SPKMethodModel?) {
|
|
64
64
|
closure(status, result)
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
// Compatibility method
|
|
69
69
|
open func invoke(withParams params: Any, completion: @escaping (_ status: MethodStatus, _ result: SPKMethodModel?) -> Void) {
|
|
70
70
|
call(withParamModel: params, completionHandler: completion)
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
internal func invokeErased(withParams params: Any, completion: @escaping CompletionBlock) {
|
|
74
74
|
// Default implementation, subclasses can override as needed
|
|
75
75
|
call(withParamModel: params, completionHandler: completion)
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
// Handle unimplemented methods
|
|
79
79
|
public func handleNotImplemented(message: String? = nil, completion: CompletionBlock) {
|
|
80
80
|
let status = MethodStatus.notImplemented(message: message ?? "The method '\(Self.methodName())' is not implemented")
|
|
@@ -9,7 +9,7 @@ public enum AnyCodableValue: Codable {
|
|
|
9
9
|
case bool(Bool)
|
|
10
10
|
case dictionary([String: AnyCodableValue])
|
|
11
11
|
case array([AnyCodableValue])
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
public init?(_ any: Any) {
|
|
14
14
|
switch any {
|
|
15
15
|
case let v as String:
|
|
@@ -30,7 +30,7 @@ public enum AnyCodableValue: Codable {
|
|
|
30
30
|
return nil
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
public init(from decoder: Decoder) throws {
|
|
35
35
|
let container = try decoder.singleValueContainer()
|
|
36
36
|
if let int = try? container.decode(Int.self) {
|
|
@@ -52,7 +52,7 @@ public enum AnyCodableValue: Codable {
|
|
|
52
52
|
)
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
public func encode(to encoder: Encoder) throws {
|
|
57
57
|
var container = encoder.singleValueContainer()
|
|
58
58
|
switch self {
|
|
@@ -89,7 +89,7 @@ extension AnyCodableValue {
|
|
|
89
89
|
return arr.map { $0.anyValue }
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
|
|
93
93
|
public func get<T>() -> T? {
|
|
94
94
|
switch self {
|
|
95
95
|
case .string(let v as T):
|
|
@@ -107,7 +107,7 @@ extension AnyCodableValue {
|
|
|
107
107
|
default: return nil
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
|
|
111
111
|
public func dictionaryValue<ValueType>() -> [String: ValueType]? {
|
|
112
112
|
if case .dictionary(let dict) = self {
|
|
113
113
|
return dict.reduce(into: [String: ValueType]()) { result, pair in
|
|
@@ -118,7 +118,7 @@ extension AnyCodableValue {
|
|
|
118
118
|
}
|
|
119
119
|
return nil
|
|
120
120
|
}
|
|
121
|
-
|
|
121
|
+
|
|
122
122
|
public func arrayValue<ValueType>() -> [ValueType]? {
|
|
123
123
|
if case .array(let arr) = self {
|
|
124
124
|
return arr.compactMap { $0.anyValue as? ValueType }
|
|
@@ -10,13 +10,13 @@ extension String {
|
|
|
10
10
|
// Implement simplified version to remove common sandbox path prefixes
|
|
11
11
|
let fileManager = FileManager.default
|
|
12
12
|
let homeDirectory = NSHomeDirectory()
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
if self.hasPrefix(homeDirectory) {
|
|
15
15
|
return self.replacingOccurrences(of: homeDirectory, with: "")
|
|
16
16
|
}
|
|
17
17
|
return self
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
/// Get actual path from processed file path
|
|
21
21
|
public func spk_stringFromProcessFile() -> String {
|
|
22
22
|
// Implement simplified version, assuming input is already a full path
|
|
@@ -6,28 +6,28 @@ import Foundation
|
|
|
6
6
|
|
|
7
7
|
final class ReadWriteLock {
|
|
8
8
|
private var lock = pthread_rwlock_t()
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
init() {
|
|
11
11
|
pthread_rwlock_init(&lock, nil)
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
deinit {
|
|
15
15
|
pthread_rwlock_destroy(&lock)
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
func read<T>(_ block: () -> T) -> T {
|
|
19
19
|
pthread_rwlock_rdlock(&lock)
|
|
20
20
|
defer { pthread_rwlock_unlock(&lock) }
|
|
21
21
|
return block()
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
func write<T>(_ block: () -> T) -> T {
|
|
25
25
|
pthread_rwlock_wrlock(&lock)
|
|
26
26
|
defer { pthread_rwlock_unlock(&lock) }
|
|
27
27
|
return block()
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
func sync<T>(_ block: () -> T) -> T {
|
|
31
31
|
return write(block)
|
|
32
32
|
}
|
|
33
|
-
}
|
|
33
|
+
}
|
|
@@ -7,7 +7,7 @@ import Foundation
|
|
|
7
7
|
/// HTTP response Swift implementation
|
|
8
8
|
public class SPKHttpResponse: NSObject {
|
|
9
9
|
public var allHeaderFields: [AnyHashable: Any]? = [:]
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
init(allHeaderFields: [AnyHashable: Any]? = nil) {
|
|
12
12
|
self.allHeaderFields = allHeaderFields
|
|
13
13
|
}
|
|
@@ -16,9 +16,9 @@ public class SPKHttpResponse: NSObject {
|
|
|
16
16
|
/// Chromium-style HTTP response
|
|
17
17
|
public class SPKHttpResponseChromium: SPKHttpResponse {
|
|
18
18
|
public var statusCode: Int = 200
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
init(statusCode: Int = 200, allHeaderFields: [AnyHashable: Any]? = nil) {
|
|
21
21
|
self.statusCode = statusCode
|
|
22
22
|
super.init(allHeaderFields: allHeaderFields)
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -15,15 +15,15 @@ public protocol SPKHttpTaskProtocol {
|
|
|
15
15
|
public class SPKHttpTask: NSObject, SPKHttpTaskProtocol {
|
|
16
16
|
public var protectTimeout: TimeInterval = 30
|
|
17
17
|
public var timeoutInterval: TimeInterval = 30
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
private let dataTask: URLSessionDataTask?
|
|
20
20
|
private let downloadTask: URLSessionDownloadTask?
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
init(dataTask: URLSessionDataTask? = nil, downloadTask: URLSessionDownloadTask? = nil) {
|
|
23
23
|
self.dataTask = dataTask
|
|
24
24
|
self.downloadTask = downloadTask
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
public func resume() {
|
|
28
28
|
dataTask?.resume()
|
|
29
29
|
downloadTask?.resume()
|
|
@@ -33,24 +33,26 @@ public class SPKHttpTask: NSObject, SPKHttpTaskProtocol {
|
|
|
33
33
|
/// Network manager
|
|
34
34
|
public class TTNetworkManager: NSObject {
|
|
35
35
|
public static let shared = TTNetworkManager()
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
private let session: URLSession
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
private override init() {
|
|
40
40
|
let configuration = URLSessionConfiguration.default
|
|
41
41
|
session = URLSession(configuration: configuration)
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
|
|
44
44
|
/// Download task
|
|
45
|
-
public func downloadTaskWithRequest(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
public func downloadTaskWithRequest(
|
|
46
|
+
_ urlString: String,
|
|
47
|
+
parameters: [String: Any]?,
|
|
48
|
+
headerField: [String: Any]?,
|
|
49
|
+
needCommonParams: Bool,
|
|
50
|
+
progress: ((Float) -> Void)?,
|
|
51
|
+
destination: URL,
|
|
52
|
+
autoResume: Bool,
|
|
53
|
+
completionHandler: @escaping (SPKHttpResponse?, URL?, Error?) -> Void
|
|
54
|
+
) -> SPKHttpTask {
|
|
55
|
+
|
|
54
56
|
// Simplified download implementation
|
|
55
57
|
guard let url = URL(string: urlString) else {
|
|
56
58
|
let error = NSError(domain: "TTNetworkError", code: -1000, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"])
|
|
@@ -59,28 +61,28 @@ public class TTNetworkManager: NSObject {
|
|
|
59
61
|
}
|
|
60
62
|
return SPKHttpTask()
|
|
61
63
|
}
|
|
62
|
-
|
|
64
|
+
|
|
63
65
|
var request = URLRequest(url: url)
|
|
64
66
|
request.httpMethod = "GET"
|
|
65
|
-
|
|
67
|
+
|
|
66
68
|
// Add request headers
|
|
67
69
|
if let headers = headerField as? [String: String] {
|
|
68
70
|
for (key, value) in headers {
|
|
69
71
|
request.setValue(value, forHTTPHeaderField: key)
|
|
70
72
|
}
|
|
71
73
|
}
|
|
72
|
-
|
|
74
|
+
|
|
73
75
|
// Download task
|
|
74
76
|
let downloadTask = session.downloadTask(with: request) { [weak self] location, response, error in
|
|
75
77
|
guard let self = self else { return }
|
|
76
|
-
|
|
78
|
+
|
|
77
79
|
if let error = error {
|
|
78
80
|
DispatchQueue.main.async {
|
|
79
81
|
completionHandler(nil, nil, error)
|
|
80
82
|
}
|
|
81
83
|
return
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
|
|
84
86
|
guard let location = location else {
|
|
85
87
|
let error = NSError(domain: "TTNetworkError", code: -1001, userInfo: [NSLocalizedDescriptionKey: "Download location not found"])
|
|
86
88
|
DispatchQueue.main.async {
|
|
@@ -88,7 +90,7 @@ public class TTNetworkManager: NSObject {
|
|
|
88
90
|
}
|
|
89
91
|
return
|
|
90
92
|
}
|
|
91
|
-
|
|
93
|
+
|
|
92
94
|
do {
|
|
93
95
|
// Move file to destination
|
|
94
96
|
let fileManager = FileManager.default
|
|
@@ -96,7 +98,7 @@ public class TTNetworkManager: NSObject {
|
|
|
96
98
|
try fileManager.removeItem(at: destination)
|
|
97
99
|
}
|
|
98
100
|
try fileManager.moveItem(at: location, to: destination)
|
|
99
|
-
|
|
101
|
+
|
|
100
102
|
// Construct response
|
|
101
103
|
var httpResponse: SPKHttpResponseChromium?
|
|
102
104
|
if let urlResponse = response as? HTTPURLResponse {
|
|
@@ -105,7 +107,7 @@ public class TTNetworkManager: NSObject {
|
|
|
105
107
|
allHeaderFields: urlResponse.allHeaderFields
|
|
106
108
|
)
|
|
107
109
|
}
|
|
108
|
-
|
|
110
|
+
|
|
109
111
|
DispatchQueue.main.async {
|
|
110
112
|
completionHandler(httpResponse, destination, nil)
|
|
111
113
|
}
|
|
@@ -115,26 +117,28 @@ public class TTNetworkManager: NSObject {
|
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
|
|
120
|
+
|
|
119
121
|
return SPKHttpTask(downloadTask: downloadTask)
|
|
120
122
|
}
|
|
121
|
-
|
|
123
|
+
|
|
122
124
|
class func shareInstance() -> TTNetworkManager {
|
|
123
125
|
return TTNetworkManager.shared
|
|
124
126
|
}
|
|
125
|
-
|
|
127
|
+
|
|
126
128
|
/// Upload task with multipart form data
|
|
127
|
-
public func uploadTaskWithRequest(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
129
|
+
public func uploadTaskWithRequest(
|
|
130
|
+
_ url: String,
|
|
131
|
+
fileURL: URL,
|
|
132
|
+
name: String,
|
|
133
|
+
fileName: String,
|
|
134
|
+
mimeType: String,
|
|
135
|
+
parameters: [String: Any]?,
|
|
136
|
+
headerField: [String: Any]?,
|
|
137
|
+
needCommonParams: Bool,
|
|
138
|
+
progress: ((Float) -> Void)?,
|
|
139
|
+
completionHandler: @escaping (SPKHttpResponse?, Any?, Error?) -> Void
|
|
140
|
+
) -> SPKHttpTask {
|
|
141
|
+
|
|
138
142
|
// Validate URL
|
|
139
143
|
guard let uploadUrl = URL(string: url) else {
|
|
140
144
|
let error = NSError(domain: "TTNetworkError", code: -1000, userInfo: [NSLocalizedDescriptionKey: "Invalid URL"])
|
|
@@ -143,33 +147,33 @@ public class TTNetworkManager: NSObject {
|
|
|
143
147
|
}
|
|
144
148
|
return SPKHttpTask()
|
|
145
149
|
}
|
|
146
|
-
|
|
150
|
+
|
|
147
151
|
// Create URLRequest
|
|
148
152
|
var request = URLRequest(url: uploadUrl)
|
|
149
153
|
request.httpMethod = "POST"
|
|
150
|
-
|
|
154
|
+
|
|
151
155
|
// Add request headers
|
|
152
156
|
if let headers = headerField as? [String: String] {
|
|
153
157
|
for (key, value) in headers {
|
|
154
158
|
request.setValue(value, forHTTPHeaderField: key)
|
|
155
159
|
}
|
|
156
160
|
}
|
|
157
|
-
|
|
161
|
+
|
|
158
162
|
// Create multipart form data upload task
|
|
159
163
|
let boundary = "Boundary-\(UUID().uuidString)"
|
|
160
164
|
request.setValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
|
|
161
|
-
|
|
165
|
+
|
|
162
166
|
// Create upload task with multipart form data
|
|
163
167
|
let uploadTask = session.uploadTask(with: request, fromFile: fileURL) { [weak self] data, response, error in
|
|
164
168
|
guard let self = self else { return }
|
|
165
|
-
|
|
169
|
+
|
|
166
170
|
if let error = error {
|
|
167
171
|
DispatchQueue.main.async {
|
|
168
172
|
completionHandler(nil, nil, error)
|
|
169
173
|
}
|
|
170
174
|
return
|
|
171
175
|
}
|
|
172
|
-
|
|
176
|
+
|
|
173
177
|
// Construct response
|
|
174
178
|
var httpResponse: SPKHttpResponseChromium?
|
|
175
179
|
if let urlResponse = response as? HTTPURLResponse {
|
|
@@ -178,7 +182,7 @@ public class TTNetworkManager: NSObject {
|
|
|
178
182
|
allHeaderFields: urlResponse.allHeaderFields
|
|
179
183
|
)
|
|
180
184
|
}
|
|
181
|
-
|
|
185
|
+
|
|
182
186
|
// Parse response data if available
|
|
183
187
|
var responseObject: Any? = nil
|
|
184
188
|
if let data = data {
|
|
@@ -189,12 +193,12 @@ public class TTNetworkManager: NSObject {
|
|
|
189
193
|
responseObject = String(data: data, encoding: .utf8)
|
|
190
194
|
}
|
|
191
195
|
}
|
|
192
|
-
|
|
196
|
+
|
|
193
197
|
DispatchQueue.main.async {
|
|
194
198
|
completionHandler(httpResponse, responseObject, nil)
|
|
195
199
|
}
|
|
196
200
|
}
|
|
197
|
-
|
|
201
|
+
|
|
198
202
|
return SPKHttpTask(dataTask: uploadTask)
|
|
199
203
|
}
|
|
200
204
|
}
|
|
@@ -8,34 +8,38 @@ import SystemConfiguration
|
|
|
8
8
|
/// Network reachability utility class
|
|
9
9
|
public class SPKReachability: NSObject {
|
|
10
10
|
private var reachability: SCNetworkReachability?
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
/// Check if network is reachable
|
|
13
13
|
class func isReachable() -> Bool {
|
|
14
14
|
var zeroAddress = sockaddr_in()
|
|
15
15
|
zeroAddress.sin_len = UInt8(MemoryLayout<sockaddr_in>.size)
|
|
16
16
|
zeroAddress.sin_family = sa_family_t(AF_INET)
|
|
17
|
-
|
|
18
|
-
guard
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
|
|
18
|
+
guard
|
|
19
|
+
let reachability = withUnsafePointer(
|
|
20
|
+
to: &zeroAddress,
|
|
21
|
+
{
|
|
22
|
+
$0.withMemoryRebound(to: sockaddr.self, capacity: 1) {
|
|
23
|
+
SCNetworkReachabilityCreateWithAddress(nil, $0)
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
else {
|
|
23
27
|
return false
|
|
24
28
|
}
|
|
25
|
-
|
|
29
|
+
|
|
26
30
|
var flags: SCNetworkReachabilityFlags = []
|
|
27
31
|
if !SCNetworkReachabilityGetFlags(reachability, &flags) {
|
|
28
32
|
return false
|
|
29
33
|
}
|
|
30
|
-
|
|
34
|
+
|
|
31
35
|
let isReachable = flags.contains(.reachable)
|
|
32
36
|
let needsConnection = flags.contains(.connectionRequired)
|
|
33
37
|
let canConnectAutomatically = flags.contains(.connectionOnDemand) || flags.contains(.connectionOnTraffic)
|
|
34
38
|
let canConnectWithoutUserInteraction = canConnectAutomatically && !flags.contains(.interventionRequired)
|
|
35
|
-
|
|
39
|
+
|
|
36
40
|
return isReachable && (!needsConnection || canConnectWithoutUserInteraction)
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
|
|
39
43
|
/// Singleton method
|
|
40
44
|
class func sharedInstance() -> SPKReachability {
|
|
41
45
|
struct Static {
|
|
@@ -43,4 +47,4 @@ public class SPKReachability: NSObject {
|
|
|
43
47
|
}
|
|
44
48
|
return Static.instance
|
|
45
49
|
}
|
|
46
|
-
}
|
|
50
|
+
}
|
|
@@ -7,17 +7,17 @@ import Foundation
|
|
|
7
7
|
private struct ServiceKey: Hashable {
|
|
8
8
|
let typeIdentifier: ObjectIdentifier
|
|
9
9
|
let name: AnyHashable?
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
init<T>(_ serviceType: T.Type, name: AnyHashable? = nil) {
|
|
12
12
|
self.typeIdentifier = ObjectIdentifier(serviceType)
|
|
13
13
|
self.name = name
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
|
|
16
16
|
func hash(into hasher: inout Hasher) {
|
|
17
17
|
hasher.combine(typeIdentifier)
|
|
18
18
|
hasher.combine(name)
|
|
19
19
|
}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
static func == (lhs: ServiceKey, rhs: ServiceKey) -> Bool {
|
|
22
22
|
return lhs.typeIdentifier == rhs.typeIdentifier && lhs.name == rhs.name
|
|
23
23
|
}
|
|
@@ -26,7 +26,7 @@ private struct ServiceKey: Hashable {
|
|
|
26
26
|
internal final class DIContainer: DIContainerProtocol {
|
|
27
27
|
private var factories: [ServiceKey: Any] = [:]
|
|
28
28
|
private var lock = ReadWriteLock()
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
func register<Service>(_ serviceType: Service.Type, name: AnyHashable?, scope: ServiceScope, factory: @escaping Factory<Service>) {
|
|
31
31
|
let key = ServiceKey(serviceType, name: name)
|
|
32
32
|
let entry = ServiceEntry<Service>(scope: scope, factory: factory)
|
|
@@ -34,7 +34,7 @@ internal final class DIContainer: DIContainerProtocol {
|
|
|
34
34
|
factories[key] = entry
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
public func resolve<Service>(_ serviceType: Service.Type, name: AnyHashable?) -> Service? {
|
|
39
39
|
let key = ServiceKey(serviceType, name: name)
|
|
40
40
|
var entry: ServiceEntry<Service>?
|
|
@@ -49,12 +49,12 @@ internal final class DIContainer: DIContainerProtocol {
|
|
|
49
49
|
guard let serviceEntry = entry else {
|
|
50
50
|
return nil
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
return lock.write {
|
|
54
54
|
if let instance = serviceEntry.instance {
|
|
55
55
|
return instance
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
let service = serviceEntry.createService()
|
|
59
59
|
if serviceEntry.scope == .container {
|
|
60
60
|
serviceEntry.instance = service
|
|
@@ -68,12 +68,12 @@ private class ServiceEntry<Service> {
|
|
|
68
68
|
var scope: ServiceScope
|
|
69
69
|
var factory: Factory<Service>
|
|
70
70
|
var instance: Service?
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
init(scope: ServiceScope, factory: @escaping Factory<Service>) {
|
|
73
73
|
self.scope = scope
|
|
74
74
|
self.factory = factory
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
|
|
77
77
|
func createService() -> Service {
|
|
78
78
|
return factory()
|
|
79
79
|
}
|
|
@@ -6,15 +6,15 @@ import Foundation
|
|
|
6
6
|
|
|
7
7
|
public struct DefaultDIContainerProvider: DIContainerProvider {
|
|
8
8
|
private static let pipeShared = DIContainer()
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
public static func inject() {
|
|
11
11
|
DIProviderRegistry.provider = DefaultDIContainerProvider()
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
|
|
14
14
|
public func pipeShared() -> any DIContainerProtocol {
|
|
15
15
|
return Self.pipeShared
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
|
|
18
18
|
public func container() -> any DIContainerProtocol {
|
|
19
19
|
return DIContainer()
|
|
20
20
|
}
|
|
@@ -8,7 +8,7 @@ extension MethodPipe {
|
|
|
8
8
|
public convenience init(withNothing nothing: String? = nil) {
|
|
9
9
|
self.init()
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
/// Async/await version of `debugExecuteMethod`.
|
|
13
13
|
/// Wraps the completion-based API with a checked continuation.
|
|
14
14
|
/// - Note: Available on iOS 13+.
|
|
@@ -18,9 +18,11 @@ extension MethodPipe {
|
|
|
18
18
|
/// - thread: Target thread to run the method.
|
|
19
19
|
/// - Returns: A tuple `(status, result)`.
|
|
20
20
|
@available(iOS 13.0, *)
|
|
21
|
-
public func debugExecuteMethod(
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
public func debugExecuteMethod(
|
|
22
|
+
methodName: String,
|
|
23
|
+
params: [String: Any]?,
|
|
24
|
+
thread: MethodThread = .mainThread
|
|
25
|
+
) async -> (MethodStatus, [String: Any]?) {
|
|
24
26
|
await withCheckedContinuation { continuation in
|
|
25
27
|
var resumed = false
|
|
26
28
|
self.executeMethod(methodName: methodName, params: params, thread: thread) { status, result in
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
import Foundation
|
|
6
6
|
|
|
7
7
|
public enum LynxPipeStatusCode: Int {
|
|
8
|
-
case unknownError = -1000
|
|
8
|
+
case unknownError = -1000 // Unknown error
|
|
9
9
|
case manualCallback = -999 // Callback from the business side
|
|
10
|
-
case undefined = -998
|
|
11
|
-
case code404 = -997
|
|
12
|
-
case parameterError = -3
|
|
13
|
-
case noHandler = -2
|
|
14
|
-
case failed = 0
|
|
15
|
-
case succeeded = 1
|
|
10
|
+
case undefined = -998 // Frontend method not defined
|
|
11
|
+
case code404 = -997 // Frontend returns 404
|
|
12
|
+
case parameterError = -3 // Parameter error
|
|
13
|
+
case noHandler = -2 // Method not registered
|
|
14
|
+
case failed = 0 // Failure
|
|
15
|
+
case succeeded = 1 // Success
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
extension LynxPipeStatusCode {
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
import Foundation
|
|
6
6
|
import Lynx
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
extension LynxConfig {
|
|
9
9
|
private struct AssociatedKeys {
|
|
10
10
|
static var spk_containerID: UInt8 = 0
|
|
11
11
|
static var spk_namescope: UInt8 = 0
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
var spk_containerID: String? {
|
|
13
|
+
|
|
14
|
+
public var spk_containerID: String? {
|
|
15
15
|
get {
|
|
16
16
|
return objc_getAssociatedObject(self, &AssociatedKeys.spk_containerID) as? String
|
|
17
17
|
}
|
|
@@ -19,8 +19,8 @@ public extension LynxConfig {
|
|
|
19
19
|
objc_setAssociatedObject(self, &AssociatedKeys.spk_containerID, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
var spk_namescope: String? {
|
|
22
|
+
|
|
23
|
+
public var spk_namescope: String? {
|
|
24
24
|
get {
|
|
25
25
|
return objc_getAssociatedObject(self, &AssociatedKeys.spk_namescope) as? String
|
|
26
26
|
}
|
|
@@ -9,13 +9,13 @@ extension LynxContext {
|
|
|
9
9
|
private struct AssociatedKeys {
|
|
10
10
|
static var spk_containerID: UInt8 = 0
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
var spk_containerID: String? {
|
|
14
14
|
get {
|
|
15
15
|
return objc_getAssociatedObject(self, &AssociatedKeys.spk_containerID) as? String
|
|
16
16
|
}
|
|
17
17
|
set {
|
|
18
|
-
objc_setAssociatedObject(self, &AssociatedKeys.spk_containerID, newValue
|
|
18
|
+
objc_setAssociatedObject(self, &AssociatedKeys.spk_containerID, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}
|