@npaw/forge-react-native 9.7.1 → 9.7.3
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/android/build.gradle +1 -1
- package/android/src/main/java/com/npaw/forge/reactnative/ForgeDtoMapper.java +10 -0
- package/android/src/main/java/com/npaw/forge/reactnative/ForgeInstanceRegistry.java +59 -1
- package/android/src/main/java/com/npaw/forge/reactnative/NPAWForgeModule.java +33 -0
- package/android/src/test/java/com/npaw/forge/reactnative/ForgeInstanceRegistryTest.java +65 -0
- package/app.plugin.js +17 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/Info.plist +8 -8
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/ios-arm64/Headers/forge_kernelFFI.h +71 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/ios-arm64/libForgeKernelFFI.a +0 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/ios-arm64_x86_64-simulator/Headers/forge_kernelFFI.h +71 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/ios-arm64_x86_64-simulator/libForgeKernelFFI.a +0 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/tvos-arm64/Headers/forge_kernelFFI.h +71 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/tvos-arm64/libForgeKernelFFI.a +0 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/tvos-arm64-simulator/Headers/forge_kernelFFI.h +71 -0
- package/ios/ForgeApple/ForgeKernelFFI.xcframework/tvos-arm64-simulator/libForgeKernelFFI.a +0 -0
- package/ios/ForgeApple/Sources/ForgeKernelUniFFI/forge_kernel.swift +198 -1
- package/ios/ForgeApple/Sources/ForgeKernelUniFFI/forge_kernelFFI.h +71 -0
- package/ios/ForgeApple/Sources/NPAWForgeAVPlayerAdapter/AVPlayerAdapter.swift +12 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/ConnectionType.swift +125 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/ForgeApple.swift +67 -1
- package/ios/ForgeApple/Sources/NPAWForgeCore/ForgeCapturePlan.swift +4 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/ForgeLogging.swift +80 -3
- package/ios/ForgeApple/Sources/NPAWForgeCore/ForgeRuntime.swift +44 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/LocationObserver.swift +183 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/NPAWForge.swift +123 -2
- package/ios/ForgeApple/Sources/NPAWForgeCore/NativeUniFFIRuntime.swift +59 -0
- package/ios/ForgeApple/Sources/NPAWForgeCore/PlayerAdapter.swift +17 -1
- package/ios/ForgeInstanceRegistry.swift +69 -0
- package/ios/ForgeModuleImpl.swift +53 -6
- package/ios/NPAWForgeTurboModule.mm +6 -1
- package/package.json +3 -1
- package/plugin/index.js +82 -0
- package/plugin/mutations.js +140 -0
- package/src/NPAWForge.ts +12 -1
- package/src/events.ts +21 -1
- package/src/index.ts +11 -1
- package/src/sections.ts +292 -0
- package/src/types.ts +23 -2
|
@@ -589,6 +589,8 @@ public protocol ForgeRuntimeBridgeProtocol: AnyObject, Sendable {
|
|
|
589
589
|
|
|
590
590
|
func clearContentMetadataProvider(viewId: UInt64) -> AppleBindingOutcome
|
|
591
591
|
|
|
592
|
+
func clearLogListener() -> AppleBindingOutcome
|
|
593
|
+
|
|
592
594
|
func clearSessionPreSendHook() -> AppleBindingOutcome
|
|
593
595
|
|
|
594
596
|
func clearVideoPreSendHook(viewId: UInt64) -> AppleBindingOutcome
|
|
@@ -603,18 +605,24 @@ public protocol ForgeRuntimeBridgeProtocol: AnyObject, Sendable {
|
|
|
603
605
|
|
|
604
606
|
func recordIdentityEvent(kind: String, timemarkMs: UInt64, fields: [String: String]) -> AppleBindingOutcome
|
|
605
607
|
|
|
608
|
+
func recordLocationFix(latitude: Double, longitude: Double, accuracyM: Double, timestampMs: UInt64) -> AppleBindingOutcome
|
|
609
|
+
|
|
606
610
|
func recordNetworkEvent(observation: AppleNetworkObservation) -> AppleBindingOutcome
|
|
607
611
|
|
|
608
612
|
func recordPlayerEvent(viewId: UInt64, event: AppleVideoEvent, timestamp: AppleSemanticTimestamp, overridesJson: String, metadata: AppleContentMetadata) -> AppleBindingOutcome
|
|
609
613
|
|
|
610
614
|
func recordSessionEvent(eventName: String, timemarkMs: UInt64, params: [String: String]) -> AppleBindingOutcome
|
|
611
615
|
|
|
616
|
+
func setAutoConnectionType(connectionType: String?) -> AppleBindingOutcome
|
|
617
|
+
|
|
612
618
|
func setCapturePlanListener(listener: AppleCapturePlanListener) -> AppleBindingOutcome
|
|
613
619
|
|
|
614
620
|
func setContentMetadataProvider(viewId: UInt64, provider: AppleContentMetadataProvider) -> AppleBindingOutcome
|
|
615
621
|
|
|
616
622
|
func setLogLevel(logLevel: String) -> AppleBindingOutcome
|
|
617
623
|
|
|
624
|
+
func setLogListener(listener: AppleLogListener) -> AppleBindingOutcome
|
|
625
|
+
|
|
618
626
|
func setSessionPreSendHook(hook: AppleSessionPreSendHook) -> AppleBindingOutcome
|
|
619
627
|
|
|
620
628
|
func setVideoPreSendHook(viewId: UInt64, hook: AppleVideoPreSendHook) -> AppleBindingOutcome
|
|
@@ -710,6 +718,14 @@ open func clearContentMetadataProvider(viewId: UInt64) -> AppleBindingOutcome {
|
|
|
710
718
|
})
|
|
711
719
|
}
|
|
712
720
|
|
|
721
|
+
open func clearLogListener() -> AppleBindingOutcome {
|
|
722
|
+
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
723
|
+
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_log_listener(
|
|
724
|
+
self.uniffiCloneHandle(),$0
|
|
725
|
+
)
|
|
726
|
+
})
|
|
727
|
+
}
|
|
728
|
+
|
|
713
729
|
open func clearSessionPreSendHook() -> AppleBindingOutcome {
|
|
714
730
|
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
715
731
|
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_session_pre_send_hook(
|
|
@@ -780,6 +796,18 @@ open func recordIdentityEvent(kind: String, timemarkMs: UInt64, fields: [String:
|
|
|
780
796
|
})
|
|
781
797
|
}
|
|
782
798
|
|
|
799
|
+
open func recordLocationFix(latitude: Double, longitude: Double, accuracyM: Double, timestampMs: UInt64) -> AppleBindingOutcome {
|
|
800
|
+
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
801
|
+
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_location_fix(
|
|
802
|
+
self.uniffiCloneHandle(),
|
|
803
|
+
FfiConverterDouble.lower(latitude),
|
|
804
|
+
FfiConverterDouble.lower(longitude),
|
|
805
|
+
FfiConverterDouble.lower(accuracyM),
|
|
806
|
+
FfiConverterUInt64.lower(timestampMs),$0
|
|
807
|
+
)
|
|
808
|
+
})
|
|
809
|
+
}
|
|
810
|
+
|
|
783
811
|
open func recordNetworkEvent(observation: AppleNetworkObservation) -> AppleBindingOutcome {
|
|
784
812
|
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
785
813
|
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_network_event(
|
|
@@ -813,6 +841,15 @@ open func recordSessionEvent(eventName: String, timemarkMs: UInt64, params: [Str
|
|
|
813
841
|
})
|
|
814
842
|
}
|
|
815
843
|
|
|
844
|
+
open func setAutoConnectionType(connectionType: String?) -> AppleBindingOutcome {
|
|
845
|
+
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
846
|
+
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_auto_connection_type(
|
|
847
|
+
self.uniffiCloneHandle(),
|
|
848
|
+
FfiConverterOptionString.lower(connectionType),$0
|
|
849
|
+
)
|
|
850
|
+
})
|
|
851
|
+
}
|
|
852
|
+
|
|
816
853
|
open func setCapturePlanListener(listener: AppleCapturePlanListener) -> AppleBindingOutcome {
|
|
817
854
|
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
818
855
|
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_capture_plan_listener(
|
|
@@ -841,6 +878,15 @@ open func setLogLevel(logLevel: String) -> AppleBindingOutcome {
|
|
|
841
878
|
})
|
|
842
879
|
}
|
|
843
880
|
|
|
881
|
+
open func setLogListener(listener: AppleLogListener) -> AppleBindingOutcome {
|
|
882
|
+
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
883
|
+
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_log_listener(
|
|
884
|
+
self.uniffiCloneHandle(),
|
|
885
|
+
FfiConverterCallbackInterfaceAppleLogListener_lower(listener),$0
|
|
886
|
+
)
|
|
887
|
+
})
|
|
888
|
+
}
|
|
889
|
+
|
|
844
890
|
open func setSessionPreSendHook(hook: AppleSessionPreSendHook) -> AppleBindingOutcome {
|
|
845
891
|
return try! FfiConverterTypeAppleBindingOutcome_lift(try! rustCall() {
|
|
846
892
|
uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_session_pre_send_hook(
|
|
@@ -1893,11 +1939,12 @@ public struct AppleRuntimeConfig: Equatable, Hashable {
|
|
|
1893
1939
|
public var logLevel: String
|
|
1894
1940
|
public var deviceUuid: String?
|
|
1895
1941
|
public var deviceInfoJson: String?
|
|
1942
|
+
public var framework: String?
|
|
1896
1943
|
public var preSessionEventPolicy: ApplePreSessionEventPolicy
|
|
1897
1944
|
|
|
1898
1945
|
// Default memberwise initializers are never public by default, so we
|
|
1899
1946
|
// declare one manually.
|
|
1900
|
-
public init(accountCode: String, pluginVersion: String, appName: String, buildVariant: String, appReleaseVersion: String?, lmaEndpoint: String, analyticsUserAgent: String?, allowLocalHttp: Bool, logLevel: String, deviceUuid: String?, deviceInfoJson: String?, preSessionEventPolicy: ApplePreSessionEventPolicy) {
|
|
1947
|
+
public init(accountCode: String, pluginVersion: String, appName: String, buildVariant: String, appReleaseVersion: String?, lmaEndpoint: String, analyticsUserAgent: String?, allowLocalHttp: Bool, logLevel: String, deviceUuid: String?, deviceInfoJson: String?, framework: String?, preSessionEventPolicy: ApplePreSessionEventPolicy) {
|
|
1901
1948
|
self.accountCode = accountCode
|
|
1902
1949
|
self.pluginVersion = pluginVersion
|
|
1903
1950
|
self.appName = appName
|
|
@@ -1909,6 +1956,7 @@ public struct AppleRuntimeConfig: Equatable, Hashable {
|
|
|
1909
1956
|
self.logLevel = logLevel
|
|
1910
1957
|
self.deviceUuid = deviceUuid
|
|
1911
1958
|
self.deviceInfoJson = deviceInfoJson
|
|
1959
|
+
self.framework = framework
|
|
1912
1960
|
self.preSessionEventPolicy = preSessionEventPolicy
|
|
1913
1961
|
}
|
|
1914
1962
|
|
|
@@ -1939,6 +1987,7 @@ public struct FfiConverterTypeAppleRuntimeConfig: FfiConverterRustBuffer {
|
|
|
1939
1987
|
logLevel: FfiConverterString.read(from: &buf),
|
|
1940
1988
|
deviceUuid: FfiConverterOptionString.read(from: &buf),
|
|
1941
1989
|
deviceInfoJson: FfiConverterOptionString.read(from: &buf),
|
|
1990
|
+
framework: FfiConverterOptionString.read(from: &buf),
|
|
1942
1991
|
preSessionEventPolicy: FfiConverterTypeApplePreSessionEventPolicy.read(from: &buf)
|
|
1943
1992
|
)
|
|
1944
1993
|
}
|
|
@@ -1955,6 +2004,7 @@ public struct FfiConverterTypeAppleRuntimeConfig: FfiConverterRustBuffer {
|
|
|
1955
2004
|
FfiConverterString.write(value.logLevel, into: &buf)
|
|
1956
2005
|
FfiConverterOptionString.write(value.deviceUuid, into: &buf)
|
|
1957
2006
|
FfiConverterOptionString.write(value.deviceInfoJson, into: &buf)
|
|
2007
|
+
FfiConverterOptionString.write(value.framework, into: &buf)
|
|
1958
2008
|
FfiConverterTypeApplePreSessionEventPolicy.write(value.preSessionEventPolicy, into: &buf)
|
|
1959
2009
|
}
|
|
1960
2010
|
}
|
|
@@ -3111,6 +3161,137 @@ public func FfiConverterCallbackInterfaceAppleContentMetadataProvider_lower(_ v:
|
|
|
3111
3161
|
|
|
3112
3162
|
|
|
3113
3163
|
|
|
3164
|
+
public protocol AppleLogListener: AnyObject, Sendable {
|
|
3165
|
+
|
|
3166
|
+
func onLog(log: AppleRenderedLog)
|
|
3167
|
+
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
// Put the implementation in a struct so we don't pollute the top-level namespace
|
|
3172
|
+
fileprivate struct UniffiCallbackInterfaceAppleLogListener {
|
|
3173
|
+
|
|
3174
|
+
// Create the VTable using a series of closures.
|
|
3175
|
+
// Swift automatically converts these into C callback functions.
|
|
3176
|
+
//
|
|
3177
|
+
// Store the vtable directly.
|
|
3178
|
+
static let vtable: UniffiVTableCallbackInterfaceAppleLogListener = UniffiVTableCallbackInterfaceAppleLogListener(
|
|
3179
|
+
uniffiFree: { (uniffiHandle: UInt64) -> () in
|
|
3180
|
+
do {
|
|
3181
|
+
try FfiConverterCallbackInterfaceAppleLogListener.handleMap.remove(handle: uniffiHandle)
|
|
3182
|
+
} catch {
|
|
3183
|
+
print("Uniffi callback interface AppleLogListener: handle missing in uniffiFree")
|
|
3184
|
+
}
|
|
3185
|
+
},
|
|
3186
|
+
uniffiClone: { (uniffiHandle: UInt64) -> UInt64 in
|
|
3187
|
+
do {
|
|
3188
|
+
return try FfiConverterCallbackInterfaceAppleLogListener.handleMap.clone(handle: uniffiHandle)
|
|
3189
|
+
} catch {
|
|
3190
|
+
fatalError("Uniffi callback interface AppleLogListener: handle missing in uniffiClone")
|
|
3191
|
+
}
|
|
3192
|
+
},
|
|
3193
|
+
onLog: { (
|
|
3194
|
+
uniffiHandle: UInt64,
|
|
3195
|
+
log: RustBuffer,
|
|
3196
|
+
uniffiOutReturn: UnsafeMutableRawPointer,
|
|
3197
|
+
uniffiCallStatus: UnsafeMutablePointer<RustCallStatus>
|
|
3198
|
+
) in
|
|
3199
|
+
let makeCall = {
|
|
3200
|
+
() throws -> () in
|
|
3201
|
+
guard let uniffiObj = try? FfiConverterCallbackInterfaceAppleLogListener.handleMap.get(handle: uniffiHandle) else {
|
|
3202
|
+
throw UniffiInternalError.unexpectedStaleHandle
|
|
3203
|
+
}
|
|
3204
|
+
return uniffiObj.onLog(
|
|
3205
|
+
log: try FfiConverterTypeAppleRenderedLog_lift(log)
|
|
3206
|
+
)
|
|
3207
|
+
}
|
|
3208
|
+
|
|
3209
|
+
|
|
3210
|
+
let writeReturn = { () }
|
|
3211
|
+
uniffiTraitInterfaceCall(
|
|
3212
|
+
callStatus: uniffiCallStatus,
|
|
3213
|
+
makeCall: makeCall,
|
|
3214
|
+
writeReturn: writeReturn
|
|
3215
|
+
)
|
|
3216
|
+
}
|
|
3217
|
+
)
|
|
3218
|
+
|
|
3219
|
+
// Rust stores this pointer for future callback invocations, so it must live
|
|
3220
|
+
// for the process lifetime (not just for the init function call).
|
|
3221
|
+
static let vtablePtr: UnsafePointer<UniffiVTableCallbackInterfaceAppleLogListener> = {
|
|
3222
|
+
let ptr = UnsafeMutablePointer<UniffiVTableCallbackInterfaceAppleLogListener>.allocate(capacity: 1)
|
|
3223
|
+
ptr.initialize(to: vtable)
|
|
3224
|
+
return UnsafePointer(ptr)
|
|
3225
|
+
}()
|
|
3226
|
+
}
|
|
3227
|
+
|
|
3228
|
+
private func uniffiCallbackInitAppleLogListener() {
|
|
3229
|
+
uniffi_forge_kernel_uniffi_fn_init_callback_vtable_appleloglistener(UniffiCallbackInterfaceAppleLogListener.vtablePtr)
|
|
3230
|
+
}
|
|
3231
|
+
|
|
3232
|
+
// FfiConverter protocol for callback interfaces
|
|
3233
|
+
#if swift(>=5.8)
|
|
3234
|
+
@_documentation(visibility: private)
|
|
3235
|
+
#endif
|
|
3236
|
+
fileprivate struct FfiConverterCallbackInterfaceAppleLogListener {
|
|
3237
|
+
fileprivate static let handleMap = UniffiHandleMap<AppleLogListener>()
|
|
3238
|
+
}
|
|
3239
|
+
|
|
3240
|
+
#if swift(>=5.8)
|
|
3241
|
+
@_documentation(visibility: private)
|
|
3242
|
+
#endif
|
|
3243
|
+
extension FfiConverterCallbackInterfaceAppleLogListener : FfiConverter {
|
|
3244
|
+
typealias SwiftType = AppleLogListener
|
|
3245
|
+
typealias FfiType = UInt64
|
|
3246
|
+
|
|
3247
|
+
#if swift(>=5.8)
|
|
3248
|
+
@_documentation(visibility: private)
|
|
3249
|
+
#endif
|
|
3250
|
+
public static func lift(_ handle: UInt64) throws -> SwiftType {
|
|
3251
|
+
try handleMap.get(handle: handle)
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
#if swift(>=5.8)
|
|
3255
|
+
@_documentation(visibility: private)
|
|
3256
|
+
#endif
|
|
3257
|
+
public static func read(from buf: inout (data: Data, offset: Data.Index)) throws -> SwiftType {
|
|
3258
|
+
let handle: UInt64 = try readInt(&buf)
|
|
3259
|
+
return try lift(handle)
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
#if swift(>=5.8)
|
|
3263
|
+
@_documentation(visibility: private)
|
|
3264
|
+
#endif
|
|
3265
|
+
public static func lower(_ v: SwiftType) -> UInt64 {
|
|
3266
|
+
return handleMap.insert(obj: v)
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
#if swift(>=5.8)
|
|
3270
|
+
@_documentation(visibility: private)
|
|
3271
|
+
#endif
|
|
3272
|
+
public static func write(_ v: SwiftType, into buf: inout [UInt8]) {
|
|
3273
|
+
writeInt(&buf, lower(v))
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
|
|
3277
|
+
|
|
3278
|
+
#if swift(>=5.8)
|
|
3279
|
+
@_documentation(visibility: private)
|
|
3280
|
+
#endif
|
|
3281
|
+
public func FfiConverterCallbackInterfaceAppleLogListener_lift(_ handle: UInt64) throws -> AppleLogListener {
|
|
3282
|
+
return try FfiConverterCallbackInterfaceAppleLogListener.lift(handle)
|
|
3283
|
+
}
|
|
3284
|
+
|
|
3285
|
+
#if swift(>=5.8)
|
|
3286
|
+
@_documentation(visibility: private)
|
|
3287
|
+
#endif
|
|
3288
|
+
public func FfiConverterCallbackInterfaceAppleLogListener_lower(_ v: AppleLogListener) -> UInt64 {
|
|
3289
|
+
return FfiConverterCallbackInterfaceAppleLogListener.lower(v)
|
|
3290
|
+
}
|
|
3291
|
+
|
|
3292
|
+
|
|
3293
|
+
|
|
3294
|
+
|
|
3114
3295
|
public protocol AppleSessionPreSendHook: AnyObject, Sendable {
|
|
3115
3296
|
|
|
3116
3297
|
func willSend(serviceName: String, params: [String: String]) -> [String: String]
|
|
@@ -3849,6 +4030,9 @@ private let initializationResult: InitializationResult = {
|
|
|
3849
4030
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_content_metadata_provider() != 29053) {
|
|
3850
4031
|
return InitializationResult.apiChecksumMismatch
|
|
3851
4032
|
}
|
|
4033
|
+
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_log_listener() != 33777) {
|
|
4034
|
+
return InitializationResult.apiChecksumMismatch
|
|
4035
|
+
}
|
|
3852
4036
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_session_pre_send_hook() != 25451) {
|
|
3853
4037
|
return InitializationResult.apiChecksumMismatch
|
|
3854
4038
|
}
|
|
@@ -3870,6 +4054,9 @@ private let initializationResult: InitializationResult = {
|
|
|
3870
4054
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_identity_event() != 47443) {
|
|
3871
4055
|
return InitializationResult.apiChecksumMismatch
|
|
3872
4056
|
}
|
|
4057
|
+
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_location_fix() != 44789) {
|
|
4058
|
+
return InitializationResult.apiChecksumMismatch
|
|
4059
|
+
}
|
|
3873
4060
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_network_event() != 5299) {
|
|
3874
4061
|
return InitializationResult.apiChecksumMismatch
|
|
3875
4062
|
}
|
|
@@ -3879,6 +4066,9 @@ private let initializationResult: InitializationResult = {
|
|
|
3879
4066
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_session_event() != 32672) {
|
|
3880
4067
|
return InitializationResult.apiChecksumMismatch
|
|
3881
4068
|
}
|
|
4069
|
+
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_auto_connection_type() != 38828) {
|
|
4070
|
+
return InitializationResult.apiChecksumMismatch
|
|
4071
|
+
}
|
|
3882
4072
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_capture_plan_listener() != 52103) {
|
|
3883
4073
|
return InitializationResult.apiChecksumMismatch
|
|
3884
4074
|
}
|
|
@@ -3888,6 +4078,9 @@ private let initializationResult: InitializationResult = {
|
|
|
3888
4078
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_log_level() != 1993) {
|
|
3889
4079
|
return InitializationResult.apiChecksumMismatch
|
|
3890
4080
|
}
|
|
4081
|
+
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_log_listener() != 29129) {
|
|
4082
|
+
return InitializationResult.apiChecksumMismatch
|
|
4083
|
+
}
|
|
3891
4084
|
if (uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_session_pre_send_hook() != 21614) {
|
|
3892
4085
|
return InitializationResult.apiChecksumMismatch
|
|
3893
4086
|
}
|
|
@@ -3909,6 +4102,9 @@ private let initializationResult: InitializationResult = {
|
|
|
3909
4102
|
if (uniffi_forge_kernel_uniffi_checksum_method_applecontentmetadataprovider_metadata_snapshot() != 21583) {
|
|
3910
4103
|
return InitializationResult.apiChecksumMismatch
|
|
3911
4104
|
}
|
|
4105
|
+
if (uniffi_forge_kernel_uniffi_checksum_method_appleloglistener_on_log() != 23012) {
|
|
4106
|
+
return InitializationResult.apiChecksumMismatch
|
|
4107
|
+
}
|
|
3912
4108
|
if (uniffi_forge_kernel_uniffi_checksum_method_applesessionpresendhook_will_send() != 48599) {
|
|
3913
4109
|
return InitializationResult.apiChecksumMismatch
|
|
3914
4110
|
}
|
|
@@ -3918,6 +4114,7 @@ private let initializationResult: InitializationResult = {
|
|
|
3918
4114
|
|
|
3919
4115
|
uniffiCallbackInitAppleCapturePlanListener()
|
|
3920
4116
|
uniffiCallbackInitAppleContentMetadataProvider()
|
|
4117
|
+
uniffiCallbackInitAppleLogListener()
|
|
3921
4118
|
uniffiCallbackInitAppleSessionPreSendHook()
|
|
3922
4119
|
uniffiCallbackInitAppleVideoPreSendHook()
|
|
3923
4120
|
return InitializationResult.ok
|
|
@@ -256,6 +256,13 @@ typedef void (*UniffiCallbackInterfaceAppleContentMetadataProviderMethod0)(uint6
|
|
|
256
256
|
RustCallStatus *_Nonnull uniffiCallStatus
|
|
257
257
|
);
|
|
258
258
|
|
|
259
|
+
#endif
|
|
260
|
+
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_APPLE_LOG_LISTENER_METHOD0
|
|
261
|
+
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_APPLE_LOG_LISTENER_METHOD0
|
|
262
|
+
typedef void (*UniffiCallbackInterfaceAppleLogListenerMethod0)(uint64_t, RustBuffer, void* _Nonnull,
|
|
263
|
+
RustCallStatus *_Nonnull uniffiCallStatus
|
|
264
|
+
);
|
|
265
|
+
|
|
259
266
|
#endif
|
|
260
267
|
#ifndef UNIFFI_FFIDEF_CALLBACK_INTERFACE_APPLE_SESSION_PRE_SEND_HOOK_METHOD0
|
|
261
268
|
#define UNIFFI_FFIDEF_CALLBACK_INTERFACE_APPLE_SESSION_PRE_SEND_HOOK_METHOD0
|
|
@@ -288,6 +295,15 @@ typedef struct UniffiVTableCallbackInterfaceAppleContentMetadataProvider {
|
|
|
288
295
|
UniffiCallbackInterfaceAppleContentMetadataProviderMethod0 _Nonnull metadataSnapshot;
|
|
289
296
|
} UniffiVTableCallbackInterfaceAppleContentMetadataProvider;
|
|
290
297
|
|
|
298
|
+
#endif
|
|
299
|
+
#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_APPLE_LOG_LISTENER
|
|
300
|
+
#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_APPLE_LOG_LISTENER
|
|
301
|
+
typedef struct UniffiVTableCallbackInterfaceAppleLogListener {
|
|
302
|
+
UniffiCallbackInterfaceFree _Nonnull uniffiFree;
|
|
303
|
+
UniffiCallbackInterfaceClone _Nonnull uniffiClone;
|
|
304
|
+
UniffiCallbackInterfaceAppleLogListenerMethod0 _Nonnull onLog;
|
|
305
|
+
} UniffiVTableCallbackInterfaceAppleLogListener;
|
|
306
|
+
|
|
291
307
|
#endif
|
|
292
308
|
#ifndef UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_APPLE_SESSION_PRE_SEND_HOOK
|
|
293
309
|
#define UNIFFI_FFIDEF_V_TABLE_CALLBACK_INTERFACE_APPLE_SESSION_PRE_SEND_HOOK
|
|
@@ -337,6 +353,11 @@ RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_capture
|
|
|
337
353
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_content_metadata_provider(uint64_t ptr, uint64_t view_id, RustCallStatus *_Nonnull out_status
|
|
338
354
|
);
|
|
339
355
|
#endif
|
|
356
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_CLEAR_LOG_LISTENER
|
|
357
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_CLEAR_LOG_LISTENER
|
|
358
|
+
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_log_listener(uint64_t ptr, RustCallStatus *_Nonnull out_status
|
|
359
|
+
);
|
|
360
|
+
#endif
|
|
340
361
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_CLEAR_SESSION_PRE_SEND_HOOK
|
|
341
362
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_CLEAR_SESSION_PRE_SEND_HOOK
|
|
342
363
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_clear_session_pre_send_hook(uint64_t ptr, RustCallStatus *_Nonnull out_status
|
|
@@ -372,6 +393,11 @@ RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_applic
|
|
|
372
393
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_identity_event(uint64_t ptr, RustBuffer kind, uint64_t timemark_ms, RustBuffer fields, RustCallStatus *_Nonnull out_status
|
|
373
394
|
);
|
|
374
395
|
#endif
|
|
396
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_RECORD_LOCATION_FIX
|
|
397
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_RECORD_LOCATION_FIX
|
|
398
|
+
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_location_fix(uint64_t ptr, double latitude, double longitude, double accuracy_m, uint64_t timestamp_ms, RustCallStatus *_Nonnull out_status
|
|
399
|
+
);
|
|
400
|
+
#endif
|
|
375
401
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_RECORD_NETWORK_EVENT
|
|
376
402
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_RECORD_NETWORK_EVENT
|
|
377
403
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_network_event(uint64_t ptr, RustBuffer observation, RustCallStatus *_Nonnull out_status
|
|
@@ -387,6 +413,11 @@ RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_player
|
|
|
387
413
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_record_session_event(uint64_t ptr, RustBuffer event_name, uint64_t timemark_ms, RustBuffer params, RustCallStatus *_Nonnull out_status
|
|
388
414
|
);
|
|
389
415
|
#endif
|
|
416
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_AUTO_CONNECTION_TYPE
|
|
417
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_AUTO_CONNECTION_TYPE
|
|
418
|
+
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_auto_connection_type(uint64_t ptr, RustBuffer connection_type, RustCallStatus *_Nonnull out_status
|
|
419
|
+
);
|
|
420
|
+
#endif
|
|
390
421
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_CAPTURE_PLAN_LISTENER
|
|
391
422
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_CAPTURE_PLAN_LISTENER
|
|
392
423
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_capture_plan_listener(uint64_t ptr, uint64_t listener, RustCallStatus *_Nonnull out_status
|
|
@@ -402,6 +433,11 @@ RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_content_m
|
|
|
402
433
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_log_level(uint64_t ptr, RustBuffer log_level, RustCallStatus *_Nonnull out_status
|
|
403
434
|
);
|
|
404
435
|
#endif
|
|
436
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_LOG_LISTENER
|
|
437
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_LOG_LISTENER
|
|
438
|
+
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_log_listener(uint64_t ptr, uint64_t listener, RustCallStatus *_Nonnull out_status
|
|
439
|
+
);
|
|
440
|
+
#endif
|
|
405
441
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_SESSION_PRE_SEND_HOOK
|
|
406
442
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_METHOD_FORGERUNTIMEBRIDGE_SET_SESSION_PRE_SEND_HOOK
|
|
407
443
|
RustBuffer uniffi_forge_kernel_uniffi_fn_method_forgeruntimebridge_set_session_pre_send_hook(uint64_t ptr, uint64_t hook, RustCallStatus *_Nonnull out_status
|
|
@@ -432,6 +468,11 @@ void uniffi_forge_kernel_uniffi_fn_init_callback_vtable_applecaptureplanlistener
|
|
|
432
468
|
void uniffi_forge_kernel_uniffi_fn_init_callback_vtable_applecontentmetadataprovider(const UniffiVTableCallbackInterfaceAppleContentMetadataProvider* _Nonnull vtable
|
|
433
469
|
);
|
|
434
470
|
#endif
|
|
471
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_INIT_CALLBACK_VTABLE_APPLELOGLISTENER
|
|
472
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_INIT_CALLBACK_VTABLE_APPLELOGLISTENER
|
|
473
|
+
void uniffi_forge_kernel_uniffi_fn_init_callback_vtable_appleloglistener(const UniffiVTableCallbackInterfaceAppleLogListener* _Nonnull vtable
|
|
474
|
+
);
|
|
475
|
+
#endif
|
|
435
476
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_INIT_CALLBACK_VTABLE_APPLESESSIONPRESENDHOOK
|
|
436
477
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_FN_INIT_CALLBACK_VTABLE_APPLESESSIONPRESENDHOOK
|
|
437
478
|
void uniffi_forge_kernel_uniffi_fn_init_callback_vtable_applesessionpresendhook(const UniffiVTableCallbackInterfaceAppleSessionPreSendHook* _Nonnull vtable
|
|
@@ -730,6 +771,12 @@ uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_cap
|
|
|
730
771
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_CLEAR_CONTENT_METADATA_PROVIDER
|
|
731
772
|
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_content_metadata_provider(void
|
|
732
773
|
|
|
774
|
+
);
|
|
775
|
+
#endif
|
|
776
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_CLEAR_LOG_LISTENER
|
|
777
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_CLEAR_LOG_LISTENER
|
|
778
|
+
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_clear_log_listener(void
|
|
779
|
+
|
|
733
780
|
);
|
|
734
781
|
#endif
|
|
735
782
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_CLEAR_SESSION_PRE_SEND_HOOK
|
|
@@ -772,6 +819,12 @@ uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_ap
|
|
|
772
819
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_RECORD_IDENTITY_EVENT
|
|
773
820
|
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_identity_event(void
|
|
774
821
|
|
|
822
|
+
);
|
|
823
|
+
#endif
|
|
824
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_RECORD_LOCATION_FIX
|
|
825
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_RECORD_LOCATION_FIX
|
|
826
|
+
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_location_fix(void
|
|
827
|
+
|
|
775
828
|
);
|
|
776
829
|
#endif
|
|
777
830
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_RECORD_NETWORK_EVENT
|
|
@@ -790,6 +843,12 @@ uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_pl
|
|
|
790
843
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_RECORD_SESSION_EVENT
|
|
791
844
|
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_record_session_event(void
|
|
792
845
|
|
|
846
|
+
);
|
|
847
|
+
#endif
|
|
848
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_AUTO_CONNECTION_TYPE
|
|
849
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_AUTO_CONNECTION_TYPE
|
|
850
|
+
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_auto_connection_type(void
|
|
851
|
+
|
|
793
852
|
);
|
|
794
853
|
#endif
|
|
795
854
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_CAPTURE_PLAN_LISTENER
|
|
@@ -808,6 +867,12 @@ uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_conte
|
|
|
808
867
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_LOG_LEVEL
|
|
809
868
|
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_log_level(void
|
|
810
869
|
|
|
870
|
+
);
|
|
871
|
+
#endif
|
|
872
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_LOG_LISTENER
|
|
873
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_LOG_LISTENER
|
|
874
|
+
uint16_t uniffi_forge_kernel_uniffi_checksum_method_forgeruntimebridge_set_log_listener(void
|
|
875
|
+
|
|
811
876
|
);
|
|
812
877
|
#endif
|
|
813
878
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_FORGERUNTIMEBRIDGE_SET_SESSION_PRE_SEND_HOOK
|
|
@@ -850,6 +915,12 @@ uint16_t uniffi_forge_kernel_uniffi_checksum_method_applecaptureplanlistener_on_
|
|
|
850
915
|
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_APPLECONTENTMETADATAPROVIDER_METADATA_SNAPSHOT
|
|
851
916
|
uint16_t uniffi_forge_kernel_uniffi_checksum_method_applecontentmetadataprovider_metadata_snapshot(void
|
|
852
917
|
|
|
918
|
+
);
|
|
919
|
+
#endif
|
|
920
|
+
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_APPLELOGLISTENER_ON_LOG
|
|
921
|
+
#define UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_APPLELOGLISTENER_ON_LOG
|
|
922
|
+
uint16_t uniffi_forge_kernel_uniffi_checksum_method_appleloglistener_on_log(void
|
|
923
|
+
|
|
853
924
|
);
|
|
854
925
|
#endif
|
|
855
926
|
#ifndef UNIFFI_FFIDEF_UNIFFI_FORGE_KERNEL_UNIFFI_CHECKSUM_METHOD_APPLESESSIONPRESENDHOOK_WILL_SEND
|
|
@@ -144,6 +144,18 @@ public final class AVPlayerAdapter: PlayerAdapter {
|
|
|
144
144
|
handleTimeControlStatus(player.timeControlStatus)
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
/// Last line of defence for an adapter released without an unbind.
|
|
148
|
+
///
|
|
149
|
+
/// `unregisterListeners` is the normal path and covers everything; this
|
|
150
|
+
/// exists because a periodic time observer left on an AVPlayer is not an
|
|
151
|
+
/// inert leak — AVFoundation asserts when a player is deallocated while one
|
|
152
|
+
/// is still registered. The adapter holds the player strongly
|
|
153
|
+
/// (`timeObserverOwner`), so without this the two would be released
|
|
154
|
+
/// together with the observer still attached.
|
|
155
|
+
deinit {
|
|
156
|
+
removeTimeObserverLocked()
|
|
157
|
+
}
|
|
158
|
+
|
|
147
159
|
public override func unregisterListeners() {
|
|
148
160
|
observerLock.lock()
|
|
149
161
|
defer { observerLock.unlock() }
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (C) NPAW - All Rights Reserved
|
|
3
|
+
*
|
|
4
|
+
* This source code is protected under international copyright law. All rights
|
|
5
|
+
* reserved and protected by the copyright holders.
|
|
6
|
+
* This file is confidential and only available to authorized individuals with the
|
|
7
|
+
* permission of the copyright holders. If you encounter this file and do not have
|
|
8
|
+
* permission, please contact the copyright holders and delete this file.
|
|
9
|
+
*
|
|
10
|
+
*
|
|
11
|
+
* @author: Victor Soto <victor.soto@nicepeopleatwork.com>
|
|
12
|
+
* @description: Automatic Apple connection type collection (connectionType) for Forge analytics.
|
|
13
|
+
*/
|
|
14
|
+
import Foundation
|
|
15
|
+
import Network
|
|
16
|
+
|
|
17
|
+
/// The connection classes Forge reports, matching the kernel's closed
|
|
18
|
+
/// allowlist.
|
|
19
|
+
///
|
|
20
|
+
/// Every platform maps its own link types onto these five so a Suite filter
|
|
21
|
+
/// means the same thing on iOS, Android, web and Roku.
|
|
22
|
+
public enum ForgeConnectionType: String, Sendable {
|
|
23
|
+
case wifi
|
|
24
|
+
case cellular
|
|
25
|
+
case ethernet
|
|
26
|
+
case other
|
|
27
|
+
case unknown
|
|
28
|
+
|
|
29
|
+
/// Maps an `NWPath` onto a reported class.
|
|
30
|
+
///
|
|
31
|
+
/// An unsatisfied path is `unknown` rather than a guess: the device has no
|
|
32
|
+
/// usable link, and the interface list on an unsatisfied path describes
|
|
33
|
+
/// what might come back, not what is carrying traffic.
|
|
34
|
+
///
|
|
35
|
+
/// `wiredEthernet` covers Apple TV and a Mac on a dock. `loopback` and
|
|
36
|
+
/// `other` land in `other`, which is also where an unrecognised future
|
|
37
|
+
/// interface type goes.
|
|
38
|
+
static func from(path: NWPath) -> ForgeConnectionType {
|
|
39
|
+
guard path.status == .satisfied else { return .unknown }
|
|
40
|
+
if path.usesInterfaceType(.wifi) { return .wifi }
|
|
41
|
+
if path.usesInterfaceType(.cellular) { return .cellular }
|
|
42
|
+
if path.usesInterfaceType(.wiredEthernet) { return .ethernet }
|
|
43
|
+
return .other
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// Watches the device's network path and republishes the class it belongs to.
|
|
48
|
+
///
|
|
49
|
+
/// One observer per Forge instance, started at build and cancelled on teardown.
|
|
50
|
+
/// `NWPathMonitor` needs no entitlement and no user prompt, so unlike Android
|
|
51
|
+
/// there is no permission that can silently disable this.
|
|
52
|
+
final class ForgeConnectionTypeObserver {
|
|
53
|
+
private let monitor: NWPathMonitor
|
|
54
|
+
private let queue: DispatchQueue
|
|
55
|
+
private let publish: (String?) -> Void
|
|
56
|
+
private let lock = NSLock()
|
|
57
|
+
private var started = false
|
|
58
|
+
private var lastPublished: ForgeConnectionType?
|
|
59
|
+
|
|
60
|
+
init(
|
|
61
|
+
monitor: NWPathMonitor = NWPathMonitor(),
|
|
62
|
+
queue: DispatchQueue = DispatchQueue(label: "com.npaw.forge.connection-type"),
|
|
63
|
+
publish: @escaping (String?) -> Void
|
|
64
|
+
) {
|
|
65
|
+
self.monitor = monitor
|
|
66
|
+
self.queue = queue
|
|
67
|
+
self.publish = publish
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/// Starts watching. Starting twice is a no-op, so a facade that rebuilds
|
|
71
|
+
/// does not stack monitors.
|
|
72
|
+
func start() {
|
|
73
|
+
lock.lock()
|
|
74
|
+
if started {
|
|
75
|
+
lock.unlock()
|
|
76
|
+
return
|
|
77
|
+
}
|
|
78
|
+
started = true
|
|
79
|
+
lock.unlock()
|
|
80
|
+
|
|
81
|
+
monitor.pathUpdateHandler = { [weak self] path in
|
|
82
|
+
self?.handle(path: path)
|
|
83
|
+
}
|
|
84
|
+
monitor.start(queue: queue)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// Cancels the monitor and clears the published value, so a torn-down
|
|
88
|
+
/// instance cannot keep a stale class attached to later events.
|
|
89
|
+
func stop() {
|
|
90
|
+
lock.lock()
|
|
91
|
+
let wasStarted = started
|
|
92
|
+
started = false
|
|
93
|
+
lastPublished = nil
|
|
94
|
+
lock.unlock()
|
|
95
|
+
|
|
96
|
+
guard wasStarted else { return }
|
|
97
|
+
monitor.pathUpdateHandler = nil
|
|
98
|
+
monitor.cancel()
|
|
99
|
+
publish(nil)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
func handle(path: NWPath) {
|
|
103
|
+
report(ForgeConnectionType.from(path: path))
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// Publishes only genuine changes.
|
|
107
|
+
///
|
|
108
|
+
/// `NWPathMonitor` fires on any path detail — a DNS change, an interface
|
|
109
|
+
/// coming up behind the active one — and the kernel already suppresses
|
|
110
|
+
/// repeats on the wire. Filtering here keeps the traffic across the
|
|
111
|
+
/// UniFFI boundary proportional to real handovers.
|
|
112
|
+
///
|
|
113
|
+
/// Separate from `handle(path:)` because an `NWPath` cannot be constructed
|
|
114
|
+
/// in a test, and this is the half worth testing.
|
|
115
|
+
func report(_ observed: ForgeConnectionType) {
|
|
116
|
+
lock.lock()
|
|
117
|
+
guard started, lastPublished != observed else {
|
|
118
|
+
lock.unlock()
|
|
119
|
+
return
|
|
120
|
+
}
|
|
121
|
+
lastPublished = observed
|
|
122
|
+
lock.unlock()
|
|
123
|
+
publish(observed.rawValue)
|
|
124
|
+
}
|
|
125
|
+
}
|