sparkling-method 2.1.0-rc.3 → 2.1.0-rc.30
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 +110 -9
- package/ios/Sources/Core/Pipe/MethodPipe.swift +8 -8
- package/ios/Sources/Core/Pipe/MethodRegistry.swift +26 -25
- package/ios/Sources/Core/Pipe/SparklingMethodInvocationCenter.swift +174 -0
- 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 +10 -5
- package/ios/Sources/Lynx/Engine/LynxPipeEnginePool.swift +5 -5
- package/ios/Sources/Lynx/Engine/LynxView+SPKPipe.swift +8 -4
- 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 +34 -8
- 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
|
@@ -20,7 +20,7 @@ extension DIContainerProtocol {
|
|
|
20
20
|
public func register<Service>(_ serviceType: Service.Type, name: AnyHashable? = nil, scope: ServiceScope = .container, factory: @escaping Factory<Service>) {
|
|
21
21
|
self.register(serviceType, name: name, scope: scope, factory: factory)
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
|
|
24
24
|
public func resolve<Service>(_ serviceType: Service.Type, name: AnyHashable? = nil) -> Service? {
|
|
25
25
|
return self.resolve(serviceType, name: name)
|
|
26
26
|
}
|
|
@@ -13,12 +13,12 @@ import Foundation
|
|
|
13
13
|
completionHandler.handleCompletion(status: .invalidParameter(message: "Invalid parameter model type"), result: nil)
|
|
14
14
|
return
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
// Simulate processing logic
|
|
18
18
|
let result = SampleMethodResultModel()
|
|
19
19
|
result.sampleResult = "Processed: \(params.sampleParam ?? "")"
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
// Return success result
|
|
22
22
|
completionHandler.handleCompletion(status: MethodStatus.succeeded(), result: result)
|
|
23
23
|
}
|
|
24
|
-
}
|
|
24
|
+
}
|
|
@@ -13,7 +13,7 @@ class SampleMethodParamModel: SPKMethodModel {
|
|
|
13
13
|
@objc public static func requiredKeyPaths() -> Set<String>? {
|
|
14
14
|
return ["sampleParam"]
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
override class func jsonKeyPathsByPropertyKey() -> [AnyHashable: Any] {
|
|
18
18
|
return ["sampleParam": "sample_param"]
|
|
19
19
|
}
|
|
@@ -23,12 +23,12 @@ class SampleMethodParamModel: SPKMethodModel {
|
|
|
23
23
|
@objc(SampleMethodResultModel)
|
|
24
24
|
public final class SampleMethodResultModel: SPKMethodModel {
|
|
25
25
|
var sampleResult: String?
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
// Required parameter key paths
|
|
28
28
|
@objc public static func requiredKeyPaths() -> Set<String>? {
|
|
29
29
|
return ["sampleResult"]
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
override class func jsonKeyPathsByPropertyKey() -> [AnyHashable: Any] {
|
|
33
33
|
return ["sampleResult": "sample_result"]
|
|
34
34
|
}
|
|
@@ -41,18 +41,18 @@ public final class SampleMethod: PipeMethod {
|
|
|
41
41
|
public override var methodName: String {
|
|
42
42
|
return "sample_method"
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
public override class func methodName() -> String {
|
|
46
46
|
return "sample_method"
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
/// Parameter model type
|
|
50
50
|
@objc override var paramsModelType: AnyClass {
|
|
51
51
|
return SampleMethodParamModel.self
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
/// Result model type
|
|
55
55
|
@objc override var resultModelType: AnyClass {
|
|
56
56
|
return SampleMethodResultModel.self
|
|
57
57
|
}
|
|
58
|
-
}
|
|
58
|
+
}
|
|
@@ -6,7 +6,7 @@ import Foundation
|
|
|
6
6
|
|
|
7
7
|
final class WeakWrap {
|
|
8
8
|
weak var value: AnyObject?
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
init(_ value: AnyObject) {
|
|
11
11
|
self.value = value
|
|
12
12
|
}
|
|
@@ -19,7 +19,7 @@ enum ValueWrap {
|
|
|
19
19
|
|
|
20
20
|
public class MethodContext {
|
|
21
21
|
private var storage: [String: ValueWrap] = [:]
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
public func set(_ value: Any, forKey key: String, weak: Bool = false) {
|
|
24
24
|
if weak, let obj = value as? AnyObject {
|
|
25
25
|
storage[key] = .weak(WeakWrap(obj))
|
|
@@ -27,7 +27,7 @@ public class MethodContext {
|
|
|
27
27
|
storage[key] = .strong(value)
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
public func get<T>(_ key: String, as type: T.Type = T.self) -> T? {
|
|
32
32
|
guard let valueWrap = storage[key] else { return nil }
|
|
33
33
|
switch valueWrap {
|
|
@@ -35,11 +35,11 @@ public class MethodContext {
|
|
|
35
35
|
case .weak(let weakWrap): return weakWrap.value as? T
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
public func removeValue(forKey key: String) {
|
|
40
40
|
storage.removeValue(forKey: key)
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
public subscript<T>(key: String) -> T? {
|
|
44
44
|
get { get(key, as: T.self) }
|
|
45
45
|
set {
|
|
@@ -30,97 +30,97 @@ import Foundation
|
|
|
30
30
|
@objc public class MethodStatus: NSObject {
|
|
31
31
|
@objc public let code: MethodStatusCode
|
|
32
32
|
@objc public let message: String?
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Convenience constructor
|
|
35
35
|
@objc public init(code: MethodStatusCode, message: String? = nil) {
|
|
36
36
|
self.code = code
|
|
37
37
|
self.message = message
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
// Convenience factory method
|
|
41
41
|
@objc public static func succeeded() -> MethodStatus {
|
|
42
42
|
return MethodStatus(code: .succeeded)
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
@objc public static func failed(message: String? = nil) -> MethodStatus {
|
|
46
46
|
return MethodStatus(code: .failed, message: message)
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
@objc public static func invalidParameter(message: String? = nil) -> MethodStatus {
|
|
50
50
|
return MethodStatus(code: .invalidInputParameter, message: message)
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
@objc public static func notImplemented(message: String? = nil) -> MethodStatus {
|
|
54
54
|
return MethodStatus(code: .notImplemented, message: message)
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
// Convenience methods for other common statuses
|
|
58
58
|
@objc public static func unregisteredMethod(message: String? = nil) -> MethodStatus {
|
|
59
59
|
return MethodStatus(code: .unregisteredMethod, message: message)
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
@objc public static func invalidNamespace(message: String? = nil) -> MethodStatus {
|
|
63
63
|
return MethodStatus(code: .invalidNamespace, message: message)
|
|
64
64
|
}
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
@objc public static func invalidResult(message: String? = nil) -> MethodStatus {
|
|
67
67
|
return MethodStatus(code: .invalidResult, message: message)
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
|
|
70
70
|
@objc public static func unauthorizedAccess(message: String? = nil) -> MethodStatus {
|
|
71
71
|
return MethodStatus(code: .unauthorizedAccess, message: message)
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
|
|
74
74
|
@objc public static func operationCancelled(message: String? = nil) -> MethodStatus {
|
|
75
75
|
return MethodStatus(code: .operationCancelled, message: message)
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
@objc public static func operationTimeout(message: String? = nil) -> MethodStatus {
|
|
79
79
|
return MethodStatus(code: .operationTimeout, message: message)
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
@objc public static func notFound(message: String? = nil) -> MethodStatus {
|
|
83
83
|
return MethodStatus(code: .notFound, message: message)
|
|
84
84
|
}
|
|
85
|
-
|
|
85
|
+
|
|
86
86
|
@objc public static func alreadyExists(message: String? = nil) -> MethodStatus {
|
|
87
87
|
return MethodStatus(code: .alreadyExists, message: message)
|
|
88
88
|
}
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
@objc public static func paramModelTypeWrong(message: String? = nil) -> MethodStatus {
|
|
91
91
|
return MethodStatus(code: .paramModelTypeWrong, message: message)
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
@objc public static func resultModelTypeWrong(message: String? = nil) -> MethodStatus {
|
|
95
95
|
return MethodStatus(code: .resultModelTypeWrong, message: message)
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
@objc public static func unknown(message: String? = nil) -> MethodStatus {
|
|
99
99
|
return MethodStatus(code: .unknown, message: message)
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
|
|
102
102
|
@objc public static func networkUnreachable(message: String? = nil) -> MethodStatus {
|
|
103
103
|
return MethodStatus(code: .networkUnreachable, message: message)
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
|
|
106
106
|
@objc public static func networkTimeout(message: String? = nil) -> MethodStatus {
|
|
107
107
|
return MethodStatus(code: .networkTimeout, message: message)
|
|
108
108
|
}
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
@objc public static func malformedResponse(message: String? = nil) -> MethodStatus {
|
|
111
111
|
return MethodStatus(code: .malformedResponse, message: message)
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
|
|
114
114
|
// For compatibility with original Int type code access
|
|
115
115
|
@objc public var rawCode: Int {
|
|
116
116
|
return code.rawValue
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
|
|
119
119
|
// Whether it's successful
|
|
120
120
|
@objc public var isSuccess: Bool {
|
|
121
121
|
return code == .succeeded
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
|
|
124
124
|
// Already have instance variable message, no need for duplicate computed property
|
|
125
125
|
}
|
|
126
126
|
|
|
@@ -129,11 +129,11 @@ extension MethodStatus {
|
|
|
129
129
|
let msg = self.message ?? ""
|
|
130
130
|
return "<MethodStatus - code: \(self.code), message: \"\(msg)\">"
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
|
|
133
133
|
public static func == (lhs: MethodStatus, rhs: MethodStatus) -> Bool {
|
|
134
134
|
return lhs.code == rhs.code
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
|
|
137
137
|
public static func === (lhs: MethodStatus, rhs: MethodStatus) -> Bool {
|
|
138
138
|
return lhs.code == rhs.code && lhs.message == rhs.message
|
|
139
139
|
}
|
|
@@ -4,13 +4,72 @@
|
|
|
4
4
|
|
|
5
5
|
import Foundation
|
|
6
6
|
|
|
7
|
+
private enum MethodInvocationPayloadKeys {
|
|
8
|
+
static let code = "code"
|
|
9
|
+
static let data = "data"
|
|
10
|
+
static let message = "message"
|
|
11
|
+
static let msg = "msg"
|
|
12
|
+
static let containerID = "containerID"
|
|
13
|
+
static let protocolVersion = "protocolVersion"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private func methodInvocationStatusCode(_ status: MethodStatus) -> Int {
|
|
17
|
+
status.code == .notFound ? MethodStatusCode.unregisteredMethod.rawValue : status.rawCode
|
|
18
|
+
}
|
|
19
|
+
|
|
7
20
|
extension MethodPipe {
|
|
8
21
|
func executeMethod(methodName: String, params: [String: Any]?, thread: MethodThread = .mainThread, completion: CommonPipeCompletion?) {
|
|
22
|
+
let invocationId = UUID().uuidString
|
|
23
|
+
let invocationStart = Date()
|
|
24
|
+
let invocationCenter = SparklingMethodInvocationCenter.shared
|
|
25
|
+
let invocationNamespace: String? = "method-pipe"
|
|
26
|
+
let callbackPayload: (MethodStatus, [String: Any]?) -> [String: Any] = { status, data in
|
|
27
|
+
var payload: [String: Any] = [
|
|
28
|
+
MethodInvocationPayloadKeys.code: methodInvocationStatusCode(status),
|
|
29
|
+
MethodInvocationPayloadKeys.data: data ?? NSNull(),
|
|
30
|
+
MethodInvocationPayloadKeys.protocolVersion: "1.1.0",
|
|
31
|
+
]
|
|
32
|
+
payload[MethodInvocationPayloadKeys.msg] = status.message ?? NSNull()
|
|
33
|
+
if let containerID = params?[MethodInvocationPayloadKeys.containerID] as? String {
|
|
34
|
+
payload[MethodInvocationPayloadKeys.containerID] = containerID
|
|
35
|
+
}
|
|
36
|
+
return payload
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
invocationCenter.notifyStart(
|
|
40
|
+
SparklingMethodInvocationEvent(
|
|
41
|
+
id: invocationId,
|
|
42
|
+
name: methodName,
|
|
43
|
+
namespace: invocationNamespace,
|
|
44
|
+
platform: "core",
|
|
45
|
+
params: params,
|
|
46
|
+
result: nil,
|
|
47
|
+
statusCode: nil,
|
|
48
|
+
statusMessage: nil,
|
|
49
|
+
startTime: invocationStart,
|
|
50
|
+
endTime: nil
|
|
51
|
+
)
|
|
52
|
+
)
|
|
53
|
+
|
|
9
54
|
guard let method = self.method(forName: methodName) else {
|
|
10
|
-
|
|
55
|
+
let status = MethodStatus.notFound()
|
|
56
|
+
let notFound = SparklingMethodInvocationEvent(
|
|
57
|
+
id: invocationId,
|
|
58
|
+
name: methodName,
|
|
59
|
+
namespace: invocationNamespace,
|
|
60
|
+
platform: "core",
|
|
61
|
+
params: params,
|
|
62
|
+
result: callbackPayload(status, nil),
|
|
63
|
+
statusCode: methodInvocationStatusCode(status),
|
|
64
|
+
statusMessage: status.message ?? "notFound",
|
|
65
|
+
startTime: invocationStart,
|
|
66
|
+
endTime: Date()
|
|
67
|
+
)
|
|
68
|
+
invocationCenter.notifyEnd(notFound)
|
|
69
|
+
completion?(status, nil)
|
|
11
70
|
return
|
|
12
71
|
}
|
|
13
|
-
|
|
72
|
+
|
|
14
73
|
let resultModelType = method.resultModelClass
|
|
15
74
|
let resultBlk: PipeMethod.CompletionBlock = { status, result in
|
|
16
75
|
if let result = result, type(of: result) != EmptyMethodModel.self {
|
|
@@ -20,7 +79,7 @@ extension MethodPipe {
|
|
|
20
79
|
return
|
|
21
80
|
}
|
|
22
81
|
}
|
|
23
|
-
|
|
82
|
+
|
|
24
83
|
var fStatus = status
|
|
25
84
|
var resultDict: [String: Any] = [:]
|
|
26
85
|
do {
|
|
@@ -30,27 +89,67 @@ extension MethodPipe {
|
|
|
30
89
|
} catch {
|
|
31
90
|
fStatus = .invalidResult(message: error.localizedDescription)
|
|
32
91
|
}
|
|
33
|
-
|
|
92
|
+
|
|
34
93
|
resultDict[DictKeys.statusMessage] = fStatus.message
|
|
94
|
+
let callbackResult = callbackPayload(fStatus, resultDict)
|
|
95
|
+
|
|
96
|
+
invocationCenter.notifyEnd(
|
|
97
|
+
SparklingMethodInvocationEvent(
|
|
98
|
+
id: invocationId,
|
|
99
|
+
name: methodName,
|
|
100
|
+
namespace: invocationNamespace,
|
|
101
|
+
platform: "core",
|
|
102
|
+
params: params,
|
|
103
|
+
result: callbackResult,
|
|
104
|
+
statusCode: methodInvocationStatusCode(fStatus),
|
|
105
|
+
statusMessage: fStatus.message,
|
|
106
|
+
startTime: invocationStart,
|
|
107
|
+
endTime: Date()
|
|
108
|
+
)
|
|
109
|
+
)
|
|
110
|
+
|
|
35
111
|
completion?(fStatus, resultDict)
|
|
36
112
|
}
|
|
113
|
+
|
|
114
|
+
// Notify observers of an early-out failure (mirrors `resultBlk`).
|
|
115
|
+
let notifyEarlyFailure: (String) -> Void = { message in
|
|
116
|
+
let status = MethodStatus.invalidParameter(message: message)
|
|
117
|
+
invocationCenter.notifyEnd(
|
|
118
|
+
SparklingMethodInvocationEvent(
|
|
119
|
+
id: invocationId,
|
|
120
|
+
name: methodName,
|
|
121
|
+
namespace: invocationNamespace,
|
|
122
|
+
platform: "core",
|
|
123
|
+
params: params,
|
|
124
|
+
result: callbackPayload(status, [MethodInvocationPayloadKeys.message: message]),
|
|
125
|
+
statusCode: methodInvocationStatusCode(status),
|
|
126
|
+
statusMessage: message,
|
|
127
|
+
startTime: invocationStart,
|
|
128
|
+
endTime: Date()
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
37
133
|
let paramsModelType = method.paramsModelClass
|
|
38
134
|
guard var params = params else {
|
|
135
|
+
notifyEarlyFailure("Pipe inner error: empty params")
|
|
39
136
|
completion?(.invalidParameter(message: "Pipe inner error: empty params"), nil)
|
|
40
137
|
return
|
|
41
138
|
}
|
|
42
|
-
|
|
139
|
+
|
|
43
140
|
// Safely get requiredKeyPaths
|
|
44
|
-
if let methodModelType = paramsModelType as? MethodModel.Type,
|
|
45
|
-
|
|
141
|
+
if let methodModelType = paramsModelType as? MethodModel.Type,
|
|
142
|
+
let requiredKeyPaths = methodModelType.requiredKeyPaths
|
|
143
|
+
{
|
|
46
144
|
let paramsKeys: Set<String> = Set(params.keys)
|
|
47
145
|
let missingKeys = requiredKeyPaths.subtracting(paramsKeys).sorted().joined(separator: ", ")
|
|
48
146
|
if missingKeys.count > 0 {
|
|
147
|
+
notifyEarlyFailure("Missing required parameter(s): \(missingKeys)")
|
|
49
148
|
completion?(.invalidParameter(message: "Missing required parameter(s): \(missingKeys)"), nil)
|
|
50
149
|
return
|
|
51
150
|
}
|
|
52
151
|
}
|
|
53
|
-
|
|
152
|
+
|
|
54
153
|
var paramModel: MethodModel?
|
|
55
154
|
do {
|
|
56
155
|
if let methodModelType = paramsModelType as? MethodModel.Type {
|
|
@@ -59,10 +158,12 @@ extension MethodPipe {
|
|
|
59
158
|
throw NSError(domain: "MethodPipe", code: -1, userInfo: [NSLocalizedDescriptionKey: "Invalid params model type: \(paramsModelType)"])
|
|
60
159
|
}
|
|
61
160
|
} catch {
|
|
161
|
+
notifyEarlyFailure(error.localizedDescription)
|
|
62
162
|
completion?(.invalidParameter(message: error.localizedDescription), nil)
|
|
63
163
|
return
|
|
64
164
|
}
|
|
65
165
|
guard var paramModel = paramModel else {
|
|
166
|
+
notifyEarlyFailure("Param model conversion failed")
|
|
66
167
|
completion?(.invalidParameter(message: "Param model conversion failed: \(type(of: paramsModelType)) from dict: \(params)"), nil)
|
|
67
168
|
return
|
|
68
169
|
}
|
|
@@ -71,7 +172,7 @@ extension MethodPipe {
|
|
|
71
172
|
context.pipeContainer = self.engine?.pipeContainer
|
|
72
173
|
return context
|
|
73
174
|
}()
|
|
74
|
-
|
|
175
|
+
|
|
75
176
|
let invokeBlk: () -> Void = {
|
|
76
177
|
method.invokeErased(withParams: paramModel, completion: resultBlk)
|
|
77
178
|
}
|
|
@@ -7,38 +7,38 @@ import Foundation
|
|
|
7
7
|
public class MethodPipe: MethodPipeFacade {
|
|
8
8
|
var engine: PipeEngine?
|
|
9
9
|
public private(set) lazy var registry = MethodRegistry()
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
public func register(localMethod method: PipeMethod) {
|
|
12
12
|
registry.register(method: method)
|
|
13
13
|
}
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
public func register(localMethods methods: [PipeMethod]) {
|
|
16
16
|
registry.register(methods: methods)
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
public func register(globalMethod method: PipeMethod) {
|
|
20
20
|
MethodRegistry.global.register(method: method)
|
|
21
21
|
}
|
|
22
22
|
public func unregister(localMethodName name: String) {
|
|
23
23
|
registry.unregister(methodName: name)
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
|
|
26
26
|
public func unregister(globalMethodName name: String) {
|
|
27
27
|
MethodRegistry.global.unregister(methodName: name)
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
public func respondTo(methodName name: String) -> Bool {
|
|
31
31
|
return registry.respondTo(methodName: name) || MethodRegistry.global.respondTo(methodName: name)
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
public func method(forName name: String) -> PipeMethod? {
|
|
35
35
|
return registry.method(forName: name) ?? MethodRegistry.global.method(forName: name)
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
|
|
38
38
|
public func method<T: PipeMethod>(forName name: String) -> T? {
|
|
39
39
|
return method(forName: name) as? T
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
public func fireEvent(name: String, params: [String: Any]?) {
|
|
43
43
|
engine?.fireEvent(name: name, params: params)
|
|
44
44
|
}
|
|
@@ -7,37 +7,37 @@ import ObjectiveC.runtime
|
|
|
7
7
|
|
|
8
8
|
public final class MethodRegistry {
|
|
9
9
|
public static let global = MethodRegistry()
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
private var methodTypeMap: [String: PipeMethod.Type] = [:]
|
|
12
12
|
private var methodMap: [String: PipeMethod] = [:]
|
|
13
13
|
private var lock = ReadWriteLock()
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
init() {}
|
|
16
|
-
|
|
16
|
+
|
|
17
17
|
public func register(methodType: PipeMethod.Type) {
|
|
18
18
|
lock.write {
|
|
19
19
|
methodTypeMap[methodType.methodName()] = methodType
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
public func register(method: PipeMethod) {
|
|
24
24
|
let methodName = type(of: method).methodName()
|
|
25
25
|
lock.write {
|
|
26
26
|
methodMap[methodName] = method
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
public func register(methods: [PipeMethod]) {
|
|
31
|
-
if
|
|
31
|
+
if methods.isEmpty { return }
|
|
32
32
|
lock.write {
|
|
33
33
|
for method in methods {
|
|
34
34
|
methodMap[type(of: method).methodName()] = method
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
public func register(methodTypes: [PipeMethod.Type]) {
|
|
40
|
-
if
|
|
40
|
+
if methodTypes.isEmpty { return }
|
|
41
41
|
let validMap: [String: PipeMethod.Type] = methodTypes.reduce(into: [String: PipeMethod.Type]()) { result, type in
|
|
42
42
|
result[type.methodName()] = type
|
|
43
43
|
}
|
|
@@ -45,47 +45,48 @@ public final class MethodRegistry {
|
|
|
45
45
|
methodTypeMap.merge(validMap) { (_, new) in new }
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
public func unregister(methodName name: String) {
|
|
50
50
|
lock.write {
|
|
51
51
|
methodMap[name] = nil
|
|
52
52
|
methodTypeMap[name] = nil
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
public func respondTo(methodName name: String) -> Bool {
|
|
57
57
|
return lock.read {
|
|
58
58
|
methodMap[name] != nil || methodTypeMap[name] != nil
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
public func method(forName name: String) -> PipeMethod? {
|
|
63
|
-
return lock.read { methodMap[name] }
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
return lock.read { methodMap[name] }
|
|
64
|
+
?? lock.write {
|
|
65
|
+
if let method = methodMap[name] {
|
|
66
|
+
return method
|
|
67
|
+
}
|
|
68
|
+
guard let methodType = methodTypeMap[name] else {
|
|
69
|
+
return nil
|
|
70
|
+
}
|
|
71
|
+
let newMethod = methodType.init()
|
|
72
|
+
methodMap[name] = newMethod
|
|
73
|
+
return newMethod
|
|
66
74
|
}
|
|
67
|
-
guard let methodType = methodTypeMap[name] else {
|
|
68
|
-
return nil
|
|
69
|
-
}
|
|
70
|
-
let newMethod = methodType.init()
|
|
71
|
-
methodMap[name] = newMethod
|
|
72
|
-
return newMethod
|
|
73
|
-
}
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
+
|
|
76
77
|
public func method<T: PipeMethod>(forName name: String) -> T? {
|
|
77
78
|
return method(forName: name) as? T
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
+
|
|
80
81
|
public static func autoRegisterGlobalMethods() {
|
|
81
82
|
var count: UInt32 = 0
|
|
82
83
|
let classList = objc_copyClassList(&count)!
|
|
83
84
|
defer {
|
|
84
85
|
free(UnsafeMutableRawPointer(classList))
|
|
85
86
|
}
|
|
86
|
-
|
|
87
|
+
|
|
87
88
|
let classes = UnsafeBufferPointer(start: classList, count: Int(count))
|
|
88
|
-
var methodTypes:[PipeMethod.Type] = []
|
|
89
|
+
var methodTypes: [PipeMethod.Type] = []
|
|
89
90
|
for i in 0..<Int(count) {
|
|
90
91
|
let cls: AnyClass = classes[i]
|
|
91
92
|
if class_getSuperclass(cls) == PipeMethod.self, let type = cls as? PipeMethod.Type {
|