@voidhash/nitro-ui 0.0.0-stage → 0.4.0
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/LICENSE.md +21 -0
- package/Package.swift +161 -0
- package/README.md +127 -2
- package/android/nitro-ui.gradle +35 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/HybridVoidhashNativeClient.kt +53 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/VoidhashNitroUIModule.kt +65 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/client/LegacyStorageImporter.kt +526 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/client/SdkBackedNativeClient.kt +1131 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/client/StoreMapping.kt +257 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/client/VoidhashFlowPermissionHandlers.kt +23 -0
- package/android/src/main/java/com/margelo/nitro/voidhash/flows/VoidhashFlowsCore.kt +93 -0
- package/build/chunk-Z6TDMZMZ.js +326 -0
- package/build/chunk-Z6TDMZMZ.js.map +1 -0
- package/build/index.d.ts +2866 -0
- package/build/index.js +4182 -0
- package/build/index.js.map +1 -0
- package/build/navigation.d.ts +66 -0
- package/build/navigation.js +72 -0
- package/build/navigation.js.map +1 -0
- package/ios/HybridVoidhashNativeClient.swift +427 -0
- package/ios/Shared/NativeClientMapping.swift +184 -0
- package/ios/Shared/NativeStoreJson.swift +126 -0
- package/ios/Shared/VoidhashCoreExports.swift +5 -0
- package/ios/Shared/VoidhashLegacyImporter.swift +686 -0
- package/ios/Shared/VoidhashNativeClientCore.swift +1400 -0
- package/nitro.json +8 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroVoidhash+autolinking.cmake +86 -0
- package/nitrogen/generated/android/NitroVoidhash+autolinking.gradle +10 -0
- package/nitrogen/generated/android/NitroVoidhashOnLoad.cpp +22 -0
- package/nitrogen/generated/android/c++/JCallback_Promise_std__string__std__string_std__string.cpp +57 -0
- package/nitrogen/generated/android/c++/JCallback_void_NativeClientEvent.cpp +55 -0
- package/nitrogen/generated/android/c++/JHybridVoidhashNativeClientSpec.cpp +387 -0
- package/nitrogen/generated/android/c++/JNativeAnalyticsConsent.cpp +55 -0
- package/nitrogen/generated/android/c++/JNativeAppStoreMessages.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeAppStorePurchaseOptions.cpp +36 -0
- package/nitrogen/generated/android/c++/JNativeAppStoreSubscriptionState.cpp +64 -0
- package/nitrogen/generated/android/c++/JNativeAppStoreSubscriptionStatus.cpp +38 -0
- package/nitrogen/generated/android/c++/JNativeClientConfiguration.cpp +75 -0
- package/nitrogen/generated/android/c++/JNativeClientEvent.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeClientEventType.cpp +70 -0
- package/nitrogen/generated/android/c++/JNativeDiagnostic.cpp +44 -0
- package/nitrogen/generated/android/c++/JNativeDiagnosticKind.cpp +67 -0
- package/nitrogen/generated/android/c++/JNativeEnvironment.cpp +61 -0
- package/nitrogen/generated/android/c++/JNativeFeatureFlag.cpp +41 -0
- package/nitrogen/generated/android/c++/JNativeFeatureFlagsResult.cpp +45 -0
- package/nitrogen/generated/android/c++/JNativeFlowCapability.cpp +58 -0
- package/nitrogen/generated/android/c++/JNativeFlowLoading.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeFlowPresentation.cpp +42 -0
- package/nitrogen/generated/android/c++/JNativeFlowRevision.cpp +37 -0
- package/nitrogen/generated/android/c++/JNativeFlowRuntime.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeFlushStatus.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeFreshnessReason.cpp +58 -0
- package/nitrogen/generated/android/c++/JNativeGooglePlayPurchaseOptions.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeIdentifyResult.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeIdentityChange.cpp +38 -0
- package/nitrogen/generated/android/c++/JNativeInAppMessageResult.cpp +38 -0
- package/nitrogen/generated/android/c++/JNativeInAppMessageStatus.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeOffer.cpp +44 -0
- package/nitrogen/generated/android/c++/JNativeOfferKind.cpp +61 -0
- package/nitrogen/generated/android/c++/JNativeOfferSelection.cpp +55 -0
- package/nitrogen/generated/android/c++/JNativePaymentMode.cpp +58 -0
- package/nitrogen/generated/android/c++/JNativePendingAnalytics.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativePeriod.cpp +39 -0
- package/nitrogen/generated/android/c++/JNativePeriodUnit.cpp +61 -0
- package/nitrogen/generated/android/c++/JNativePersonState.cpp +44 -0
- package/nitrogen/generated/android/c++/JNativePersonWriteResult.cpp +38 -0
- package/nitrogen/generated/android/c++/JNativePrice.cpp +39 -0
- package/nitrogen/generated/android/c++/JNativePricingPhase.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeProduct.cpp +55 -0
- package/nitrogen/generated/android/c++/JNativeProductType.cpp +61 -0
- package/nitrogen/generated/android/c++/JNativePurchaseIntent.cpp +38 -0
- package/nitrogen/generated/android/c++/JNativePurchaseIntents.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativePurchaseOptions.cpp +49 -0
- package/nitrogen/generated/android/c++/JNativePurchaseOutcome.cpp +55 -0
- package/nitrogen/generated/android/c++/JNativePurchaseResult.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeRefundRequestStatus.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeReportedPurchaseState.cpp +55 -0
- package/nitrogen/generated/android/c++/JNativeReportedTransaction.cpp +42 -0
- package/nitrogen/generated/android/c++/JNativeStore.cpp +58 -0
- package/nitrogen/generated/android/c++/JNativeStorePlatform.cpp +52 -0
- package/nitrogen/generated/android/c++/JNativeStorefront.cpp +37 -0
- package/nitrogen/generated/android/c++/JNativeSubscriptionInfo.cpp +45 -0
- package/nitrogen/generated/android/c++/JNativeSubscriptionReplacement.cpp +36 -0
- package/nitrogen/generated/android/c++/JNativeSubscriptionReplacementMode.cpp +61 -0
- package/nitrogen/generated/android/c++/JNativeTransaction.cpp +53 -0
- package/nitrogen/generated/android/c++/JNativeTransactionOffer.cpp +40 -0
- package/nitrogen/generated/android/c++/JNativeTransactionOfferKind.cpp +64 -0
- package/nitrogen/generated/android/c++/JNativeTransactionUpdate.cpp +36 -0
- package/nitrogen/generated/android/c++/JNativeWriteStatus.cpp +55 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JCallback_Promise_std__string__std__string_std__string.hpp +55 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JCallback_void_NativeClientEvent.hpp +54 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JHybridVoidhashNativeClientSpec.hpp +166 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JHybridVoidhashNativeClientSpecJavaPart.hpp +26 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeAnalyticsConsent.hpp +77 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeAppStoreMessages.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeAppStorePurchaseOptions.hpp +51 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeAppStoreSubscriptionState.hpp +92 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeAppStoreSubscriptionStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeClientConfiguration.hpp +190 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeClientEvent.hpp +99 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeClientEventType.hpp +102 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeDiagnostic.hpp +79 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeDiagnosticKind.hpp +97 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeEnvironment.hpp +87 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFeatureFlag.hpp +68 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFeatureFlagsResult.hpp +76 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlowCapability.hpp +82 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlowLoading.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlowPresentation.hpp +65 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlowRevision.hpp +56 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlowRuntime.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFlushStatus.hpp +63 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeFreshnessReason.hpp +82 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeGooglePlayPurchaseOptions.hpp +63 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeIdentifyResult.hpp +63 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeIdentityChange.hpp +61 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeInAppMessageResult.hpp +57 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeInAppMessageStatus.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeOffer.hpp +71 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeOfferKind.hpp +87 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeOfferSelection.hpp +77 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePaymentMode.hpp +82 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePendingAnalytics.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePeriod.hpp +62 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePeriodUnit.hpp +87 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePersonState.hpp +79 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePersonWriteResult.hpp +57 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePrice.hpp +66 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePricingPhase.hpp +67 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeProduct.hpp +118 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeProductType.hpp +87 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePurchaseIntent.hpp +57 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePurchaseIntents.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePurchaseOptions.hpp +88 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePurchaseOutcome.hpp +77 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativePurchaseResult.hpp +63 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeRefundRequestStatus.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeReportedPurchaseState.hpp +77 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeReportedTransaction.hpp +73 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeStore.hpp +82 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeStorePlatform.hpp +72 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeStorefront.hpp +56 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeSubscriptionInfo.hpp +84 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeSubscriptionReplacement.hpp +55 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeSubscriptionReplacementMode.hpp +87 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeTransaction.hpp +116 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeTransactionOffer.hpp +63 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeTransactionOfferKind.hpp +92 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeTransactionUpdate.hpp +55 -0
- package/nitrogen/generated/android/c++/include/NitroVoidhash/private/JNativeWriteStatus.hpp +77 -0
- package/nitrogen/generated/android/include/NitroVoidhash/private/NitroVoidhashOnLoad.hpp +13 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/Callback_Promise_std__string__std__string_std__string.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/Callback_void_NativeClientEvent.kt +69 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/HybridVoidhashNativeClientSpec.kt +278 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeAnalyticsConsent.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeAppStoreMessages.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeAppStorePurchaseOptions.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeAppStoreSubscriptionState.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeAppStoreSubscriptionStatus.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeClientConfiguration.kt +172 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeClientEvent.kt +87 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeClientEventType.kt +64 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeDiagnostic.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeDiagnosticKind.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeEnvironment.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFeatureFlag.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFeatureFlagsResult.kt +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlowCapability.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlowLoading.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlowPresentation.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlowRevision.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlowRuntime.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFlushStatus.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeFreshnessReason.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeGooglePlayPurchaseOptions.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeIdentifyResult.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeIdentityChange.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeInAppMessageResult.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeInAppMessageStatus.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeOffer.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeOfferKind.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeOfferSelection.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePaymentMode.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePendingAnalytics.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePeriod.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePeriodUnit.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePersonState.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePersonWriteResult.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePrice.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePricingPhase.kt +62 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeProduct.kt +107 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeProductType.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePurchaseIntent.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePurchaseIntents.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePurchaseOptions.kt +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePurchaseOutcome.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativePurchaseResult.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeRefundRequestStatus.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeReportedPurchaseState.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeReportedTransaction.kt +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeStore.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeStorePlatform.kt +46 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeStorefront.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeSubscriptionInfo.kt +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeSubscriptionReplacement.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeSubscriptionReplacementMode.kt +55 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeTransaction.kt +107 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeTransactionOffer.kt +57 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeTransactionOfferKind.kt +58 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeTransactionUpdate.kt +52 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NativeWriteStatus.kt +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/voidhash/NitroVoidhashOnLoad.kt +22 -0
- package/nitrogen/generated/apple/NitroVoidhash-Swift-Cxx-Bridge.cpp +381 -0
- package/nitrogen/generated/apple/NitroVoidhashAppleCxx/NitroVoidhashAppleCxx.cpp +9 -0
- package/nitrogen/generated/apple/NitroVoidhashAppleCxx/include/NitroVoidhashAppleCxx/NitroVoidhashAppleCxx.h +265 -0
- package/nitrogen/generated/apple/NitroVoidhashAutolinking.cpp +20 -0
- package/nitrogen/generated/apple/NitroVoidhashAutolinking.mm +24 -0
- package/nitrogen/generated/apple/c++/HybridVoidhashNativeClientSpecSwift.cpp +555 -0
- package/nitrogen/generated/apple/c++/HybridVoidhashNativeClientSpec_cxx-Swift.cpp +28 -0
- package/nitrogen/generated/apple/c++/NativeAnalyticsConsent-Swift.cpp +49 -0
- package/nitrogen/generated/apple/c++/NativeAppStoreMessages-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeAppStorePurchaseOptions-Swift.cpp +32 -0
- package/nitrogen/generated/apple/c++/NativeAppStoreSubscriptionState-Swift.cpp +58 -0
- package/nitrogen/generated/apple/c++/NativeAppStoreSubscriptionStatus-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeClientConfiguration-Swift.cpp +57 -0
- package/nitrogen/generated/apple/c++/NativeClientEvent-Swift.cpp +40 -0
- package/nitrogen/generated/apple/c++/NativeClientEventType-Swift.cpp +64 -0
- package/nitrogen/generated/apple/c++/NativeDiagnostic-Swift.cpp +37 -0
- package/nitrogen/generated/apple/c++/NativeDiagnosticKind-Swift.cpp +61 -0
- package/nitrogen/generated/apple/c++/NativeEnvironment-Swift.cpp +55 -0
- package/nitrogen/generated/apple/c++/NativeFeatureFlag-Swift.cpp +35 -0
- package/nitrogen/generated/apple/c++/NativeFeatureFlagsResult-Swift.cpp +36 -0
- package/nitrogen/generated/apple/c++/NativeFlowCapability-Swift.cpp +52 -0
- package/nitrogen/generated/apple/c++/NativeFlowLoading-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeFlowPresentation-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeFlowRevision-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativeFlowRuntime-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeFlushStatus-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeFreshnessReason-Swift.cpp +52 -0
- package/nitrogen/generated/apple/c++/NativeGooglePlayPurchaseOptions-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeIdentifyResult-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeIdentityChange-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeInAppMessageResult-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativeInAppMessageStatus-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeOffer-Swift.cpp +35 -0
- package/nitrogen/generated/apple/c++/NativeOfferKind-Swift.cpp +55 -0
- package/nitrogen/generated/apple/c++/NativeOfferSelection-Swift.cpp +49 -0
- package/nitrogen/generated/apple/c++/NativePaymentMode-Swift.cpp +52 -0
- package/nitrogen/generated/apple/c++/NativePendingAnalytics-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativePeriod-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativePeriodUnit-Swift.cpp +55 -0
- package/nitrogen/generated/apple/c++/NativePersonState-Swift.cpp +37 -0
- package/nitrogen/generated/apple/c++/NativePersonWriteResult-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativePrice-Swift.cpp +35 -0
- package/nitrogen/generated/apple/c++/NativePricingPhase-Swift.cpp +35 -0
- package/nitrogen/generated/apple/c++/NativeProduct-Swift.cpp +44 -0
- package/nitrogen/generated/apple/c++/NativeProductType-Swift.cpp +55 -0
- package/nitrogen/generated/apple/c++/NativePurchaseIntent-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativePurchaseIntents-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativePurchaseOptions-Swift.cpp +38 -0
- package/nitrogen/generated/apple/c++/NativePurchaseOutcome-Swift.cpp +49 -0
- package/nitrogen/generated/apple/c++/NativePurchaseResult-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeRefundRequestStatus-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeReportedPurchaseState-Swift.cpp +49 -0
- package/nitrogen/generated/apple/c++/NativeReportedTransaction-Swift.cpp +36 -0
- package/nitrogen/generated/apple/c++/NativeStore-Swift.cpp +52 -0
- package/nitrogen/generated/apple/c++/NativeStorePlatform-Swift.cpp +46 -0
- package/nitrogen/generated/apple/c++/NativeStorefront-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativeSubscriptionInfo-Swift.cpp +38 -0
- package/nitrogen/generated/apple/c++/NativeSubscriptionReplacement-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativeSubscriptionReplacementMode-Swift.cpp +55 -0
- package/nitrogen/generated/apple/c++/NativeTransaction-Swift.cpp +44 -0
- package/nitrogen/generated/apple/c++/NativeTransactionOffer-Swift.cpp +34 -0
- package/nitrogen/generated/apple/c++/NativeTransactionOfferKind-Swift.cpp +58 -0
- package/nitrogen/generated/apple/c++/NativeTransactionUpdate-Swift.cpp +33 -0
- package/nitrogen/generated/apple/c++/NativeWriteStatus-Swift.cpp +49 -0
- package/nitrogen/generated/apple/c++/Record_swift__String_bool-Swift.cpp +26 -0
- package/nitrogen/generated/apple/c++/Record_swift__String_swift__String-Swift.cpp +26 -0
- package/nitrogen/generated/apple/c++/SwiftContainer_swift__Array___NitroVoidhash__NativeAppStoreSubscriptionStatus_-Swift.cpp +38 -0
- package/nitrogen/generated/apple/c++/SwiftContainer_swift__Array___NitroVoidhash__NativeProduct_-Swift.cpp +41 -0
- package/nitrogen/generated/apple/c++/SwiftContainer_swift__Array___NitroVoidhash__NativeTransaction_-Swift.cpp +36 -0
- package/nitrogen/generated/apple/c++/SwiftContainer_swift__Optional___NitroVoidhash__NativeStorefront_-Swift.cpp +30 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/NitroVoidhashAutolinking.hpp +13 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/HybridVoidhashNativeClientSpecSwift.hpp +121 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/HybridVoidhashNativeClientSpec_cxx-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeAnalyticsConsent-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeAppStoreMessages-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeAppStorePurchaseOptions-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeAppStoreSubscriptionState-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeAppStoreSubscriptionStatus-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeClientConfiguration-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeClientEvent-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeClientEventType-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeDiagnostic-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeDiagnosticKind-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeEnvironment-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFeatureFlag-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFeatureFlagsResult-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlowCapability-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlowLoading-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlowPresentation-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlowRevision-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlowRuntime-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFlushStatus-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeFreshnessReason-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeGooglePlayPurchaseOptions-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeIdentifyResult-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeIdentityChange-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeInAppMessageResult-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeInAppMessageStatus-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeOffer-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeOfferKind-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeOfferSelection-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePaymentMode-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePendingAnalytics-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePeriod-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePeriodUnit-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePersonState-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePersonWriteResult-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePrice-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePricingPhase-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeProduct-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeProductType-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePurchaseIntent-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePurchaseIntents-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePurchaseOptions-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePurchaseOutcome-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativePurchaseResult-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeRefundRequestStatus-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeReportedPurchaseState-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeReportedTransaction-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeStore-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeStorePlatform-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeStorefront-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeSubscriptionInfo-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeSubscriptionReplacement-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeSubscriptionReplacementMode-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeTransaction-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeTransactionOffer-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeTransactionOfferKind-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeTransactionUpdate-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NativeWriteStatus-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/NitroVoidhash-Swift-Cxx-Umbrella.hpp +100 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/Record_swift__String_bool-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/Record_swift__String_swift__String-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/SwiftContainer_swift__Array___NitroVoidhash__NativeAppStoreSubscriptionStatus_-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/SwiftContainer_swift__Array___NitroVoidhash__NativeProduct_-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/SwiftContainer_swift__Array___NitroVoidhash__NativeTransaction_-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/NitroVoidhash/private/SwiftContainer_swift__Optional___NitroVoidhash__NativeStorefront_-Swift.hpp +23 -0
- package/nitrogen/generated/apple/c++/include/module.modulemap +12 -0
- package/nitrogen/generated/apple/swift/Callback_Promise_swift__String__swift__String_swift__String.swift +73 -0
- package/nitrogen/generated/apple/swift/Callback_void___NitroVoidhash__NativeClientEvent.swift +66 -0
- package/nitrogen/generated/apple/swift/HybridVoidhashNativeClientSpec.swift +113 -0
- package/nitrogen/generated/apple/swift/HybridVoidhashNativeClientSpec_cxx.swift +629 -0
- package/nitrogen/generated/apple/swift/NativeAnalyticsConsent.swift +59 -0
- package/nitrogen/generated/apple/swift/NativeAppStoreMessages.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeAppStorePurchaseOptions.swift +28 -0
- package/nitrogen/generated/apple/swift/NativeAppStoreSubscriptionState.swift +74 -0
- package/nitrogen/generated/apple/swift/NativeAppStoreSubscriptionStatus.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeClientConfiguration.swift +203 -0
- package/nitrogen/generated/apple/swift/NativeClientEvent.swift +84 -0
- package/nitrogen/generated/apple/swift/NativeClientEventType.swift +84 -0
- package/nitrogen/generated/apple/swift/NativeDiagnostic.swift +63 -0
- package/nitrogen/generated/apple/swift/NativeDiagnosticKind.swift +79 -0
- package/nitrogen/generated/apple/swift/NativeEnvironment.swift +69 -0
- package/nitrogen/generated/apple/swift/NativeFeatureFlag.swift +49 -0
- package/nitrogen/generated/apple/swift/NativeFeatureFlagsResult.swift +56 -0
- package/nitrogen/generated/apple/swift/NativeFlowCapability.swift +64 -0
- package/nitrogen/generated/apple/swift/NativeFlowLoading.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeFlowPresentation.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeFlowRevision.swift +35 -0
- package/nitrogen/generated/apple/swift/NativeFlowRuntime.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeFlushStatus.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeFreshnessReason.swift +64 -0
- package/nitrogen/generated/apple/swift/NativeGooglePlayPurchaseOptions.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeIdentifyResult.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeIdentityChange.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeInAppMessageResult.swift +35 -0
- package/nitrogen/generated/apple/swift/NativeInAppMessageStatus.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeOffer.swift +49 -0
- package/nitrogen/generated/apple/swift/NativeOfferKind.swift +69 -0
- package/nitrogen/generated/apple/swift/NativeOfferSelection.swift +59 -0
- package/nitrogen/generated/apple/swift/NativePaymentMode.swift +64 -0
- package/nitrogen/generated/apple/swift/NativePendingAnalytics.swift +54 -0
- package/nitrogen/generated/apple/swift/NativePeriod.swift +42 -0
- package/nitrogen/generated/apple/swift/NativePeriodUnit.swift +69 -0
- package/nitrogen/generated/apple/swift/NativePersonState.swift +63 -0
- package/nitrogen/generated/apple/swift/NativePersonWriteResult.swift +35 -0
- package/nitrogen/generated/apple/swift/NativePrice.swift +49 -0
- package/nitrogen/generated/apple/swift/NativePricingPhase.swift +49 -0
- package/nitrogen/generated/apple/swift/NativeProduct.swift +112 -0
- package/nitrogen/generated/apple/swift/NativeProductType.swift +69 -0
- package/nitrogen/generated/apple/swift/NativePurchaseIntent.swift +35 -0
- package/nitrogen/generated/apple/swift/NativePurchaseIntents.swift +54 -0
- package/nitrogen/generated/apple/swift/NativePurchaseOptions.swift +70 -0
- package/nitrogen/generated/apple/swift/NativePurchaseOutcome.swift +59 -0
- package/nitrogen/generated/apple/swift/NativePurchaseResult.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeRefundRequestStatus.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeReportedPurchaseState.swift +59 -0
- package/nitrogen/generated/apple/swift/NativeReportedTransaction.swift +56 -0
- package/nitrogen/generated/apple/swift/NativeStore.swift +64 -0
- package/nitrogen/generated/apple/swift/NativeStorePlatform.swift +54 -0
- package/nitrogen/generated/apple/swift/NativeStorefront.swift +35 -0
- package/nitrogen/generated/apple/swift/NativeSubscriptionInfo.swift +70 -0
- package/nitrogen/generated/apple/swift/NativeSubscriptionReplacement.swift +35 -0
- package/nitrogen/generated/apple/swift/NativeSubscriptionReplacementMode.swift +69 -0
- package/nitrogen/generated/apple/swift/NativeTransaction.swift +112 -0
- package/nitrogen/generated/apple/swift/NativeTransactionOffer.swift +42 -0
- package/nitrogen/generated/apple/swift/NativeTransactionOfferKind.swift +74 -0
- package/nitrogen/generated/apple/swift/NativeTransactionUpdate.swift +35 -0
- package/nitrogen/generated/apple/swift/NativeWriteStatus.swift +59 -0
- package/nitrogen/generated/apple/swift/Promise_Promise_swift__String_.swift +100 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeFeatureFlagsResult.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeFlushStatus.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeIdentifyResult.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeIdentityChange.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeInAppMessageResult.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativePersonState.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativePersonWriteResult.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativePurchaseResult.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__NativeRefundRequestStatus.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__SwiftContainer_swift__Array___NitroVoidhash__NativeAppStoreSubscriptionStatus_.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__SwiftContainer_swift__Array___NitroVoidhash__NativeProduct_.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__SwiftContainer_swift__Array___NitroVoidhash__NativeTransaction_.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise___NitroVoidhash__SwiftContainer_swift__Optional___NitroVoidhash__NativeStorefront_.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise_bool.swift +100 -0
- package/nitrogen/generated/apple/swift/Promise_swift__String.swift +102 -0
- package/nitrogen/generated/apple/swift/Promise_void.swift +100 -0
- package/nitrogen/generated/apple/swift/Record_swift__String_bool.swift +48 -0
- package/nitrogen/generated/apple/swift/Record_swift__String_swift__String.swift +48 -0
- package/nitrogen/generated/apple/swift/SwiftContainer_swift__Array___NitroVoidhash__NativeAppStoreSubscriptionStatus_.swift +21 -0
- package/nitrogen/generated/apple/swift/SwiftContainer_swift__Array___NitroVoidhash__NativeProduct_.swift +21 -0
- package/nitrogen/generated/apple/swift/SwiftContainer_swift__Array___NitroVoidhash__NativeTransaction_.swift +21 -0
- package/nitrogen/generated/apple/swift/SwiftContainer_swift__Optional___NitroVoidhash__NativeStorefront_.swift +21 -0
- package/nitrogen/generated/hybrid-classes.json +19 -0
- package/nitrogen/generated/shared/c++/NitroVoidhashCxxModule.cpp +2 -0
- package/nitrogen/generated/shared/c++/include/NitroVoidhash/NitroVoidhashCxxModule.hpp +2 -0
- package/nitrogen/generated/shared/javascript/VoidhashNativeClient.cjs +19 -0
- package/nitrogen/generated/shared/javascript/VoidhashNativeClient.d.cts +9 -0
- package/package.json +103 -3
- package/src/specs/VoidhashNativeClient.nitro.ts +1162 -0
|
@@ -0,0 +1,1131 @@
|
|
|
1
|
+
// Copied from ../react-native/android/src/main/java/com/margelo/nitro/voidhash/client/SdkBackedNativeClient.kt by `pnpm build`. Edit the original, not this copy.
|
|
2
|
+
@file:OptIn(VoidhashHostApi::class)
|
|
3
|
+
|
|
4
|
+
package com.margelo.nitro.voidhash
|
|
5
|
+
|
|
6
|
+
import com.voidhash.sdk.VoidhashHostApi
|
|
7
|
+
import android.app.Activity
|
|
8
|
+
import android.content.Context
|
|
9
|
+
import androidx.annotation.Keep
|
|
10
|
+
import com.android.billingclient.api.BillingClient
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.Promise
|
|
13
|
+
import com.margelo.nitro.voidhash.client.LegacyStorageImporter
|
|
14
|
+
import com.margelo.nitro.voidhash.client.toNative
|
|
15
|
+
import com.margelo.nitro.voidhash.flows.VoidhashFlowsCore
|
|
16
|
+
import com.voidhash.sdk.AnalyticsConsent
|
|
17
|
+
import com.voidhash.sdk.ClientEvent
|
|
18
|
+
import com.voidhash.sdk.FeatureFlagOptions
|
|
19
|
+
import com.voidhash.sdk.FlowCapability
|
|
20
|
+
import com.voidhash.sdk.FlowException
|
|
21
|
+
import com.voidhash.sdk.FlowFailure
|
|
22
|
+
import com.voidhash.sdk.FlowResult
|
|
23
|
+
import com.voidhash.sdk.FlagsState
|
|
24
|
+
import com.voidhash.sdk.FreshnessReason
|
|
25
|
+
import com.voidhash.sdk.GooglePlayInAppMessageResult
|
|
26
|
+
import com.voidhash.sdk.HostSettings
|
|
27
|
+
import com.voidhash.sdk.PendingAnalytics
|
|
28
|
+
import com.voidhash.sdk.PersonState
|
|
29
|
+
import com.voidhash.sdk.PlatformServices
|
|
30
|
+
import com.voidhash.sdk.ScreenTrackingOptions
|
|
31
|
+
import com.voidhash.sdk.Voidhash
|
|
32
|
+
import com.voidhash.sdk.VoidhashClient
|
|
33
|
+
import com.voidhash.sdk.VoidhashException
|
|
34
|
+
import com.voidhash.sdk.VoidhashGroup
|
|
35
|
+
import com.voidhash.sdk.VoidhashOptions
|
|
36
|
+
import com.voidhash.sdk.VoidhashPurchaseException
|
|
37
|
+
import com.voidhash.sdk.WriteStatus
|
|
38
|
+
import com.voidhash.sdk.analytics.AutomaticEvents
|
|
39
|
+
import com.voidhash.sdk.analytics.FlushStatus
|
|
40
|
+
import com.voidhash.sdk.api.FeatureFlag
|
|
41
|
+
import com.voidhash.sdk.billing.GooglePlayPurchaseOptions
|
|
42
|
+
import com.voidhash.sdk.billing.PurchaseFailureReason
|
|
43
|
+
import com.voidhash.sdk.billing.SubscriptionReplacement
|
|
44
|
+
import com.voidhash.sdk.billing.SubscriptionReplacementMode
|
|
45
|
+
import com.voidhash.sdk.billing.VoidhashOfferSelection
|
|
46
|
+
import com.voidhash.sdk.billing.VoidhashProduct
|
|
47
|
+
import com.voidhash.sdk.billing.VoidhashPurchaseOptions
|
|
48
|
+
import com.voidhash.sdk.billing.VoidhashPurchaseResult
|
|
49
|
+
import com.voidhash.sdk.diagnostics.VoidhashDiagnostic
|
|
50
|
+
import com.voidhash.sdk.isAnonymousDistinctId
|
|
51
|
+
import com.voidhash.sdk.diagnostics.VoidhashDiagnosticKind
|
|
52
|
+
import com.voidhash.sdk.identity.invalidGroupReason
|
|
53
|
+
import com.voidhash.sdk.platform.whenStartedUnlocked
|
|
54
|
+
import com.voidhash.sdk.transactions.isScalarTraitValue
|
|
55
|
+
import kotlinx.coroutines.CancellationException
|
|
56
|
+
import kotlinx.coroutines.CompletableDeferred
|
|
57
|
+
import kotlinx.coroutines.CompletableJob
|
|
58
|
+
import kotlinx.coroutines.CoroutineDispatcher
|
|
59
|
+
import kotlinx.coroutines.CoroutineScope
|
|
60
|
+
import kotlinx.coroutines.CoroutineStart
|
|
61
|
+
import kotlinx.coroutines.Job
|
|
62
|
+
import kotlinx.coroutines.Dispatchers
|
|
63
|
+
import kotlinx.coroutines.SupervisorJob
|
|
64
|
+
import kotlinx.coroutines.cancelAndJoin
|
|
65
|
+
import kotlinx.coroutines.ensureActive
|
|
66
|
+
import kotlinx.coroutines.launch
|
|
67
|
+
import kotlinx.coroutines.sync.Mutex
|
|
68
|
+
import kotlinx.coroutines.sync.withLock
|
|
69
|
+
import kotlinx.coroutines.withContext
|
|
70
|
+
import org.json.JSONArray
|
|
71
|
+
import org.json.JSONObject
|
|
72
|
+
import java.util.concurrent.Executor
|
|
73
|
+
import java.util.concurrent.LinkedBlockingQueue
|
|
74
|
+
import java.util.concurrent.ThreadPoolExecutor
|
|
75
|
+
import java.util.concurrent.TimeUnit
|
|
76
|
+
import java.util.concurrent.atomic.AtomicReference
|
|
77
|
+
|
|
78
|
+
/** Captures and screens kept before `start()`, attributed to the identity it loads. */
|
|
79
|
+
private const val PRE_START_CAPTURE_LIMIT = 100
|
|
80
|
+
|
|
81
|
+
/** Diagnostics kept for a listener that is not set yet. */
|
|
82
|
+
private const val PRE_LISTENER_DIAGNOSTIC_LIMIT = 100
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The version of the bridge contract (`src/specs/VoidhashNativeClient.nitro.ts`) this module
|
|
86
|
+
* implements: the facade's `NATIVE_CONTRACT_VERSION`, which starts no client of another.
|
|
87
|
+
*/
|
|
88
|
+
internal const val NATIVE_CONTRACT_VERSION = 1
|
|
89
|
+
|
|
90
|
+
/** A rejection the facade reads its code from: the message is always `"<CODE>: <detail>"`. */
|
|
91
|
+
internal class NativeClientException(val code: String, detail: String, cause: Throwable? = null) :
|
|
92
|
+
RuntimeException("$code: $detail", cause)
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* One thread, ended once idle, that settles a client's promises and delivers its events in order:
|
|
96
|
+
* an instance a JavaScript reload left behind keeps none.
|
|
97
|
+
*/
|
|
98
|
+
internal fun deliveryQueue(threadName: String): Executor =
|
|
99
|
+
ThreadPoolExecutor(1, 1, 5, TimeUnit.SECONDS, LinkedBlockingQueue()) { runnable ->
|
|
100
|
+
Thread(runnable, threadName).apply { isDaemon = true }
|
|
101
|
+
}.apply { allowCoreThreadTimeOut(true) }
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The native client contract (`VoidhashNativeClient.nitro.ts`) over the bare SDK's
|
|
105
|
+
* [VoidhashClient], for every host that binds it with Nitro.
|
|
106
|
+
*
|
|
107
|
+
* This file is compiled unchanged by the React Native and the NitroUI packages, against each
|
|
108
|
+
* one's generated spec. Each host's final `HybridVoidhashNativeClient` supplies only what differs
|
|
109
|
+
* between them: where the application context and the current activity come from, how the
|
|
110
|
+
* instance is constructed, and `setEventListener` and `presentFlow`, whose callback types differ
|
|
111
|
+
* between Nitro versions; it hands those callbacks over as plain Kotlin functions through
|
|
112
|
+
* [setListener] and [presentFlowAnswering].
|
|
113
|
+
*
|
|
114
|
+
* Every behaviour is the SDK's; this class maps the contract onto it. Three rules are its own:
|
|
115
|
+
*
|
|
116
|
+
* - **Order.** Events and promise settlements go through one serial queue, in the order the client
|
|
117
|
+
* produced them. The client announces a change synchronously where it happens, so an event a call
|
|
118
|
+
* caused is queued before that call's settlement, and reaches JavaScript first.
|
|
119
|
+
* - **Lifetime.** `configure()` only records the options. `start()` configures the SDK, which
|
|
120
|
+
* retires any client still running in the process (a JavaScript reload leaves one behind), and
|
|
121
|
+
* initializes it from local state. `shutdown()` rejects every call still pending with
|
|
122
|
+
* `NOT_INITIALIZED` before it resolves, so no answer from that run arrives after it.
|
|
123
|
+
* - **First unlock.** In a process Android starts before the device was first unlocked, `start()`
|
|
124
|
+
* waits for the unlock before it opens anything (see [awaitFirstUnlock]), so the SDK is never
|
|
125
|
+
* configured into the inert client it returns there, which this class could not follow.
|
|
126
|
+
*/
|
|
127
|
+
@Keep
|
|
128
|
+
@DoNotStrip
|
|
129
|
+
abstract class SdkBackedNativeClient internal constructor(
|
|
130
|
+
/** The SDK name the client reports to Voidhash: `react-native` or `nitro-ui`. */
|
|
131
|
+
private val sdkName: String,
|
|
132
|
+
/** The host framework as errors name it, such as `React Native`. */
|
|
133
|
+
private val hostName: String,
|
|
134
|
+
private val contextProvider: () -> Context?,
|
|
135
|
+
private val activityProvider: () -> Activity?,
|
|
136
|
+
private val platform: PlatformServices,
|
|
137
|
+
private val delivery: Executor,
|
|
138
|
+
/** Where a call starts running; replaceable so a test decides when that is. */
|
|
139
|
+
private val callDispatcher: CoroutineDispatcher,
|
|
140
|
+
) : HybridVoidhashNativeClientSpec() {
|
|
141
|
+
private companion object {
|
|
142
|
+
/** Whether a `start()` of this process already adopted the `distinctId` option. */
|
|
143
|
+
@Volatile
|
|
144
|
+
var distinctIdAdopted = false
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* The wait of the one start in this process that waits for the first unlock. A newer
|
|
148
|
+
* instance's start takes it over, as its start retires an older instance's client.
|
|
149
|
+
*/
|
|
150
|
+
val startAwaitingUnlock = AtomicReference<CompletableDeferred<Unit>?>(null)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
private class PendingCapture(val name: String, val properties: Map<String, Any?>, val at: Long)
|
|
154
|
+
|
|
155
|
+
private val lock = Any()
|
|
156
|
+
private var configuration: NativeClientConfiguration? = null
|
|
157
|
+
private var readOnly: Boolean? = null
|
|
158
|
+
|
|
159
|
+
/** A consent `setAnalyticsConsent()` chose before `start()`; it wins over the configuration's. */
|
|
160
|
+
private var chosenConsent: NativeAnalyticsConsent? = null
|
|
161
|
+
|
|
162
|
+
@Volatile
|
|
163
|
+
private var client: VoidhashClient? = null
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The products the client's last [getProducts] answered, by slug: the ones [purchase] buys and
|
|
167
|
+
* [showManageSubscriptions] names, without asking Google Play again before every sheet.
|
|
168
|
+
* Dropped once a purchase or a restore may have changed the offers the end user is eligible
|
|
169
|
+
* for. Guarded by [lock].
|
|
170
|
+
*/
|
|
171
|
+
private var heldProducts: Map<String, VoidhashProduct> = emptyMap()
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Counts the products loads begun and the drops of [heldProducts]: only the latest load begun
|
|
175
|
+
* since the last drop is held, so an earlier, slower one never replaces its answer. Guarded by
|
|
176
|
+
* [lock].
|
|
177
|
+
*/
|
|
178
|
+
private var productsLoads = 0
|
|
179
|
+
|
|
180
|
+
@Volatile
|
|
181
|
+
private var listener: ((NativeClientEvent) -> Unit)? = null
|
|
182
|
+
private val pendingCaptures = ArrayDeque<PendingCapture>()
|
|
183
|
+
private val pendingDiagnostics = ArrayDeque<NativeDiagnostic>()
|
|
184
|
+
private var droppedBeforeStart = 0
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Whether captures go to the client. Not before `initialize` has loaded the consent stored on
|
|
188
|
+
* the device: until then the client knows only the option, and a capture would be refused or
|
|
189
|
+
* kept on its say.
|
|
190
|
+
*/
|
|
191
|
+
private var capturesOpen = false
|
|
192
|
+
|
|
193
|
+
/** The run the client's callbacks belong to; a later start or a shutdown silences an earlier run's. */
|
|
194
|
+
@Volatile
|
|
195
|
+
private var run = 0
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Keeps identity changes and person writes in call order: a write queued before an identify
|
|
199
|
+
* belongs to the identity before it. FIFO, and taken on the calling thread.
|
|
200
|
+
*/
|
|
201
|
+
private val identityOrder = Mutex()
|
|
202
|
+
|
|
203
|
+
/** The calls of the current run; [shutdown] cancels them and rejects their promises. */
|
|
204
|
+
private var calls: CompletableJob = SupervisorJob()
|
|
205
|
+
private var callScope = CoroutineScope(calls + callDispatcher)
|
|
206
|
+
private val lifecycleScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
|
207
|
+
|
|
208
|
+
// ---- Lifecycle ----
|
|
209
|
+
|
|
210
|
+
override fun contractVersion(): Double = NATIVE_CONTRACT_VERSION.toDouble()
|
|
211
|
+
|
|
212
|
+
override fun configure(configuration: NativeClientConfiguration) {
|
|
213
|
+
synchronized(lock) { this.configuration = configuration }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
override fun start(): Promise<Unit> {
|
|
217
|
+
val promise = Promise<Unit>()
|
|
218
|
+
// A start already running is joined; one that is done starts nothing again.
|
|
219
|
+
synchronized(lock) {
|
|
220
|
+
if (starting?.isCompleted != false && client?.isClosed == false) {
|
|
221
|
+
settle(promise, Result.success(Unit))
|
|
222
|
+
return promise
|
|
223
|
+
}
|
|
224
|
+
startPromises += promise
|
|
225
|
+
if (starting?.isCompleted == false) return promise
|
|
226
|
+
val thisRun = ++run
|
|
227
|
+
starting = lifecycleScope.launch {
|
|
228
|
+
val outcome = runCatching { startClient(thisRun) }
|
|
229
|
+
// Queued from the start itself and under the lock, with the start taken out of
|
|
230
|
+
// `starting` in the same step: a `start()` made from here on begins anew instead
|
|
231
|
+
// of adding its promise to a list nobody settles any more, and a shutdown that
|
|
232
|
+
// finds no start to wait for resolves after these.
|
|
233
|
+
synchronized(lock) {
|
|
234
|
+
val settling = startPromises.toList()
|
|
235
|
+
startPromises.clear()
|
|
236
|
+
if (starting === coroutineContext[Job]) starting = null
|
|
237
|
+
settling.forEach { settle(it, outcome) }
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return promise
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** The start in flight, if any; [shutdown] waits for it. Guarded by [lock]. */
|
|
245
|
+
private var starting: Job? = null
|
|
246
|
+
|
|
247
|
+
/** The wait of the start in flight for the first unlock, which [shutdown] ends. Guarded by [lock]. */
|
|
248
|
+
private var awaitingUnlock: CompletableDeferred<Unit>? = null
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Suspends the start that is run [thisRun] until the device was unlocked for the first time
|
|
252
|
+
* since it started. Before that, in a process Android starts for a `directBootAware`
|
|
253
|
+
* component, nothing the SDK or the TypeScript core stored can be opened: the start waits
|
|
254
|
+
* rather than begin as a fresh install, and reads and writes nothing meanwhile. Captures are
|
|
255
|
+
* held as before any start. A [shutdown] ends the wait, and so does the start of a newer
|
|
256
|
+
* instance; both reject this start with `NOT_INITIALIZED`.
|
|
257
|
+
*/
|
|
258
|
+
private suspend fun awaitFirstUnlock(context: Context, thisRun: Int) {
|
|
259
|
+
if (platform.userUnlocked(context)) return
|
|
260
|
+
val unlocked = CompletableDeferred<Unit>()
|
|
261
|
+
synchronized(lock) {
|
|
262
|
+
if (run != thisRun) throw notInitialized()
|
|
263
|
+
awaitingUnlock = unlocked
|
|
264
|
+
}
|
|
265
|
+
startAwaitingUnlock.getAndSet(unlocked)?.completeExceptionally(notInitialized())
|
|
266
|
+
val announce = { unlocked.complete(Unit); Unit }
|
|
267
|
+
// When Android refuses the unlock receiver, the next activity to start on the unlocked
|
|
268
|
+
// device ends the wait instead.
|
|
269
|
+
val stopWaiting = platform.whenUserUnlocked(context, announce)
|
|
270
|
+
?: whenStartedUnlocked(context, { platform.userUnlocked(context) }, announce)
|
|
271
|
+
try {
|
|
272
|
+
// Unlocked between the check above and the registration: nothing announces it any more.
|
|
273
|
+
if (platform.userUnlocked(context)) unlocked.complete(Unit)
|
|
274
|
+
unlocked.await()
|
|
275
|
+
} finally {
|
|
276
|
+
stopWaiting()
|
|
277
|
+
startAwaitingUnlock.compareAndSet(unlocked, null)
|
|
278
|
+
synchronized(lock) { if (awaitingUnlock === unlocked) awaitingUnlock = null }
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The promises of the start in flight. Guarded by [lock]. */
|
|
283
|
+
private val startPromises = mutableListOf<Promise<Unit>>()
|
|
284
|
+
|
|
285
|
+
/** The start that is run [thisRun]: overtaken by a [shutdown], it starts nothing, or stops what it started. */
|
|
286
|
+
private suspend fun startClient(thisRun: Int) {
|
|
287
|
+
val configuration = synchronized(lock) { configuration }
|
|
288
|
+
?: throw NativeClientException("NOT_INITIALIZED", "configure() was not called")
|
|
289
|
+
if (client?.isClosed == false) return
|
|
290
|
+
val context = contextProvider()?.applicationContext
|
|
291
|
+
?: throw NativeClientException("NOT_INITIALIZED", "The $hostName host has no application context")
|
|
292
|
+
awaitFirstUnlock(context, thisRun)
|
|
293
|
+
|
|
294
|
+
// What the TypeScript core stored is adopted before the SDK reads any of it, and once a
|
|
295
|
+
// client a JavaScript reload left running can no longer write over it.
|
|
296
|
+
withContext(Dispatchers.IO) {
|
|
297
|
+
Voidhash.retireRunningClient()
|
|
298
|
+
LegacyStorageImporter(context, configuration.publishableKey, configuration.baseUrl).import()
|
|
299
|
+
}
|
|
300
|
+
if (synchronized(lock) { run } != thisRun) throw notInitialized()
|
|
301
|
+
// The client this start configures, once there is one: the instance may still hold an
|
|
302
|
+
// earlier start's closed client until then.
|
|
303
|
+
val configured = AtomicReference<VoidhashClient?>(null)
|
|
304
|
+
|
|
305
|
+
val pinned = configuration.distinctId?.takeUnless { distinctIdAdopted }
|
|
306
|
+
// `appStoreMessages` and `purchaseIntents` are StoreKit's; Google Play has nothing they apply to.
|
|
307
|
+
val options = VoidhashOptions(
|
|
308
|
+
baseUrl = configuration.baseUrl,
|
|
309
|
+
ingestUrl = configuration.ingestUrl,
|
|
310
|
+
debug = configuration.debug,
|
|
311
|
+
distinctId = pinned,
|
|
312
|
+
readOnly = readOnly ?: configuration.readOnly,
|
|
313
|
+
dev = configuration.developmentMode,
|
|
314
|
+
// The facade's navigation integrations report screens through `screen()`.
|
|
315
|
+
screenTracking = ScreenTrackingOptions(automatic = false),
|
|
316
|
+
automaticLifecycleEvents = configuration.automaticLifecycleEvents,
|
|
317
|
+
preloadLocations = configuration.preloadLocations.toList(),
|
|
318
|
+
flowRevisions = configuration.flowRevisions.associate { it.location to it.revision.toInt() },
|
|
319
|
+
flowRenderer = VoidhashFlowsCore.linkedRenderer(
|
|
320
|
+
runtimeModules = configuration.flowRuntime == NativeFlowRuntime.MODULE,
|
|
321
|
+
showsLoading = configuration.flowLoading != NativeFlowLoading.NONE,
|
|
322
|
+
),
|
|
323
|
+
flowCapabilities = configuration.flowCapabilities.map(::flowCapability).toSet(),
|
|
324
|
+
flowPermissionHandlers = VoidhashFlowPermissionHandlers.registered(),
|
|
325
|
+
featureFlags = FeatureFlagOptions(
|
|
326
|
+
maxWaitMs = configuration.featureFlagMaxWaitMs?.toLong() ?: FeatureFlagOptions().maxWaitMs,
|
|
327
|
+
defaults = configuration.featureFlagDefaults.orEmpty(),
|
|
328
|
+
),
|
|
329
|
+
onDiagnostic = { diagnostic -> if (isCurrent(thisRun, configured.get())) onDiagnostic(diagnostic) },
|
|
330
|
+
analyticsConsent = consent(configuration.analyticsConsent),
|
|
331
|
+
analyticsWhilePending = when (configuration.analyticsWhilePending) {
|
|
332
|
+
NativePendingAnalytics.DROP -> PendingAnalytics.DROP
|
|
333
|
+
NativePendingAnalytics.BUFFER -> PendingAnalytics.BUFFER
|
|
334
|
+
},
|
|
335
|
+
grantConsentOnIdentify = configuration.grantConsentOnIdentify,
|
|
336
|
+
installAttribution = configuration.installAttribution,
|
|
337
|
+
metaAppId = configuration.metaAppId,
|
|
338
|
+
)
|
|
339
|
+
val started = Voidhash.configure(
|
|
340
|
+
context,
|
|
341
|
+
configuration.publishableKey,
|
|
342
|
+
options,
|
|
343
|
+
platform,
|
|
344
|
+
HostSettings(
|
|
345
|
+
sdkName = sdkName,
|
|
346
|
+
sdkVersion = configuration.sdkVersion,
|
|
347
|
+
onEvent = { event -> if (isCurrent(thisRun, configured.get())) onClientEvent(event) },
|
|
348
|
+
),
|
|
349
|
+
)
|
|
350
|
+
configured.set(started)
|
|
351
|
+
if (pinned != null) distinctIdAdopted = true
|
|
352
|
+
// Chosen in this process before the start: it wins, is stored, and is in effect before
|
|
353
|
+
// anything below captures. The client announces it as the consent `initialize` settles on.
|
|
354
|
+
val chosen = synchronized(lock) { chosenConsent } ?: configuration.chosenAnalyticsConsent
|
|
355
|
+
chosen?.let { started.setAnalyticsConsent(consent(it)) }
|
|
356
|
+
configuration.internalSchemaJson?.let { started.injectInternalSchemaJson(it) }
|
|
357
|
+
val published = synchronized(lock) {
|
|
358
|
+
(run == thisRun).also { current ->
|
|
359
|
+
if (current) {
|
|
360
|
+
// An observer mode set since the options were built found no client to tell:
|
|
361
|
+
// under the lock `setReadOnly` stores it under, so none is missed, and before
|
|
362
|
+
// `initialize` below can scan the store.
|
|
363
|
+
readOnly?.let(started::setReadOnly)
|
|
364
|
+
client = started
|
|
365
|
+
chosenConsent = null
|
|
366
|
+
capturesOpen = false
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
if (!published) {
|
|
371
|
+
// A shutdown overtook this start: what it started does not outlive it.
|
|
372
|
+
started.shutdown()
|
|
373
|
+
throw notInitialized()
|
|
374
|
+
}
|
|
375
|
+
try {
|
|
376
|
+
started.initialize()
|
|
377
|
+
} finally {
|
|
378
|
+
openCaptures(started)
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Hands the captures held since before the start to [started], with their call times. The
|
|
384
|
+
* client records, holds or drops them by the consent it settled on.
|
|
385
|
+
* Under the lock, so a capture made meanwhile cannot overtake them.
|
|
386
|
+
*/
|
|
387
|
+
private fun openCaptures(started: VoidhashClient) {
|
|
388
|
+
synchronized(lock) {
|
|
389
|
+
if (client !== started) return
|
|
390
|
+
for (capture in pendingCaptures) started.capture(capture.name, capture.properties, capture.at)
|
|
391
|
+
pendingCaptures.clear()
|
|
392
|
+
capturesOpen = true
|
|
393
|
+
}
|
|
394
|
+
reportDroppedCaptures()
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** Whether [run] is still this instance's, and its client [started] not retired by another one. */
|
|
398
|
+
private fun isCurrent(run: Int, started: VoidhashClient?): Boolean = run == this.run && started?.isClosed != true
|
|
399
|
+
|
|
400
|
+
override fun shutdown(): Promise<NativeFlushStatus> {
|
|
401
|
+
val promise = Promise<NativeFlushStatus>()
|
|
402
|
+
val (stopping, pending, inFlight) = synchronized(lock) {
|
|
403
|
+
val inFlight = starting
|
|
404
|
+
val stopping = client
|
|
405
|
+
client = null
|
|
406
|
+
heldProducts = emptyMap()
|
|
407
|
+
productsLoads += 1
|
|
408
|
+
capturesOpen = false
|
|
409
|
+
run += 1
|
|
410
|
+
awaitingUnlock?.completeExceptionally(notInitialized())
|
|
411
|
+
val pending = calls
|
|
412
|
+
calls = SupervisorJob()
|
|
413
|
+
callScope = CoroutineScope(calls + callDispatcher)
|
|
414
|
+
Triple(stopping, pending, inFlight)
|
|
415
|
+
}
|
|
416
|
+
lifecycleScope.launch {
|
|
417
|
+
// A start this overtook stops what it started and rejects before this resolves.
|
|
418
|
+
inFlight?.join()
|
|
419
|
+
// Each cancelled call queues its NOT_INITIALIZED rejection before this resolves.
|
|
420
|
+
pending.cancelAndJoin()
|
|
421
|
+
val outcome = runCatching { (stopping?.shutdown() ?: FlushStatus(0, 0)).toNative() }
|
|
422
|
+
settle(promise, outcome)
|
|
423
|
+
}
|
|
424
|
+
return promise
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* `setEventListener()`, with the host's callback as a Kotlin function. The listener is called
|
|
429
|
+
* on the delivery queue, one event at a time, in the order of the promise settlements around
|
|
430
|
+
* them.
|
|
431
|
+
*/
|
|
432
|
+
protected fun setListener(listener: (event: NativeClientEvent) -> Unit) {
|
|
433
|
+
deliver {
|
|
434
|
+
this.listener = listener
|
|
435
|
+
// What happened while nobody listened.
|
|
436
|
+
while (pendingDiagnostics.isNotEmpty()) {
|
|
437
|
+
val diagnostic = pendingDiagnostics.removeFirst()
|
|
438
|
+
runCatching { listener(event(NativeClientEventType.DIAGNOSTIC, diagnostic = diagnostic)) }
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
reportDroppedCaptures()
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/** Reports the captures dropped before the start, once a listener is there to hear it. */
|
|
445
|
+
private fun reportDroppedCaptures() {
|
|
446
|
+
deliver {
|
|
447
|
+
val current = listener ?: return@deliver
|
|
448
|
+
val dropped = synchronized(lock) { droppedBeforeStart.also { droppedBeforeStart = 0 } }
|
|
449
|
+
if (dropped == 0) return@deliver
|
|
450
|
+
val diagnostic = NativeDiagnostic(
|
|
451
|
+
NativeDiagnosticKind.EVICTION,
|
|
452
|
+
"ANALYTICS_EVENT_DROPPED",
|
|
453
|
+
"analytics.capture",
|
|
454
|
+
false,
|
|
455
|
+
null,
|
|
456
|
+
"Dropped the $dropped oldest events captured before the client finished starting: " +
|
|
457
|
+
"at most $PRE_START_CAPTURE_LIMIT are kept",
|
|
458
|
+
)
|
|
459
|
+
current(event(NativeClientEventType.DIAGNOSTIC, diagnostic = diagnostic))
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
override fun removeEventListener() {
|
|
464
|
+
deliver { listener = null }
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// ---- Identity and person ----
|
|
468
|
+
|
|
469
|
+
override fun getDistinctId(): Promise<String> = call { it.getDistinctId() }
|
|
470
|
+
|
|
471
|
+
override fun identify(externalUserId: String, email: String?, name: String?): Promise<NativeIdentifyResult> =
|
|
472
|
+
call(ordered = true) { client ->
|
|
473
|
+
val previous = client.getDistinctId()
|
|
474
|
+
val identified = client.identifyForHost(externalUserId, email, name)
|
|
475
|
+
NativeIdentifyResult(
|
|
476
|
+
identity = NativeIdentityChange(identified.distinctId, previous, identified.generation.toDouble()),
|
|
477
|
+
status = writeStatus(identified.result.status),
|
|
478
|
+
personJson = identified.result.person?.raw?.toString(),
|
|
479
|
+
)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
override fun reset(): Promise<NativeIdentityChange> = switchToAnonymous(signOut = false)
|
|
483
|
+
|
|
484
|
+
override fun signOut(): Promise<NativeIdentityChange> = switchToAnonymous(signOut = true)
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* The client's `reset()` or `signOut()`. The identity switches at once; what a person who
|
|
488
|
+
* was signed out left queued goes out after. Replacing an anonymous visitor, or signing out
|
|
489
|
+
* nobody, sends nothing.
|
|
490
|
+
*/
|
|
491
|
+
private fun switchToAnonymous(signOut: Boolean): Promise<NativeIdentityChange> = call(ordered = true) { client ->
|
|
492
|
+
val previous = client.getDistinctId()
|
|
493
|
+
val distinctId = client.switchToAnonymous(signOut)
|
|
494
|
+
if (distinctId != previous && !isAnonymousDistinctId(previous)) client.flush()
|
|
495
|
+
NativeIdentityChange(distinctId, previous, client.identityGeneration.toDouble())
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
override fun group(groupType: String, groupKey: String, propertiesJson: String?): Promise<Unit> =
|
|
499
|
+
call(ordered = true) { client ->
|
|
500
|
+
invalidGroupReason(groupType, groupKey)?.let { throw NativeClientException("INVALID_ARGUMENT", it) }
|
|
501
|
+
val properties = propertiesJson?.let { json ->
|
|
502
|
+
val document = try {
|
|
503
|
+
JSONObject(json)
|
|
504
|
+
} catch (error: Exception) {
|
|
505
|
+
throw NativeClientException("INVALID_ARGUMENT", "Group properties are not a JSON object")
|
|
506
|
+
}
|
|
507
|
+
jsonMap(document)
|
|
508
|
+
}
|
|
509
|
+
client.group(groupType, groupKey, properties)
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
override fun setGroups(groupsJson: String): Promise<Unit> = call(ordered = true) { client ->
|
|
513
|
+
val document = try {
|
|
514
|
+
JSONObject(groupsJson)
|
|
515
|
+
} catch (error: Exception) {
|
|
516
|
+
throw NativeClientException("INVALID_ARGUMENT", "Groups are not a JSON object")
|
|
517
|
+
}
|
|
518
|
+
client.setGroups(
|
|
519
|
+
document.keys().asSequence().associateWith { type ->
|
|
520
|
+
val group = document.optJSONObject(type)
|
|
521
|
+
?: throw NativeClientException("INVALID_ARGUMENT", "Group \"$type\" is not a JSON object")
|
|
522
|
+
val id = group.opt("id") as? String
|
|
523
|
+
?: throw NativeClientException("INVALID_ARGUMENT", "Group \"$type\" has no string id")
|
|
524
|
+
VoidhashGroup(id, group.optJSONObject("properties")?.let(::jsonMap).orEmpty())
|
|
525
|
+
},
|
|
526
|
+
)
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
override fun resetGroups(): Promise<Unit> = call(ordered = true) { it.resetGroups() }
|
|
530
|
+
|
|
531
|
+
override fun getGroups(): Map<String, String> = client?.takeUnless { it.isClosed }?.groups.orEmpty()
|
|
532
|
+
|
|
533
|
+
override fun setPersonAttributes(attributesJson: String): Promise<Unit> = call(ordered = true) { client ->
|
|
534
|
+
// Resolves once queued for the identity in effect; the network is not waited on.
|
|
535
|
+
client.queuePersonAttributes(attributes(attributesJson), null, null)
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
override fun setPersonAttributesState(attributesJson: String): Promise<NativePersonWriteResult> = call(ordered = true) { client ->
|
|
539
|
+
val result = client.setPersonAttributesWithStatus(attributes(attributesJson), null, null)
|
|
540
|
+
NativePersonWriteResult(writeStatus(result.status), result.person?.raw?.toString())
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
override fun getPersonState(forceFetch: Boolean): Promise<NativePersonState> =
|
|
544
|
+
call { client -> client.readPerson(forceFetch, surfaceAuthFailure = true).toNative() }
|
|
545
|
+
|
|
546
|
+
override fun resetPersonCache(): Promise<Unit> = call { it.resetPersonCache() }
|
|
547
|
+
|
|
548
|
+
// ---- Flags, paywalls and products ----
|
|
549
|
+
|
|
550
|
+
override fun getFeatureFlags(flagKeys: Array<String>?): Promise<NativeFeatureFlagsResult> = call { client ->
|
|
551
|
+
client.readFlags(flagKeys?.toList().orEmpty(), surfaceAuthFailure = true).state.toNative()
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
override fun getPaywall(location: String): Promise<String> = call { it.resolvePaywallJson(location) }
|
|
555
|
+
|
|
556
|
+
override fun getProducts(): Promise<Array<NativeProduct>> {
|
|
557
|
+
val load = synchronized(lock) { ++productsLoads }
|
|
558
|
+
return call { client ->
|
|
559
|
+
val products = client.getProducts()
|
|
560
|
+
synchronized(lock) {
|
|
561
|
+
// A load that a shutdown, a later load or a purchase overtook is not held: it
|
|
562
|
+
// belongs to a client no longer started, or answers for outdated offers.
|
|
563
|
+
if (this.client === client && productsLoads == load) {
|
|
564
|
+
heldProducts = products.associateBy { it.slug }
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
products.map { it.toNative() }.toTypedArray()
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* The products [slugs] name: the ones held, and Google Play's answer now for the others, `null`
|
|
573
|
+
* where it sells none.
|
|
574
|
+
*/
|
|
575
|
+
private suspend fun products(client: VoidhashClient, slugs: List<String>): List<VoidhashProduct?> {
|
|
576
|
+
val held = synchronized(lock) { heldProducts }
|
|
577
|
+
val missing = slugs.filterNot(held::containsKey).distinct()
|
|
578
|
+
val loaded = if (missing.isEmpty()) emptyMap() else missing.zip(client.getProducts(missing)).toMap()
|
|
579
|
+
return slugs.map { held[it] ?: loaded[it] }
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Forgets the products held, and any load running, after a purchase or a restore: what the end
|
|
584
|
+
* user bought can change the offers they are eligible for. Until the facade loads them again,
|
|
585
|
+
* [purchase] asks Google Play for the products it buys.
|
|
586
|
+
*/
|
|
587
|
+
private fun dropHeldProducts() {
|
|
588
|
+
synchronized(lock) {
|
|
589
|
+
heldProducts = emptyMap()
|
|
590
|
+
productsLoads += 1
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
// ---- Purchases ----
|
|
595
|
+
|
|
596
|
+
override fun purchase(productSlug: String, options: NativePurchaseOptions): Promise<NativePurchaseResult> = call { client ->
|
|
597
|
+
// Refused before Google Play is touched, as the client itself refuses it.
|
|
598
|
+
if (client.isReadOnly) {
|
|
599
|
+
throw NativeClientException(
|
|
600
|
+
"READ_ONLY_PURCHASE_NOT_ALLOWED",
|
|
601
|
+
"Read-only mode is enabled. Purchasing is disabled for observer-only operation.",
|
|
602
|
+
)
|
|
603
|
+
}
|
|
604
|
+
// The products the last load answered, as the App Store bridge buys them; Google Play is
|
|
605
|
+
// asked only for one not held. The replaced one is named by its slug as the bought one is.
|
|
606
|
+
val loaded = products(client, listOfNotNull(productSlug, options.replacing?.productSlug))
|
|
607
|
+
fun current(index: Int, slug: String) = loaded[index]
|
|
608
|
+
?: throw NativeClientException("INVALID_ARGUMENT", "No product \"$slug\" can be bought on Google Play")
|
|
609
|
+
val product = current(0, productSlug)
|
|
610
|
+
val replacing = options.replacing?.let { SubscriptionReplacement(current(1, it.productSlug), replacementMode(it.mode)) }
|
|
611
|
+
val quantity = options.quantity.toInt().takeIf { it >= 1 && it.toDouble() == options.quantity }
|
|
612
|
+
?: throw NativeClientException("INVALID_ARGUMENT", "The quantity ${options.quantity} is not a positive whole number")
|
|
613
|
+
// The App Store options are StoreKit's; Google Play has nothing to apply them to.
|
|
614
|
+
val purchaseOptions = VoidhashPurchaseOptions(
|
|
615
|
+
offer = offerSelection(product, options),
|
|
616
|
+
quantity = quantity,
|
|
617
|
+
replacing = replacing,
|
|
618
|
+
googlePlay = options.googlePlay?.let {
|
|
619
|
+
GooglePlayPurchaseOptions(it.isOfferPersonalized, it.obfuscatedProfileId, it.offerToken)
|
|
620
|
+
},
|
|
621
|
+
)
|
|
622
|
+
val activity = requireActivity()
|
|
623
|
+
val result = try {
|
|
624
|
+
client.purchase(activity, product, purchaseOptions)
|
|
625
|
+
} catch (error: VoidhashPurchaseException) {
|
|
626
|
+
// The store's reason is the code the facade reads it from.
|
|
627
|
+
val reason = when (error.reason) {
|
|
628
|
+
PurchaseFailureReason.PAYMENT_DECLINED -> "PAYMENT_DECLINED"
|
|
629
|
+
PurchaseFailureReason.INELIGIBLE_FOR_OFFER -> "INELIGIBLE_FOR_OFFER".also { dropHeldProducts() }
|
|
630
|
+
null -> throw error
|
|
631
|
+
}
|
|
632
|
+
throw NativeClientException(reason, error.description, error)
|
|
633
|
+
}
|
|
634
|
+
when (result) {
|
|
635
|
+
is VoidhashPurchaseResult.Purchased -> {
|
|
636
|
+
dropHeldProducts()
|
|
637
|
+
NativePurchaseResult(NativePurchaseOutcome.PURCHASED, result.transaction.toNative(), result.synced)
|
|
638
|
+
}
|
|
639
|
+
VoidhashPurchaseResult.Pending -> NativePurchaseResult(NativePurchaseOutcome.PENDING, null, null)
|
|
640
|
+
VoidhashPurchaseResult.Cancelled -> NativePurchaseResult(NativePurchaseOutcome.CANCELLED, null, null)
|
|
641
|
+
// Only a client the SDK made inert, as in a secondary process; the facade's own
|
|
642
|
+
// `enabled: false` never reaches the native client. Reported as on iOS, as a client
|
|
643
|
+
// that is not started.
|
|
644
|
+
VoidhashPurchaseResult.Disabled ->
|
|
645
|
+
throw NativeClientException("NOT_INITIALIZED", "Voidhash is inert in this process; nothing was bought")
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
override fun restorePurchases(): Promise<NativePersonState> = call { client ->
|
|
650
|
+
client.restorePurchases()
|
|
651
|
+
dropHeldProducts()
|
|
652
|
+
// What the restore cached, with the freshness and generation it is read under.
|
|
653
|
+
client.readPerson(forceFetch = false).toNative()
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
override fun syncPurchases(): Promise<Unit> = call { it.syncPurchases() }
|
|
657
|
+
|
|
658
|
+
override fun reportTransaction(transaction: NativeReportedTransaction, isRestore: Boolean): Promise<Unit> = call { client ->
|
|
659
|
+
if (transaction.platform != NativeStorePlatform.GOOGLEPLAY) {
|
|
660
|
+
throw NativeClientException("UNSUPPORTED_PLATFORM", "Only Google Play purchases can be reported on Android")
|
|
661
|
+
}
|
|
662
|
+
val token = transaction.purchaseToken?.takeIf { it.isNotBlank() }
|
|
663
|
+
?: throw NativeClientException("INVALID_ARGUMENT", "A Google Play purchase token is required")
|
|
664
|
+
// A pending or unspecified purchase is ignored; the integration reports it again once purchased.
|
|
665
|
+
val state = transaction.purchaseState ?: NativeReportedPurchaseState.PURCHASED
|
|
666
|
+
if (state == NativeReportedPurchaseState.PURCHASED) client.reportTransaction(token, isRestore)
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
// ---- Store actions, both stores ----
|
|
670
|
+
|
|
671
|
+
override fun showManageSubscriptions(productSlug: String?): Promise<Unit> = call { client ->
|
|
672
|
+
val activity = requireActivity()
|
|
673
|
+
// A product Google Play does not return opens the list of every subscription instead.
|
|
674
|
+
val product = productSlug?.let { products(client, listOf(it)).single() }
|
|
675
|
+
client.showManageSubscriptions(activity, product)
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
override fun presentCodeRedemption(code: String?): Promise<Unit> = call { client ->
|
|
679
|
+
client.presentCodeRedemption(requireActivity(), code)
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
override fun getStorefront(): Promise<NativeStorefront?> = call { client ->
|
|
683
|
+
client.getStorefront()?.let { NativeStorefront(it.countryCode, it.currencyCode) }
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
override fun canMakePayments(): Promise<Boolean> = call { it.canMakePayments() }
|
|
687
|
+
|
|
688
|
+
// ---- App Store ----
|
|
689
|
+
|
|
690
|
+
override fun appStoreBeginRefundRequest(transactionId: String): Promise<NativeRefundRequestStatus> =
|
|
691
|
+
rejected(appStoreOnly("Refund requests"))
|
|
692
|
+
|
|
693
|
+
override fun appStoreSubscriptionStatus(groupId: String): Promise<Array<NativeAppStoreSubscriptionStatus>> =
|
|
694
|
+
rejected(appStoreOnly("Subscription statuses"))
|
|
695
|
+
|
|
696
|
+
override fun appStoreCurrentEntitlements(): Promise<Array<NativeTransaction>> =
|
|
697
|
+
rejected(appStoreOnly("Current entitlements"))
|
|
698
|
+
|
|
699
|
+
override fun appStoreAppTransaction(): Promise<String> = rejected(appStoreOnly("The app transaction"))
|
|
700
|
+
|
|
701
|
+
private fun appStoreOnly(what: String) = NativeClientException("UNSUPPORTED_PLATFORM", "$what are an App Store feature")
|
|
702
|
+
|
|
703
|
+
// ---- Google Play ----
|
|
704
|
+
|
|
705
|
+
override fun googlePlayShowInAppMessages(): Promise<NativeInAppMessageResult> = call { client ->
|
|
706
|
+
when (val result = client.googlePlay.showInAppMessages(requireActivity())) {
|
|
707
|
+
GooglePlayInAppMessageResult.NoActionNeeded ->
|
|
708
|
+
NativeInAppMessageResult(NativeInAppMessageStatus.NOACTIONNEEDED, null)
|
|
709
|
+
is GooglePlayInAppMessageResult.SubscriptionStatusUpdated ->
|
|
710
|
+
NativeInAppMessageResult(NativeInAppMessageStatus.SUBSCRIPTIONSTATUSUPDATED, result.purchaseToken)
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
override fun googlePlayQueryPurchases(includeSuspended: Boolean): Promise<Array<NativeTransaction>> = call { client ->
|
|
715
|
+
client.googlePlay.queryPurchases(includeSuspended).map { it.toNative() }.toTypedArray()
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
override fun googlePlayIsFeatureSupported(feature: String): Promise<Boolean> = call { client ->
|
|
719
|
+
val featureType = when (feature) {
|
|
720
|
+
"subscriptions" -> BillingClient.FeatureType.SUBSCRIPTIONS
|
|
721
|
+
"subscriptionsUpdate" -> BillingClient.FeatureType.SUBSCRIPTIONS_UPDATE
|
|
722
|
+
"inAppMessaging" -> BillingClient.FeatureType.IN_APP_MESSAGING
|
|
723
|
+
"productDetails" -> BillingClient.FeatureType.PRODUCT_DETAILS
|
|
724
|
+
"billingConfig" -> BillingClient.FeatureType.BILLING_CONFIG
|
|
725
|
+
"alternativeBillingOnly" -> BillingClient.FeatureType.ALTERNATIVE_BILLING_ONLY
|
|
726
|
+
"externalOffer" -> BillingClient.FeatureType.EXTERNAL_OFFER
|
|
727
|
+
else -> throw NativeClientException("INVALID_ARGUMENT", "\"$feature\" is not a Google Play billing feature")
|
|
728
|
+
}
|
|
729
|
+
client.googlePlay.isFeatureSupported(featureType)
|
|
730
|
+
}
|
|
731
|
+
|
|
732
|
+
// ---- Configuration at runtime ----
|
|
733
|
+
|
|
734
|
+
override fun setAnalyticsConsent(consent: NativeAnalyticsConsent): Promise<Boolean> {
|
|
735
|
+
// Before the start there is nothing to store it in: `start()` applies and stores it. A
|
|
736
|
+
// denial discards what was captured so far, as it does on a running client.
|
|
737
|
+
val running = synchronized(lock) {
|
|
738
|
+
client?.takeUnless { it.isClosed } ?: run {
|
|
739
|
+
chosenConsent = consent
|
|
740
|
+
if (consent == NativeAnalyticsConsent.DENIED) {
|
|
741
|
+
pendingCaptures.clear()
|
|
742
|
+
droppedBeforeStart = 0
|
|
743
|
+
}
|
|
744
|
+
null
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
if (running == null) {
|
|
748
|
+
val promise = Promise<Boolean>()
|
|
749
|
+
deliver { promise.resolve(false) }
|
|
750
|
+
return promise
|
|
751
|
+
}
|
|
752
|
+
return call { client ->
|
|
753
|
+
client.setAnalyticsConsent(consent(consent))
|
|
754
|
+
true
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
override fun getAnalyticsConsent(): NativeAnalyticsConsent {
|
|
759
|
+
client?.takeUnless { it.isClosed }?.let { return nativeConsent(it.analyticsConsent) }
|
|
760
|
+
val configuration = synchronized(lock) { chosenConsent?.let { return it }; configuration }
|
|
761
|
+
return configuration?.chosenAnalyticsConsent ?: configuration?.analyticsConsent ?: NativeAnalyticsConsent.GRANTED
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
override fun setReadOnly(readOnly: Boolean) {
|
|
765
|
+
// The client is read under the lock the start publishes it under: either this call sees
|
|
766
|
+
// it, or the start sees what this call stored.
|
|
767
|
+
val running = synchronized(lock) {
|
|
768
|
+
this.readOnly = readOnly
|
|
769
|
+
client
|
|
770
|
+
}
|
|
771
|
+
running?.setReadOnly(readOnly)
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
override fun isReadOnly(): Boolean =
|
|
775
|
+
client?.takeUnless { it.isClosed }?.isReadOnly ?: synchronized(lock) { readOnly ?: configuration?.readOnly ?: false }
|
|
776
|
+
|
|
777
|
+
// ---- Analytics ----
|
|
778
|
+
|
|
779
|
+
override fun capture(eventName: String, propertiesJson: String) {
|
|
780
|
+
intake(eventName, propertiesJson, operation = "analytics.capture")
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
override fun screen(name: String, propertiesJson: String) {
|
|
784
|
+
if (synchronized(lock) { configuration?.screenTrackingEnabled } == false) return
|
|
785
|
+
// The facade already mapped the screen into its `$screen_*` properties: recorded as they are.
|
|
786
|
+
intake(AutomaticEvents.SCREEN, propertiesJson, operation = "analytics.screen")
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
override fun captureAt(eventName: String, propertiesJson: String, capturedAt: Double) {
|
|
790
|
+
intake(eventName, propertiesJson, operation = "analytics.capture", capturedAt = capturedAt.toLong())
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
override fun screenAt(name: String, propertiesJson: String, capturedAt: Double) {
|
|
794
|
+
if (synchronized(lock) { configuration?.screenTrackingEnabled } == false) return
|
|
795
|
+
intake(AutomaticEvents.SCREEN, propertiesJson, operation = "analytics.screen", capturedAt = capturedAt.toLong())
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* Stamps and queues an event on the calling thread; never throws. [capturedAt] is the time of
|
|
800
|
+
* an event the facade held back, in epoch millis; the time of this call without it.
|
|
801
|
+
*/
|
|
802
|
+
private fun intake(name: String, propertiesJson: String, operation: String, capturedAt: Long? = null) {
|
|
803
|
+
try {
|
|
804
|
+
val properties = jsonMap(JSONObject(propertiesJson))
|
|
805
|
+
val now = capturedAt ?: System.currentTimeMillis()
|
|
806
|
+
val running = synchronized(lock) {
|
|
807
|
+
val running = client?.takeUnless { it.isClosed || !capturesOpen }
|
|
808
|
+
if (running == null) {
|
|
809
|
+
pendingCaptures.addLast(PendingCapture(name, properties, now))
|
|
810
|
+
if (pendingCaptures.size > PRE_START_CAPTURE_LIMIT) {
|
|
811
|
+
pendingCaptures.removeFirst()
|
|
812
|
+
droppedBeforeStart += 1
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
running
|
|
816
|
+
} ?: return
|
|
817
|
+
running.capture(name, properties, now)
|
|
818
|
+
} catch (error: Throwable) {
|
|
819
|
+
onDiagnostic(
|
|
820
|
+
VoidhashDiagnostic(
|
|
821
|
+
VoidhashDiagnosticKind.EVICTION,
|
|
822
|
+
"ANALYTICS_EVENT_DROPPED",
|
|
823
|
+
operation,
|
|
824
|
+
message = "Dropped \"$name\": ${error.message}",
|
|
825
|
+
),
|
|
826
|
+
)
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
override fun flush(): Promise<NativeFlushStatus> = call { it.flush().toNative() }
|
|
831
|
+
|
|
832
|
+
/** Empty when there is no session: reading must not start one, as the SDK's own `sessionId` does. */
|
|
833
|
+
override fun getSessionId(): String = client?.takeUnless { it.isClosed }?.activeSessionId.orEmpty()
|
|
834
|
+
|
|
835
|
+
// ---- Flows ----
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* `presentFlow()`: presents the flow at [location] through the SDK and resolves with how it
|
|
839
|
+
* ended, or with why it could not be presented, as JSON. Each action [presentation] lists is
|
|
840
|
+
* answered by [answerAction], which returns JavaScript's reply; a call JavaScript rejects, and
|
|
841
|
+
* one it has no handler for, fail in the flow as they do in a native app.
|
|
842
|
+
*/
|
|
843
|
+
protected fun presentFlowAnswering(
|
|
844
|
+
location: String,
|
|
845
|
+
presentation: NativeFlowPresentation,
|
|
846
|
+
answerAction: suspend (name: String, argsJson: String) -> String,
|
|
847
|
+
): Promise<String> = call { client ->
|
|
848
|
+
val activity = usableActivity()
|
|
849
|
+
?: return@call VoidhashFlowsCore.encode(
|
|
850
|
+
VoidhashFlowsCore.failed(FlowFailure.UNAVAILABLE, "The $hostName host has no current activity"),
|
|
851
|
+
)
|
|
852
|
+
try {
|
|
853
|
+
val result = client.presentFlow(
|
|
854
|
+
activity,
|
|
855
|
+
location,
|
|
856
|
+
revision = presentation.revision?.toInt(),
|
|
857
|
+
input = VoidhashFlowsCore.flowValues(presentation.inputJson),
|
|
858
|
+
actions = VoidhashFlowsCore.actionHandlers(presentation.actions, answerAction),
|
|
859
|
+
)
|
|
860
|
+
// A flow that ended in a purchase or a restore outdates the products held.
|
|
861
|
+
if (result.outcome == FlowResult.PURCHASED || result.outcome == FlowResult.RESTORED) dropHeldProducts()
|
|
862
|
+
VoidhashFlowsCore.encode(result)
|
|
863
|
+
} catch (error: FlowException) {
|
|
864
|
+
VoidhashFlowsCore.encode(error)
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
override fun updateFlowInput(valuesJson: String): Promise<Unit> =
|
|
869
|
+
call { it.updateFlowInput(VoidhashFlowsCore.flowValues(valuesJson)) }
|
|
870
|
+
|
|
871
|
+
override fun dismissFlow(): Promise<Unit> = call { it.dismissFlow() }
|
|
872
|
+
|
|
873
|
+
/** The host's current activity, unless it is finishing or gone. */
|
|
874
|
+
private fun usableActivity(): Activity? =
|
|
875
|
+
activityProvider()?.takeUnless { it.isFinishing || it.isDestroyed }
|
|
876
|
+
|
|
877
|
+
private fun requireActivity(): Activity =
|
|
878
|
+
usableActivity() ?: throw NativeClientException("CURRENT_ACTIVITY_NULL", "The $hostName host has no current activity")
|
|
879
|
+
|
|
880
|
+
// ---- Bridging ----
|
|
881
|
+
|
|
882
|
+
/** Runs [block] on the delivery queue, after everything queued before it. */
|
|
883
|
+
private fun deliver(block: () -> Unit) {
|
|
884
|
+
delivery.execute {
|
|
885
|
+
try {
|
|
886
|
+
block()
|
|
887
|
+
} catch (_: Throwable) {
|
|
888
|
+
// A listener that throws must not stop later deliveries.
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
private fun <T> settle(promise: Promise<T>, outcome: Result<T>) {
|
|
894
|
+
deliver { outcome.fold({ promise.resolve(it) }, { promise.reject(rejection(it)) }) }
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
private fun <T> rejected(error: Throwable): Promise<T> = Promise<T>().also { settle(it, Result.failure(error)) }
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* Runs one call against the started client. Its promise settles on the delivery queue, after
|
|
901
|
+
* the events the call caused; a call [shutdown] cancels rejects with `NOT_INITIALIZED`.
|
|
902
|
+
*/
|
|
903
|
+
private fun <T> call(ordered: Boolean = false, block: suspend (VoidhashClient) -> T): Promise<T> {
|
|
904
|
+
val promise = Promise<T>()
|
|
905
|
+
val (running, scope) = synchronized(lock) { client?.takeUnless { it.isClosed } to callScope }
|
|
906
|
+
if (running == null) {
|
|
907
|
+
settle(promise, Result.failure(notInitialized()))
|
|
908
|
+
return promise
|
|
909
|
+
}
|
|
910
|
+
// An ordered call queues for [identityOrder] on the calling thread, so calls take it in
|
|
911
|
+
// the order they were made; the work itself runs off that thread. Neither start can be
|
|
912
|
+
// cancelled before the body runs: a call [shutdown] cancels before it was dispatched, or
|
|
913
|
+
// launched into a scope [shutdown] has just cancelled, still reaches its settlement below.
|
|
914
|
+
scope.launch(start = if (ordered) CoroutineStart.UNDISPATCHED else CoroutineStart.ATOMIC) {
|
|
915
|
+
val outcome = try {
|
|
916
|
+
// Cancelled before it started: nothing of the call runs, and it rejects below.
|
|
917
|
+
ensureActive()
|
|
918
|
+
Result.success(
|
|
919
|
+
if (ordered) {
|
|
920
|
+
identityOrder.withLock { withContext(Dispatchers.Default) { block(running) } }
|
|
921
|
+
} else {
|
|
922
|
+
block(running)
|
|
923
|
+
},
|
|
924
|
+
)
|
|
925
|
+
} catch (error: CancellationException) {
|
|
926
|
+
Result.failure(notInitialized())
|
|
927
|
+
} catch (error: Throwable) {
|
|
928
|
+
Result.failure(if (running.isClosed) notInitialized() else error)
|
|
929
|
+
}
|
|
930
|
+
settle(promise, outcome)
|
|
931
|
+
}
|
|
932
|
+
return promise
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
private fun notInitialized() = NativeClientException("NOT_INITIALIZED", "The Voidhash client is not started")
|
|
936
|
+
|
|
937
|
+
/** The error JavaScript reads `"<CODE>: <detail>"` from. */
|
|
938
|
+
private fun rejection(error: Throwable): Throwable = when (error) {
|
|
939
|
+
is NativeClientException -> error
|
|
940
|
+
is VoidhashException ->
|
|
941
|
+
if (error.code == "CLIENT_SHUT_DOWN") notInitialized() else NativeClientException(error.code, error.description, error)
|
|
942
|
+
else -> NativeClientException("UNKNOWN_ERROR", error.message ?: error.javaClass.simpleName, error)
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
private fun onClientEvent(event: ClientEvent) {
|
|
946
|
+
val native = when (event) {
|
|
947
|
+
is ClientEvent.Identity -> event(
|
|
948
|
+
NativeClientEventType.IDENTITY,
|
|
949
|
+
identity = NativeIdentityChange(event.distinctId, event.previousDistinctId, event.generation.toDouble()),
|
|
950
|
+
)
|
|
951
|
+
is ClientEvent.Person -> event(NativeClientEventType.PERSON, person = event.state.toNative())
|
|
952
|
+
is ClientEvent.Flags -> event(NativeClientEventType.FLAGS, flags = event.state.toNative())
|
|
953
|
+
is ClientEvent.Schema -> event(NativeClientEventType.SCHEMA, schemaJson = event.json)
|
|
954
|
+
is ClientEvent.Consent -> event(NativeClientEventType.CONSENT, consent = nativeConsent(event.consent))
|
|
955
|
+
is ClientEvent.Transaction -> {
|
|
956
|
+
// Google Play reports no renewals, but a renewal would change no offer.
|
|
957
|
+
if (event.update.transaction.isRenewal != true) dropHeldProducts()
|
|
958
|
+
event(
|
|
959
|
+
NativeClientEventType.TRANSACTION,
|
|
960
|
+
transaction = NativeTransactionUpdate(event.update.transaction.toNative(), event.update.synced),
|
|
961
|
+
)
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
deliver { listener?.invoke(native) }
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
private fun onDiagnostic(diagnostic: VoidhashDiagnostic) {
|
|
968
|
+
val native = NativeDiagnostic(
|
|
969
|
+
kind = when (diagnostic.kind) {
|
|
970
|
+
VoidhashDiagnosticKind.TRANSPORT -> NativeDiagnosticKind.TRANSPORT
|
|
971
|
+
VoidhashDiagnosticKind.EVICTION -> NativeDiagnosticKind.EVICTION
|
|
972
|
+
VoidhashDiagnosticKind.BREAKER -> NativeDiagnosticKind.BREAKER
|
|
973
|
+
VoidhashDiagnosticKind.AUTH -> NativeDiagnosticKind.AUTH
|
|
974
|
+
VoidhashDiagnosticKind.CACHE -> NativeDiagnosticKind.CACHE
|
|
975
|
+
VoidhashDiagnosticKind.CONSENT -> NativeDiagnosticKind.CONSENT
|
|
976
|
+
VoidhashDiagnosticKind.STORE -> NativeDiagnosticKind.CONFIGURATION
|
|
977
|
+
},
|
|
978
|
+
code = diagnostic.code,
|
|
979
|
+
// The contract names a product load after the facade method that makes it.
|
|
980
|
+
operation = if (diagnostic.operation == "products.load") "getProducts" else diagnostic.operation,
|
|
981
|
+
retryable = diagnostic.retryable,
|
|
982
|
+
httpStatus = diagnostic.httpStatus?.toDouble(),
|
|
983
|
+
message = diagnostic.message,
|
|
984
|
+
)
|
|
985
|
+
deliver {
|
|
986
|
+
val current = listener
|
|
987
|
+
if (current != null) {
|
|
988
|
+
current(event(NativeClientEventType.DIAGNOSTIC, diagnostic = native))
|
|
989
|
+
} else {
|
|
990
|
+
pendingDiagnostics.addLast(native)
|
|
991
|
+
if (pendingDiagnostics.size > PRE_LISTENER_DIAGNOSTIC_LIMIT) pendingDiagnostics.removeFirst()
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
private fun event(
|
|
997
|
+
type: NativeClientEventType,
|
|
998
|
+
identity: NativeIdentityChange? = null,
|
|
999
|
+
person: NativePersonState? = null,
|
|
1000
|
+
flags: NativeFeatureFlagsResult? = null,
|
|
1001
|
+
schemaJson: String? = null,
|
|
1002
|
+
consent: NativeAnalyticsConsent? = null,
|
|
1003
|
+
diagnostic: NativeDiagnostic? = null,
|
|
1004
|
+
transaction: NativeTransactionUpdate? = null,
|
|
1005
|
+
) = NativeClientEvent(type, identity, person, flags, schemaJson, consent, diagnostic, transaction, null)
|
|
1006
|
+
|
|
1007
|
+
/**
|
|
1008
|
+
* Person attributes with flat values only; `INVALID_ARGUMENT` otherwise. The client itself
|
|
1009
|
+
* sends an `email` and a `name` as the person's own.
|
|
1010
|
+
*/
|
|
1011
|
+
private fun attributes(json: String): Map<String, Any?> {
|
|
1012
|
+
val document = try {
|
|
1013
|
+
JSONObject(json)
|
|
1014
|
+
} catch (error: Exception) {
|
|
1015
|
+
throw NativeClientException("INVALID_ARGUMENT", "Person attributes are not a JSON object")
|
|
1016
|
+
}
|
|
1017
|
+
val values = jsonMap(document)
|
|
1018
|
+
val nested = values.filterValues { !isScalarTraitValue(it) }.keys
|
|
1019
|
+
if (nested.isNotEmpty()) {
|
|
1020
|
+
throw NativeClientException(
|
|
1021
|
+
"INVALID_ARGUMENT",
|
|
1022
|
+
"Person traits must be strings, numbers, booleans or null: ${nested.joinToString()} is not",
|
|
1023
|
+
)
|
|
1024
|
+
}
|
|
1025
|
+
return values
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
private fun PersonState.toNative() = NativePersonState(
|
|
1030
|
+
distinctId = distinctId,
|
|
1031
|
+
generation = generation.toDouble(),
|
|
1032
|
+
personJson = person?.raw?.toString(),
|
|
1033
|
+
isStale = isStale,
|
|
1034
|
+
isExpired = isExpired,
|
|
1035
|
+
reason = when (reason) {
|
|
1036
|
+
FreshnessReason.FRESH -> NativeFreshnessReason.FRESH
|
|
1037
|
+
FreshnessReason.REFRESH_IN_FLIGHT -> NativeFreshnessReason.REFRESHINFLIGHT
|
|
1038
|
+
FreshnessReason.REFRESH_FAILED -> NativeFreshnessReason.REFRESHFAILED
|
|
1039
|
+
FreshnessReason.NO_CACHE -> NativeFreshnessReason.NOCACHE
|
|
1040
|
+
},
|
|
1041
|
+
)
|
|
1042
|
+
|
|
1043
|
+
private fun FlagsState.toNative() = NativeFeatureFlagsResult(
|
|
1044
|
+
distinctId = distinctId,
|
|
1045
|
+
generation = generation.toDouble(),
|
|
1046
|
+
flagKeys = keys?.toTypedArray(),
|
|
1047
|
+
flags = flags.map { it.toNative() }.toTypedArray(),
|
|
1048
|
+
isStale = isStale,
|
|
1049
|
+
)
|
|
1050
|
+
|
|
1051
|
+
private fun FeatureFlag.toNative() = NativeFeatureFlag(key, enabled, variantKey, payload?.let(::jsonValue))
|
|
1052
|
+
|
|
1053
|
+
private fun FlushStatus.toNative() = NativeFlushStatus(flushed.toDouble(), pending.toDouble(), lastError)
|
|
1054
|
+
|
|
1055
|
+
private fun writeStatus(status: WriteStatus) = when (status) {
|
|
1056
|
+
WriteStatus.CONFIRMED -> NativeWriteStatus.CONFIRMED
|
|
1057
|
+
WriteStatus.DEFERRED -> NativeWriteStatus.DEFERRED
|
|
1058
|
+
WriteStatus.SKIPPED -> NativeWriteStatus.SKIPPED
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
private fun consent(consent: NativeAnalyticsConsent) = when (consent) {
|
|
1062
|
+
NativeAnalyticsConsent.GRANTED -> AnalyticsConsent.GRANTED
|
|
1063
|
+
NativeAnalyticsConsent.DENIED -> AnalyticsConsent.DENIED
|
|
1064
|
+
NativeAnalyticsConsent.PENDING -> AnalyticsConsent.PENDING
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
private fun nativeConsent(consent: AnalyticsConsent) = when (consent) {
|
|
1068
|
+
AnalyticsConsent.GRANTED -> NativeAnalyticsConsent.GRANTED
|
|
1069
|
+
AnalyticsConsent.DENIED -> NativeAnalyticsConsent.DENIED
|
|
1070
|
+
AnalyticsConsent.PENDING -> NativeAnalyticsConsent.PENDING
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
private fun replacementMode(mode: NativeSubscriptionReplacementMode) = when (mode) {
|
|
1074
|
+
NativeSubscriptionReplacementMode.WITHTIMEPRORATION -> SubscriptionReplacementMode.WITH_TIME_PRORATION
|
|
1075
|
+
NativeSubscriptionReplacementMode.CHARGEPRORATEDPRICE -> SubscriptionReplacementMode.CHARGE_PRORATED_PRICE
|
|
1076
|
+
NativeSubscriptionReplacementMode.CHARGEFULLPRICE -> SubscriptionReplacementMode.CHARGE_FULL_PRICE
|
|
1077
|
+
NativeSubscriptionReplacementMode.WITHOUTPRORATION -> SubscriptionReplacementMode.WITHOUT_PRORATION
|
|
1078
|
+
NativeSubscriptionReplacementMode.DEFERRED -> SubscriptionReplacementMode.DEFERRED
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
/**
|
|
1082
|
+
* The offer [options] names for [product]. One named with its kind is resolved here, among the
|
|
1083
|
+
* product's current offers and intro offer; one named by id alone the SDK resolves. Either way an
|
|
1084
|
+
* offer the product does not have rejects `OFFER_UNAVAILABLE`, never buying the regular price.
|
|
1085
|
+
*/
|
|
1086
|
+
private fun offerSelection(product: VoidhashProduct, options: NativePurchaseOptions): VoidhashOfferSelection =
|
|
1087
|
+
when (options.offerSelection) {
|
|
1088
|
+
NativeOfferSelection.AUTOMATIC -> VoidhashOfferSelection.Automatic
|
|
1089
|
+
NativeOfferSelection.REGULARPRICE -> VoidhashOfferSelection.None
|
|
1090
|
+
NativeOfferSelection.OFFER -> {
|
|
1091
|
+
val kind = options.offerKind
|
|
1092
|
+
val id = options.offerId
|
|
1093
|
+
val intro = product.subscription?.introOffer
|
|
1094
|
+
when {
|
|
1095
|
+
kind == NativeOfferKind.INTRODUCTORY -> VoidhashOfferSelection.Offer(
|
|
1096
|
+
intro ?: throw NativeClientException("OFFER_UNAVAILABLE", "\"${product.slug}\" has no intro offer for this user"),
|
|
1097
|
+
)
|
|
1098
|
+
id == null -> throw NativeClientException("INVALID_ARGUMENT", "The offer to buy \"${product.slug}\" with names no id")
|
|
1099
|
+
kind == null || kind == NativeOfferKind.UNKNOWN -> VoidhashOfferSelection.Id(id)
|
|
1100
|
+
else -> VoidhashOfferSelection.Offer(
|
|
1101
|
+
(product.offers + listOfNotNull(intro)).firstOrNull { it.id == id && it.kind.toNative() == kind }
|
|
1102
|
+
?: throw NativeClientException("OFFER_UNAVAILABLE", "\"${product.slug}\" has no offer \"$id\" for this user"),
|
|
1103
|
+
)
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
private fun flowCapability(capability: NativeFlowCapability) = when (capability) {
|
|
1109
|
+
NativeFlowCapability.LINKS -> FlowCapability.LINKS
|
|
1110
|
+
NativeFlowCapability.NOTIFICATIONS -> FlowCapability.NOTIFICATIONS
|
|
1111
|
+
NativeFlowCapability.TRACKING -> FlowCapability.TRACKING
|
|
1112
|
+
NativeFlowCapability.ATTRIBUTES -> FlowCapability.ATTRIBUTES
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
/** A flag payload or other decoded JSON value as JSON text. */
|
|
1116
|
+
private fun jsonValue(value: Any): String = when (value) {
|
|
1117
|
+
is JSONObject, is JSONArray -> value.toString()
|
|
1118
|
+
is String -> JSONObject.quote(value)
|
|
1119
|
+
else -> VoidhashFlowsCore.jsonScalar(value)
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
/** [json] as a map the SDK takes, nested objects and arrays included. */
|
|
1123
|
+
internal fun jsonMap(json: JSONObject): Map<String, Any?> =
|
|
1124
|
+
json.keys().asSequence().associateWith { key -> jsonPlain(json.opt(key)) }
|
|
1125
|
+
|
|
1126
|
+
private fun jsonPlain(value: Any?): Any? = when (value) {
|
|
1127
|
+
null, JSONObject.NULL -> null
|
|
1128
|
+
is JSONObject -> jsonMap(value)
|
|
1129
|
+
is JSONArray -> (0 until value.length()).map { jsonPlain(value.opt(it)) }
|
|
1130
|
+
else -> value
|
|
1131
|
+
}
|