@scalebun-release/react-native 2.5.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 +21 -0
- package/README.md +154 -0
- package/android/build.gradle +94 -0
- package/android/consumer-rules.pro +28 -0
- package/android/src/androidTest/java/com/scalebun/rn/ota/ScaleBunOtaVerifierInstrumentedTest.kt +112 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/scalebun/core/crash/CrashStorage.kt +155 -0
- package/android/src/main/java/com/scalebun/core/crash/NativeCrashHandler.kt +93 -0
- package/android/src/main/java/com/scalebun/core/performance/ANRWatchdog.kt +100 -0
- package/android/src/main/java/com/scalebun/core/performance/AppStartCollector.kt +180 -0
- package/android/src/main/java/com/scalebun/core/performance/FrameMetricsCollector.kt +230 -0
- package/android/src/main/java/com/scalebun/core/performance/PerformanceCore.kt +165 -0
- package/android/src/main/java/com/scalebun/profiler/ProfilerModule.kt +398 -0
- package/android/src/main/java/com/scalebun/profiler/ProfilerPackage.kt +24 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/CpuCollector.kt +161 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/IncidentDetector.kt +223 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/MemoryCollector.kt +157 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/RenderCollector.kt +194 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/SamplerScheduler.kt +218 -0
- package/android/src/main/java/com/scalebun/profiler/collectors/ThreadCollector.kt +142 -0
- package/android/src/main/java/com/scalebun/replaysdk/ReplaySdkModule.kt +1117 -0
- package/android/src/main/java/com/scalebun/replaysdk/ReplaySdkPackage.kt +24 -0
- package/android/src/main/java/com/scalebun/replaysdk/capture/CaptureReason.kt +47 -0
- package/android/src/main/java/com/scalebun/replaysdk/capture/FrameCaptureManager.kt +574 -0
- package/android/src/main/java/com/scalebun/replaysdk/capture/FrameCaptureScheduler.kt +187 -0
- package/android/src/main/java/com/scalebun/replaysdk/capture/UiStabilityDetector.kt +214 -0
- package/android/src/main/java/com/scalebun/replaysdk/core/ReplayConfig.kt +144 -0
- package/android/src/main/java/com/scalebun/replaysdk/core/ReplayLogger.kt +31 -0
- package/android/src/main/java/com/scalebun/replaysdk/core/SessionIdGenerator.kt +15 -0
- package/android/src/main/java/com/scalebun/replaysdk/models/ReplayModels.kt +94 -0
- package/android/src/main/java/com/scalebun/replaysdk/outbox/NativeOutbox.kt +574 -0
- package/android/src/main/java/com/scalebun/replaysdk/outbox/OutboxUploader.kt +559 -0
- package/android/src/main/java/com/scalebun/replaysdk/privacy/PrivacyMaskProcessor.kt +126 -0
- package/android/src/main/java/com/scalebun/replaysdk/session/SessionManager.kt +322 -0
- package/android/src/main/java/com/scalebun/replaysdk/storage/ReplayStorage.kt +136 -0
- package/android/src/main/java/com/scalebun/replaysdk/timeline/TimelineCollector.kt +28 -0
- package/android/src/main/java/com/scalebun/replaysdk/tracking/InteractionTracker.kt +470 -0
- package/android/src/main/java/com/scalebun/replaysdk/tracking/ScreenTracker.kt +20 -0
- package/android/src/main/java/com/scalebun/replaysdk/tracking/ScrollContextProbe.kt +188 -0
- package/android/src/main/java/com/scalebun/replaysdk/transport/ReplayTransport.kt +99 -0
- package/android/src/main/java/com/scalebun/replaysdk/voice/VoiceRecorder.kt +121 -0
- package/android/src/main/java/com/scalebun/replaysdk/voice/VoiceTranscriber.kt +170 -0
- package/android/src/main/java/com/scalebun/rn/ScaleBunPackage.kt +113 -0
- package/android/src/main/java/com/scalebun/rn/crash/ScaleBunCrashModule.kt +188 -0
- package/android/src/main/java/com/scalebun/rn/crash/ScaleBunCrashPackage.kt +22 -0
- package/android/src/main/java/com/scalebun/rn/engage/ScaleBunEngageModule.kt +579 -0
- package/android/src/main/java/com/scalebun/rn/engage/ScaleBunEngagePackage.kt +22 -0
- package/android/src/main/java/com/scalebun/rn/engage/ScaleBunNotificationPresenter.kt +110 -0
- package/android/src/main/java/com/scalebun/rn/ota/BsPatch.kt +240 -0
- package/android/src/main/java/com/scalebun/rn/ota/BundleDownloader.kt +195 -0
- package/android/src/main/java/com/scalebun/rn/ota/DeviceIntegrity.kt +81 -0
- package/android/src/main/java/com/scalebun/rn/ota/DownloadFailure.kt +55 -0
- package/android/src/main/java/com/scalebun/rn/ota/OtaProtocol.kt +244 -0
- package/android/src/main/java/com/scalebun/rn/ota/ScaleBunOtaKeyRegistry.kt +100 -0
- package/android/src/main/java/com/scalebun/rn/ota/ScaleBunOtaModule.kt +683 -0
- package/android/src/main/java/com/scalebun/rn/ota/ScaleBunOtaReleaseVerifier.kt +136 -0
- package/android/src/main/java/com/scalebun/rn/ota/SlotManager.kt +578 -0
- package/android/src/main/java/com/scalebun/rn/ota/TlsPinning.kt +118 -0
- package/android/src/main/java/com/scalebun/rn/performance/PerformanceModule.kt +217 -0
- package/android/src/main/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule.kt +77 -0
- package/android/src/main/java/com/scalebun/rn/storage/ScaleBunStorageModule.kt +68 -0
- package/android/src/main/java/com/scalebun/storage/KvFileStore.kt +174 -0
- package/android/src/newarch/java/com/scalebun/profiler/ProfilerSpec.kt +12 -0
- package/android/src/newarch/java/com/scalebun/replaysdk/ReplaySdkSpec.kt +12 -0
- package/android/src/newarch/java/com/scalebun/rn/crash/ScaleBunCrashSpec.kt +15 -0
- package/android/src/newarch/java/com/scalebun/rn/ota/ScaleBunOtaSpec.kt +16 -0
- package/android/src/newarch/java/com/scalebun/rn/performance/PerformanceSpec.kt +12 -0
- package/android/src/newarch/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.kt +14 -0
- package/android/src/newarch/java/com/scalebun/rn/storage/ScaleBunStorageSpec.kt +16 -0
- package/android/src/oldarch/java/com/scalebun/profiler/ProfilerSpec.kt +34 -0
- package/android/src/oldarch/java/com/scalebun/replaysdk/ReplaySdkSpec.kt +77 -0
- package/android/src/oldarch/java/com/scalebun/rn/crash/ScaleBunCrashSpec.kt +40 -0
- package/android/src/oldarch/java/com/scalebun/rn/ota/ScaleBunOtaSpec.kt +42 -0
- package/android/src/oldarch/java/com/scalebun/rn/performance/PerformanceSpec.kt +27 -0
- package/android/src/oldarch/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.kt +18 -0
- package/android/src/oldarch/java/com/scalebun/rn/storage/ScaleBunStorageSpec.kt +26 -0
- package/bin/lib/androidCodemod.js +370 -0
- package/bin/lib/iosCodemod.js +343 -0
- package/bin/scalebun.js +1004 -0
- package/dist/scalebun.full.js +37348 -0
- package/dist/scalebun.slim.js +34137 -0
- package/ios/Capture/InteractionTracker.swift +237 -0
- package/ios/Capture/PrivacyMaskProcessor.swift +158 -0
- package/ios/Capture/ScreenshotCaptureManager.swift +398 -0
- package/ios/Capture/WindowResolver.swift +63 -0
- package/ios/Core/DeviceIdentity.swift +50 -0
- package/ios/Core/ReplayConfig.swift +100 -0
- package/ios/Core/ReplayLogger.swift +22 -0
- package/ios/Core/SessionIdGenerator.swift +18 -0
- package/ios/Crash/ScaleBunCrashBridge.mm +74 -0
- package/ios/Crash/ScaleBunCrashHandler.swift +84 -0
- package/ios/Crash/ScaleBunCrashModule.swift +98 -0
- package/ios/Crash/ScaleBunCrashSignalBridge.h +49 -0
- package/ios/Crash/ScaleBunCrashSignalBridge.m +296 -0
- package/ios/Crash/ScaleBunCrashSignalStress.c +137 -0
- package/ios/Crash/ScaleBunCrashStorage.swift +121 -0
- package/ios/Crash/ScaleBunExceptionChain.swift +71 -0
- package/ios/CrashTests/ScaleBunExceptionChainTests.swift +144 -0
- package/ios/Engage/ScaleBunEngageBridge.m +32 -0
- package/ios/Engage/ScaleBunEngageModule.swift +250 -0
- package/ios/Engage/ScaleBunPushNotificationCenter.swift +185 -0
- package/ios/Ota/BsPatch.swift +203 -0
- package/ios/Ota/BundleDownloader.swift +249 -0
- package/ios/Ota/DeviceIntegrity.swift +112 -0
- package/ios/Ota/DownloadFailure.swift +56 -0
- package/ios/Ota/OtaProtocol.swift +246 -0
- package/ios/Ota/OtaSlotManager.swift +613 -0
- package/ios/Ota/ScaleBunOtaBridge.mm +92 -0
- package/ios/Ota/ScaleBunOtaEventsModule.swift +61 -0
- package/ios/Ota/ScaleBunOtaKeyRegistry.swift +147 -0
- package/ios/Ota/ScaleBunOtaModule.swift +587 -0
- package/ios/Ota/ScaleBunOtaReleaseVerifier.swift +119 -0
- package/ios/Ota/TlsPinning.swift +222 -0
- package/ios/OtaTests/DownloadFailureTests.swift +78 -0
- package/ios/OtaTests/ScaleBunOtaVerifierTests.swift +548 -0
- package/ios/Outbox/NativeOutbox.swift +632 -0
- package/ios/Outbox/OutboxUploader.swift +578 -0
- package/ios/Performance/ScaleBunPerformanceBridge.m +32 -0
- package/ios/Performance/ScaleBunPerformanceModule.swift +290 -0
- package/ios/PrivacyInfo.xcprivacy +97 -0
- package/ios/Profiler/ScaleBunProfilerBridge.m +55 -0
- package/ios/Profiler/ScaleBunProfilerModule.swift +966 -0
- package/ios/ReplaySdk-Bridging-Header.h +2 -0
- package/ios/ReplaySdk.swift +793 -0
- package/ios/ReplaySdkBridge.m +97 -0
- package/ios/Session/SessionManager.swift +273 -0
- package/ios/Skan/ScaleBunSkanBridge.m +14 -0
- package/ios/Skan/ScaleBunSkanModule.swift +61 -0
- package/ios/Storage/ReplayStorage.swift +61 -0
- package/ios/Storage/ScaleBunKvFileStore.swift +125 -0
- package/ios/Storage/ScaleBunStorageBridge.mm +72 -0
- package/ios/Storage/ScaleBunStorageModule.swift +57 -0
- package/ios/Transport/ReplayTransport.swift +70 -0
- package/ios/VoiceRecorder.swift +145 -0
- package/lib/commonjs/analytics/EventTracker.js +598 -0
- package/lib/commonjs/analytics/automaticEvents.js +71 -0
- package/lib/commonjs/analytics/batching.js +64 -0
- package/lib/commonjs/analytics/eventLane.js +55 -0
- package/lib/commonjs/analytics/revenue.js +125 -0
- package/lib/commonjs/analytics/subscription.js +94 -0
- package/lib/commonjs/bootstrap/FeatureRegistry.js +86 -0
- package/lib/commonjs/bootstrap/SDKBootstrapper.js +748 -0
- package/lib/commonjs/bucketing/fnv1a32.js +45 -0
- package/lib/commonjs/compat/codepush.js +153 -0
- package/lib/commonjs/config/ConfigManager.js +238 -0
- package/lib/commonjs/config/configTypes.js +16 -0
- package/lib/commonjs/config/otaPolicyState.js +85 -0
- package/lib/commonjs/config/quotaState.js +435 -0
- package/lib/commonjs/core/architecture.js +45 -0
- package/lib/commonjs/core/clock/now.js +13 -0
- package/lib/commonjs/core/config/defaults.js +2 -0
- package/lib/commonjs/core/config/schema.js +512 -0
- package/lib/commonjs/core/constants/endpoints.js +19 -0
- package/lib/commonjs/core/constants/protocol.js +31 -0
- package/lib/commonjs/core/constants/timings.js +39 -0
- package/lib/commonjs/core/constants/version.js +18 -0
- package/lib/commonjs/core/context/app.js +2 -0
- package/lib/commonjs/core/context/device.js +155 -0
- package/lib/commonjs/core/context/session.js +2 -0
- package/lib/commonjs/core/context/user.js +2 -0
- package/lib/commonjs/core/contracts/IFeature.js +2 -0
- package/lib/commonjs/core/di/container.js +29 -0
- package/lib/commonjs/core/encoding/base64.js +50 -0
- package/lib/commonjs/core/id/deviceId.js +52 -0
- package/lib/commonjs/core/id/installationId.js +55 -0
- package/lib/commonjs/core/id/sessionId.js +2 -0
- package/lib/commonjs/core/lifecycle/appLifecycle.js +31 -0
- package/lib/commonjs/core/lifecycle/crashSafe.js +33 -0
- package/lib/commonjs/core/logger/errorClassification.js +107 -0
- package/lib/commonjs/core/logger/internalLogger.js +63 -0
- package/lib/commonjs/core/logger/levels.js +2 -0
- package/lib/commonjs/crypto/hmacSha256.js +132 -0
- package/lib/commonjs/debug/bootstrap.js +429 -0
- package/lib/commonjs/debug/commands.js +732 -0
- package/lib/commonjs/debug/configBuilder.js +70 -0
- package/lib/commonjs/debug/exportBridge.js +155 -0
- package/lib/commonjs/debug/hostResolver.js +42 -0
- package/lib/commonjs/debug/index.js +141 -0
- package/lib/commonjs/debug/metrics.js +39 -0
- package/lib/commonjs/debug/perf.js +186 -0
- package/lib/commonjs/debug/perfWiring.js +109 -0
- package/lib/commonjs/debug/protocol.js +121 -0
- package/lib/commonjs/debug/redaction.js +422 -0
- package/lib/commonjs/debug/replayWiring.js +149 -0
- package/lib/commonjs/debug/screenTracking.js +60 -0
- package/lib/commonjs/debug/sessionWiring.js +48 -0
- package/lib/commonjs/debug/stream.js +542 -0
- package/lib/commonjs/debug/transport.js +368 -0
- package/lib/commonjs/features/bugreport/BugReportFeature.js +112 -0
- package/lib/commonjs/features/bugreport/buildPayload.js +97 -0
- package/lib/commonjs/features/bugreport/index.js +2 -0
- package/lib/commonjs/features/crash/CrashFeature.js +86 -0
- package/lib/commonjs/features/crash/CrashReporter.js +160 -0
- package/lib/commonjs/features/crash/NativeCrashFeature.js +42 -0
- package/lib/commonjs/features/crash/capture.js +48 -0
- package/lib/commonjs/features/crash/globalHandler.js +41 -0
- package/lib/commonjs/features/crash/index.js +14 -0
- package/lib/commonjs/features/crash/nativeCrashBridge.js +361 -0
- package/lib/commonjs/features/crash/rejectionHandler.js +180 -0
- package/lib/commonjs/features/crash/scrubCrash.js +158 -0
- package/lib/commonjs/features/engage/EngageAnchor.js +132 -0
- package/lib/commonjs/features/engage/EngageArchetypeRenderers.js +4292 -0
- package/lib/commonjs/features/engage/EngageInAppView.js +2670 -0
- package/lib/commonjs/features/engage/EngageInlinePlacement.js +133 -0
- package/lib/commonjs/features/engage/EngagePromptProvider.js +1063 -0
- package/lib/commonjs/features/engage/EngagePromptView.js +1252 -0
- package/lib/commonjs/features/engage/EngageTransport.js +608 -0
- package/lib/commonjs/features/engage/EngageVariantContent.js +1778 -0
- package/lib/commonjs/features/engage/__test-support__/reactNativeStub.js +54 -0
- package/lib/commonjs/features/engage/attachmentCapture.js +48 -0
- package/lib/commonjs/features/engage/captureVoiceAttachment.js +88 -0
- package/lib/commonjs/features/engage/engageCoachmarkTour.js +106 -0
- package/lib/commonjs/features/engage/engageGameLogic.js +308 -0
- package/lib/commonjs/features/engage/engageMediaSizing.js +60 -0
- package/lib/commonjs/features/engage/engageMultiStepSheet.js +43 -0
- package/lib/commonjs/features/engage/engageOutcome.js +118 -0
- package/lib/commonjs/features/engage/engagePushTokenBridge.js +72 -0
- package/lib/commonjs/features/engage/engageShakeBridge.js +62 -0
- package/lib/commonjs/features/engage/engageSignals.js +39 -0
- package/lib/commonjs/features/engage/engageStoreReviewBridge.js +49 -0
- package/lib/commonjs/features/engage/engageTestSeenStore.js +99 -0
- package/lib/commonjs/features/engage/engageThrottle.js +404 -0
- package/lib/commonjs/features/engage/engageTriggerEngine.js +365 -0
- package/lib/commonjs/features/engage/engageTypes.js +116 -0
- package/lib/commonjs/features/engage/engageVariantResolver.js +143 -0
- package/lib/commonjs/features/engage/engageWindowInsets.js +98 -0
- package/lib/commonjs/features/engage/gestureTriggerDetector.js +85 -0
- package/lib/commonjs/features/engage/transcription/TranscriptionProvider.js +55 -0
- package/lib/commonjs/features/install-referrer/installReferrer.js +113 -0
- package/lib/commonjs/features/journey/ScaleBunDebugRoot.js +1038 -0
- package/lib/commonjs/features/journey/ScaleBunFlatList.js +39 -0
- package/lib/commonjs/features/journey/ScaleBunImpression.js +113 -0
- package/lib/commonjs/features/journey/ScaleBunScrollView.js +102 -0
- package/lib/commonjs/features/journey/ScaleBunSectionList.js +39 -0
- package/lib/commonjs/features/journey/autoInstrumentScroll.js +161 -0
- package/lib/commonjs/features/journey/calibrationContext.js +42 -0
- package/lib/commonjs/features/journey/gestureBuffer.js +63 -0
- package/lib/commonjs/features/journey/gestureDetector.js +176 -0
- package/lib/commonjs/features/journey/impression.js +93 -0
- package/lib/commonjs/features/journey/interactionProtocol.js +168 -0
- package/lib/commonjs/features/journey/journeyManager.js +466 -0
- package/lib/commonjs/features/journey/journeyTypes.js +55 -0
- package/lib/commonjs/features/journey/nativeScroll.js +85 -0
- package/lib/commonjs/features/journey/navDetector.js +161 -0
- package/lib/commonjs/features/journey/screenshotHelper.js +136 -0
- package/lib/commonjs/features/journey/scrollContext.js +154 -0
- package/lib/commonjs/features/journey/targetGeometry.js +185 -0
- package/lib/commonjs/features/journey/targetRegistry.js +53 -0
- package/lib/commonjs/features/journey/touchTarget.js +249 -0
- package/lib/commonjs/features/journey/uiState.js +188 -0
- package/lib/commonjs/features/navigation/AutoScreenDetector.js +607 -0
- package/lib/commonjs/features/network/NetworkFeature.js +216 -0
- package/lib/commonjs/features/network/index.js +23 -0
- package/lib/commonjs/features/network/thirdParty.js +151 -0
- package/lib/commonjs/features/ota/OtaEventEmitter.js +129 -0
- package/lib/commonjs/features/ota/OtaOrchestrator.js +1309 -0
- package/lib/commonjs/features/ota/OtaTypes.js +6 -0
- package/lib/commonjs/features/ota/deviceAttributes.js +48 -0
- package/lib/commonjs/features/ota/environment.js +172 -0
- package/lib/commonjs/features/ota/geoCountry.js +93 -0
- package/lib/commonjs/features/ota/retry.js +96 -0
- package/lib/commonjs/features/ota/signedDownload.js +187 -0
- package/lib/commonjs/features/ota/useOtaUpdate.js +106 -0
- package/lib/commonjs/features/performance/PerformanceFeature.js +649 -0
- package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js +122 -0
- package/lib/commonjs/features/performance/collectors/AutoScreenLoadCollector.js +232 -0
- package/lib/commonjs/features/performance/collectors/CustomTraceCollector.js +99 -0
- package/lib/commonjs/features/performance/collectors/FrameMetricsCollector.js +184 -0
- package/lib/commonjs/features/performance/collectors/JsStallCollector.js +165 -0
- package/lib/commonjs/features/performance/collectors/NetworkPerfCollector.js +59 -0
- package/lib/commonjs/features/performance/collectors/ScreenLoadCollector.js +78 -0
- package/lib/commonjs/features/performance/collectors/UiHangCollector.js +78 -0
- package/lib/commonjs/features/performance/config.js +58 -0
- package/lib/commonjs/features/performance/getNativePerformanceModule.js +44 -0
- package/lib/commonjs/features/performance/index.js +58 -0
- package/lib/commonjs/features/performance/metrics/MetricsEngine.js +148 -0
- package/lib/commonjs/features/performance/models.js +48 -0
- package/lib/commonjs/features/performance/transport/PerformanceTransport.js +168 -0
- package/lib/commonjs/features/profiler/ProfilerFeature.js +600 -0
- package/lib/commonjs/features/profiler/config.js +151 -0
- package/lib/commonjs/features/profiler/contracts.js +62 -0
- package/lib/commonjs/features/profiler/index.js +40 -0
- package/lib/commonjs/features/profiler/models.js +112 -0
- package/lib/commonjs/features/profiler/transport/ProfilerTransport.js +94 -0
- package/lib/commonjs/features/replay/bridge/adapters/bridgeAdapter.js +203 -0
- package/lib/commonjs/features/replay/bridge/eventEmitter.js +128 -0
- package/lib/commonjs/features/replay/bridge/nativeModule.js +95 -0
- package/lib/commonjs/features/replay/bridge/nativeQuota.js +121 -0
- package/lib/commonjs/features/replay/core/clock/clock.js +47 -0
- package/lib/commonjs/features/replay/core/config/defaults.js +88 -0
- package/lib/commonjs/features/replay/core/config/validator.js +109 -0
- package/lib/commonjs/features/replay/core/env/environmentDetector.js +28 -0
- package/lib/commonjs/features/replay/core/errors/safeCall.js +42 -0
- package/lib/commonjs/features/replay/core/ids/sessionId.js +53 -0
- package/lib/commonjs/features/replay/core/logger/logger.js +36 -0
- package/lib/commonjs/features/replay/core/privacy/privacyTypes.js +34 -0
- package/lib/commonjs/features/replay/core/queue/boundedQueue.js +71 -0
- package/lib/commonjs/features/replay/integrations/alert/alertInstrumentation.js +259 -0
- package/lib/commonjs/features/replay/integrations/logs/consoleIntegration.js +139 -0
- package/lib/commonjs/features/replay/integrations/network/networkAdapter.js +77 -0
- package/lib/commonjs/features/replay/integrations/react-navigation/navigationIntegration.js +88 -0
- package/lib/commonjs/features/replay/integrations/touch/ReplayRoot.js +103 -0
- package/lib/commonjs/features/replay/pipeline/batching/batchManager.js +119 -0
- package/lib/commonjs/features/replay/pipeline/envelope/envelopeBuilder.js +52 -0
- package/lib/commonjs/features/replay/pipeline/retry/retryPolicy.js +53 -0
- package/lib/commonjs/features/replay/pipeline/transport/transportTypes.js +67 -0
- package/lib/commonjs/features/replay/public/api.js +336 -0
- package/lib/commonjs/features/replay/public/enums.js +85 -0
- package/lib/commonjs/features/replay/public/types.js +6 -0
- package/lib/commonjs/features/replay/replay/breadcrumbs/breadcrumbCollector.js +119 -0
- package/lib/commonjs/features/replay/replay/frames/frameModels.js +40 -0
- package/lib/commonjs/features/replay/replay/session/sessionOrchestrator.js +279 -0
- package/lib/commonjs/features/replay/replay/timeline/timelineModels.js +120 -0
- package/lib/commonjs/features/replay/transport/BackendReplayTransport.js +175 -0
- package/lib/commonjs/features/replay/transport/CompositeReplayTransport.js +75 -0
- package/lib/commonjs/features/replay/transport/DesktopReplayTransport.js +124 -0
- package/lib/commonjs/features/replay/transport/ReplayTransport.js +2 -0
- package/lib/commonjs/features/session/BackendSessionAdapter.js +1915 -0
- package/lib/commonjs/features/session/DesktopSessionTransport.js +124 -0
- package/lib/commonjs/features/session/JourneyEventPipeline.js +244 -0
- package/lib/commonjs/features/session/ReplayCaptureManager.js +1253 -0
- package/lib/commonjs/features/session/ScrollTracker.js +147 -0
- package/lib/commonjs/features/session/SessionManager.js +1448 -0
- package/lib/commonjs/features/session/SyncDecisionEngine.js +95 -0
- package/lib/commonjs/features/session/frameLink.js +36 -0
- package/lib/commonjs/features/session/frameScrollState.js +41 -0
- package/lib/commonjs/features/session/index.js +84 -0
- package/lib/commonjs/features/session/nativeCapture.js +53 -0
- package/lib/commonjs/features/session/outboxFrameCapture.js +83 -0
- package/lib/commonjs/features/session/sessionTypes.js +230 -0
- package/lib/commonjs/features/session/viewportPlausibility.js +143 -0
- package/lib/commonjs/features/skan/skanBridge.js +54 -0
- package/lib/commonjs/features/skan/skanConversionManager.js +134 -0
- package/lib/commonjs/index.js +267 -0
- package/lib/commonjs/integrations/fetch/fetchInterceptor.js +174 -0
- package/lib/commonjs/integrations/navigation/screenTracker.js +2 -0
- package/lib/commonjs/integrations/network/bodyCapture.js +336 -0
- package/lib/commonjs/integrations/xhr/xhrInterceptor.js +224 -0
- package/lib/commonjs/metro/composeSourceMap.js +105 -0
- package/lib/commonjs/metro/featureModules.js +131 -0
- package/lib/commonjs/metro/index.js +230 -0
- package/lib/commonjs/metro/optionalDependencyStub.js +6 -0
- package/lib/commonjs/metro/optionalModules.js +31 -0
- package/lib/commonjs/metro/serializerCompose.js +161 -0
- package/lib/commonjs/pipeline/dispatcher/dispatcher.js +28 -0
- package/lib/commonjs/pipeline/envelope/envelope.js +17 -0
- package/lib/commonjs/pipeline/envelope/serializer.js +14 -0
- package/lib/commonjs/pipeline/processors/dedupe.js +2 -0
- package/lib/commonjs/pipeline/processors/enrich.js +16 -0
- package/lib/commonjs/pipeline/processors/sampling.js +2 -0
- package/lib/commonjs/pipeline/processors/sanitize.js +28 -0
- package/lib/commonjs/pipeline/queue/flushQueue.js +107 -0
- package/lib/commonjs/pipeline/queue/memoryQueue.js +31 -0
- package/lib/commonjs/pipeline/queue/persistentQueue.js +342 -0
- package/lib/commonjs/pipeline/queue/queuePolicy.js +2 -0
- package/lib/commonjs/pipeline/scheduler/flushScheduler.js +45 -0
- package/lib/commonjs/pipeline/scheduler/retryPolicy.js +15 -0
- package/lib/commonjs/public/ScaleBunErrorBoundary.js +91 -0
- package/lib/commonjs/public/ScaleBunFacade.js +2044 -0
- package/lib/commonjs/public/ScaleBunProvider.js +62 -0
- package/lib/commonjs/public/typedTracker.js +79 -0
- package/lib/commonjs/public/types.js +6 -0
- package/lib/commonjs/push/PushManager.js +270 -0
- package/lib/commonjs/push/adapters/ManualAdapter.js +86 -0
- package/lib/commonjs/push/adapters/NativeBridgeAdapter.js +131 -0
- package/lib/commonjs/push/adapters/NoopAdapter.js +45 -0
- package/lib/commonjs/push/adapters/RNFirebaseMessagingAdapter.js +248 -0
- package/lib/commonjs/push/adapters/loadMessaging.js +29 -0
- package/lib/commonjs/push/adapters/loadNotifee.js +36 -0
- package/lib/commonjs/push/adapters/selectAdapter.js +153 -0
- package/lib/commonjs/push/detect/capabilities.js +136 -0
- package/lib/commonjs/push/index.js +33 -0
- package/lib/commonjs/push/native/nativeNotifications.js +168 -0
- package/lib/commonjs/push/types.js +2 -0
- package/lib/commonjs/specs/NativeReplaySdk.js +28 -0
- package/lib/commonjs/specs/NativeScaleBunCrash.js +30 -0
- package/lib/commonjs/specs/NativeScaleBunInstallReferrer.js +24 -0
- package/lib/commonjs/specs/NativeScaleBunOta.js +32 -0
- package/lib/commonjs/specs/NativeScaleBunPerformance.js +25 -0
- package/lib/commonjs/specs/NativeScaleBunProfiler.js +26 -0
- package/lib/commonjs/specs/NativeScaleBunStorage.js +40 -0
- package/lib/commonjs/storage/StorageBackend.js +240 -0
- package/lib/commonjs/storage/db/sqlite.js +2 -0
- package/lib/commonjs/storage/files/fileStore.js +2 -0
- package/lib/commonjs/transport/auth/sdkSession.js +28 -0
- package/lib/commonjs/transport/backoff/exponentialJitter.js +16 -0
- package/lib/commonjs/transport/http/endpoints.js +46 -0
- package/lib/commonjs/transport/http/httpClient.js +72 -0
- package/lib/commonjs/transport/rateLimit/retryAfter.js +2 -0
- package/lib/commonjs/transport/signing/requestSigner.js +2 -0
- package/lib/commonjs/vendor/protocol/index.js +327 -0
- package/lib/commonjs/vendor/protocol/internal/validation.js +429 -0
- package/lib/commonjs/vendor/sdk-contracts/bridge.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/config.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/events.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/features.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/index.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/platform.js +2 -0
- package/lib/commonjs/vendor/sdk-contracts/session-boundary.js +6 -0
- package/lib/commonjs/vendor/sdk-contracts/session.js +2 -0
- package/lib/commonjs/vendor/vendor.manifest +10 -0
- package/lib/module/analytics/EventTracker.js +592 -0
- package/lib/module/analytics/automaticEvents.js +63 -0
- package/lib/module/analytics/batching.js +55 -0
- package/lib/module/analytics/eventLane.js +47 -0
- package/lib/module/analytics/revenue.js +117 -0
- package/lib/module/analytics/subscription.js +86 -0
- package/lib/module/bootstrap/FeatureRegistry.js +79 -0
- package/lib/module/bootstrap/SDKBootstrapper.js +742 -0
- package/lib/module/bucketing/fnv1a32.js +37 -0
- package/lib/module/compat/codepush.js +147 -0
- package/lib/module/config/ConfigManager.js +230 -0
- package/lib/module/config/configTypes.js +10 -0
- package/lib/module/config/otaPolicyState.js +76 -0
- package/lib/module/config/quotaState.js +423 -0
- package/lib/module/core/architecture.js +38 -0
- package/lib/module/core/clock/now.js +7 -0
- package/lib/module/core/config/defaults.js +2 -0
- package/lib/module/core/config/schema.js +506 -0
- package/lib/module/core/constants/endpoints.js +13 -0
- package/lib/module/core/constants/protocol.js +25 -0
- package/lib/module/core/constants/timings.js +26 -0
- package/lib/module/core/constants/version.js +12 -0
- package/lib/module/core/context/app.js +2 -0
- package/lib/module/core/context/device.js +143 -0
- package/lib/module/core/context/session.js +2 -0
- package/lib/module/core/context/user.js +2 -0
- package/lib/module/core/contracts/IFeature.js +2 -0
- package/lib/module/core/di/container.js +22 -0
- package/lib/module/core/encoding/base64.js +44 -0
- package/lib/module/core/id/deviceId.js +45 -0
- package/lib/module/core/id/installationId.js +50 -0
- package/lib/module/core/id/sessionId.js +2 -0
- package/lib/module/core/lifecycle/appLifecycle.js +25 -0
- package/lib/module/core/lifecycle/crashSafe.js +26 -0
- package/lib/module/core/logger/errorClassification.js +96 -0
- package/lib/module/core/logger/internalLogger.js +59 -0
- package/lib/module/core/logger/levels.js +2 -0
- package/lib/module/crypto/hmacSha256.js +126 -0
- package/lib/module/debug/bootstrap.js +393 -0
- package/lib/module/debug/commands.js +726 -0
- package/lib/module/debug/configBuilder.js +63 -0
- package/lib/module/debug/exportBridge.js +148 -0
- package/lib/module/debug/hostResolver.js +37 -0
- package/lib/module/debug/index.js +13 -0
- package/lib/module/debug/metrics.js +33 -0
- package/lib/module/debug/perf.js +180 -0
- package/lib/module/debug/perfWiring.js +102 -0
- package/lib/module/debug/protocol.js +19 -0
- package/lib/module/debug/redaction.js +411 -0
- package/lib/module/debug/replayWiring.js +139 -0
- package/lib/module/debug/screenTracking.js +53 -0
- package/lib/module/debug/sessionWiring.js +43 -0
- package/lib/module/debug/stream.js +536 -0
- package/lib/module/debug/transport.js +362 -0
- package/lib/module/features/bugreport/BugReportFeature.js +105 -0
- package/lib/module/features/bugreport/buildPayload.js +91 -0
- package/lib/module/features/bugreport/index.js +2 -0
- package/lib/module/features/crash/CrashFeature.js +79 -0
- package/lib/module/features/crash/CrashReporter.js +151 -0
- package/lib/module/features/crash/NativeCrashFeature.js +36 -0
- package/lib/module/features/crash/capture.js +42 -0
- package/lib/module/features/crash/globalHandler.js +36 -0
- package/lib/module/features/crash/index.js +8 -0
- package/lib/module/features/crash/nativeCrashBridge.js +350 -0
- package/lib/module/features/crash/rejectionHandler.js +171 -0
- package/lib/module/features/crash/scrubCrash.js +149 -0
- package/lib/module/features/engage/EngageAnchor.js +121 -0
- package/lib/module/features/engage/EngageArchetypeRenderers.js +4264 -0
- package/lib/module/features/engage/EngageInAppView.js +2656 -0
- package/lib/module/features/engage/EngageInlinePlacement.js +123 -0
- package/lib/module/features/engage/EngagePromptProvider.js +1054 -0
- package/lib/module/features/engage/EngagePromptView.js +1243 -0
- package/lib/module/features/engage/EngageTransport.js +602 -0
- package/lib/module/features/engage/EngageVariantContent.js +1771 -0
- package/lib/module/features/engage/__test-support__/reactNativeStub.js +52 -0
- package/lib/module/features/engage/attachmentCapture.js +42 -0
- package/lib/module/features/engage/captureVoiceAttachment.js +80 -0
- package/lib/module/features/engage/engageCoachmarkTour.js +94 -0
- package/lib/module/features/engage/engageGameLogic.js +287 -0
- package/lib/module/features/engage/engageMediaSizing.js +51 -0
- package/lib/module/features/engage/engageMultiStepSheet.js +35 -0
- package/lib/module/features/engage/engageOutcome.js +108 -0
- package/lib/module/features/engage/engagePushTokenBridge.js +65 -0
- package/lib/module/features/engage/engageShakeBridge.js +56 -0
- package/lib/module/features/engage/engageSignals.js +34 -0
- package/lib/module/features/engage/engageStoreReviewBridge.js +43 -0
- package/lib/module/features/engage/engageTestSeenStore.js +92 -0
- package/lib/module/features/engage/engageThrottle.js +390 -0
- package/lib/module/features/engage/engageTriggerEngine.js +360 -0
- package/lib/module/features/engage/engageTypes.js +110 -0
- package/lib/module/features/engage/engageVariantResolver.js +135 -0
- package/lib/module/features/engage/engageWindowInsets.js +89 -0
- package/lib/module/features/engage/gestureTriggerDetector.js +80 -0
- package/lib/module/features/engage/transcription/TranscriptionProvider.js +46 -0
- package/lib/module/features/install-referrer/installReferrer.js +104 -0
- package/lib/module/features/journey/ScaleBunDebugRoot.js +1030 -0
- package/lib/module/features/journey/ScaleBunFlatList.js +32 -0
- package/lib/module/features/journey/ScaleBunImpression.js +105 -0
- package/lib/module/features/journey/ScaleBunScrollView.js +95 -0
- package/lib/module/features/journey/ScaleBunSectionList.js +32 -0
- package/lib/module/features/journey/autoInstrumentScroll.js +155 -0
- package/lib/module/features/journey/calibrationContext.js +35 -0
- package/lib/module/features/journey/gestureBuffer.js +56 -0
- package/lib/module/features/journey/gestureDetector.js +169 -0
- package/lib/module/features/journey/impression.js +84 -0
- package/lib/module/features/journey/interactionProtocol.js +158 -0
- package/lib/module/features/journey/journeyManager.js +459 -0
- package/lib/module/features/journey/journeyTypes.js +49 -0
- package/lib/module/features/journey/nativeScroll.js +77 -0
- package/lib/module/features/journey/navDetector.js +154 -0
- package/lib/module/features/journey/screenshotHelper.js +129 -0
- package/lib/module/features/journey/scrollContext.js +142 -0
- package/lib/module/features/journey/targetGeometry.js +175 -0
- package/lib/module/features/journey/targetRegistry.js +44 -0
- package/lib/module/features/journey/touchTarget.js +241 -0
- package/lib/module/features/journey/uiState.js +176 -0
- package/lib/module/features/navigation/AutoScreenDetector.js +601 -0
- package/lib/module/features/network/NetworkFeature.js +209 -0
- package/lib/module/features/network/index.js +17 -0
- package/lib/module/features/network/thirdParty.js +142 -0
- package/lib/module/features/ota/OtaEventEmitter.js +123 -0
- package/lib/module/features/ota/OtaOrchestrator.js +1302 -0
- package/lib/module/features/ota/OtaTypes.js +2 -0
- package/lib/module/features/ota/deviceAttributes.js +43 -0
- package/lib/module/features/ota/environment.js +165 -0
- package/lib/module/features/ota/geoCountry.js +86 -0
- package/lib/module/features/ota/retry.js +87 -0
- package/lib/module/features/ota/signedDownload.js +174 -0
- package/lib/module/features/ota/useOtaUpdate.js +100 -0
- package/lib/module/features/performance/PerformanceFeature.js +643 -0
- package/lib/module/features/performance/collectors/AppLaunchCollector.js +115 -0
- package/lib/module/features/performance/collectors/AutoScreenLoadCollector.js +225 -0
- package/lib/module/features/performance/collectors/CustomTraceCollector.js +92 -0
- package/lib/module/features/performance/collectors/FrameMetricsCollector.js +177 -0
- package/lib/module/features/performance/collectors/JsStallCollector.js +158 -0
- package/lib/module/features/performance/collectors/NetworkPerfCollector.js +52 -0
- package/lib/module/features/performance/collectors/ScreenLoadCollector.js +71 -0
- package/lib/module/features/performance/collectors/UiHangCollector.js +71 -0
- package/lib/module/features/performance/config.js +51 -0
- package/lib/module/features/performance/getNativePerformanceModule.js +39 -0
- package/lib/module/features/performance/index.js +9 -0
- package/lib/module/features/performance/metrics/MetricsEngine.js +139 -0
- package/lib/module/features/performance/models.js +42 -0
- package/lib/module/features/performance/transport/PerformanceTransport.js +162 -0
- package/lib/module/features/profiler/ProfilerFeature.js +594 -0
- package/lib/module/features/profiler/config.js +143 -0
- package/lib/module/features/profiler/contracts.js +56 -0
- package/lib/module/features/profiler/index.js +11 -0
- package/lib/module/features/profiler/models.js +106 -0
- package/lib/module/features/profiler/transport/ProfilerTransport.js +87 -0
- package/lib/module/features/replay/bridge/adapters/bridgeAdapter.js +198 -0
- package/lib/module/features/replay/bridge/eventEmitter.js +122 -0
- package/lib/module/features/replay/bridge/nativeModule.js +89 -0
- package/lib/module/features/replay/bridge/nativeQuota.js +109 -0
- package/lib/module/features/replay/core/clock/clock.js +37 -0
- package/lib/module/features/replay/core/config/defaults.js +82 -0
- package/lib/module/features/replay/core/config/validator.js +103 -0
- package/lib/module/features/replay/core/env/environmentDetector.js +22 -0
- package/lib/module/features/replay/core/errors/safeCall.js +35 -0
- package/lib/module/features/replay/core/ids/sessionId.js +44 -0
- package/lib/module/features/replay/core/logger/logger.js +29 -0
- package/lib/module/features/replay/core/privacy/privacyTypes.js +27 -0
- package/lib/module/features/replay/core/queue/boundedQueue.js +64 -0
- package/lib/module/features/replay/integrations/alert/alertInstrumentation.js +252 -0
- package/lib/module/features/replay/integrations/logs/consoleIntegration.js +131 -0
- package/lib/module/features/replay/integrations/network/networkAdapter.js +70 -0
- package/lib/module/features/replay/integrations/react-navigation/navigationIntegration.js +82 -0
- package/lib/module/features/replay/integrations/touch/ReplayRoot.js +96 -0
- package/lib/module/features/replay/pipeline/batching/batchManager.js +113 -0
- package/lib/module/features/replay/pipeline/envelope/envelopeBuilder.js +43 -0
- package/lib/module/features/replay/pipeline/retry/retryPolicy.js +45 -0
- package/lib/module/features/replay/pipeline/transport/transportTypes.js +60 -0
- package/lib/module/features/replay/public/api.js +332 -0
- package/lib/module/features/replay/public/enums.js +85 -0
- package/lib/module/features/replay/public/types.js +2 -0
- package/lib/module/features/replay/replay/breadcrumbs/breadcrumbCollector.js +113 -0
- package/lib/module/features/replay/replay/frames/frameModels.js +33 -0
- package/lib/module/features/replay/replay/session/sessionOrchestrator.js +272 -0
- package/lib/module/features/replay/replay/timeline/timelineModels.js +108 -0
- package/lib/module/features/replay/transport/BackendReplayTransport.js +169 -0
- package/lib/module/features/replay/transport/CompositeReplayTransport.js +68 -0
- package/lib/module/features/replay/transport/DesktopReplayTransport.js +119 -0
- package/lib/module/features/replay/transport/ReplayTransport.js +2 -0
- package/lib/module/features/session/BackendSessionAdapter.js +1908 -0
- package/lib/module/features/session/DesktopSessionTransport.js +118 -0
- package/lib/module/features/session/JourneyEventPipeline.js +239 -0
- package/lib/module/features/session/ReplayCaptureManager.js +1248 -0
- package/lib/module/features/session/ScrollTracker.js +141 -0
- package/lib/module/features/session/SessionManager.js +1443 -0
- package/lib/module/features/session/SyncDecisionEngine.js +88 -0
- package/lib/module/features/session/frameLink.js +29 -0
- package/lib/module/features/session/frameScrollState.js +34 -0
- package/lib/module/features/session/index.js +35 -0
- package/lib/module/features/session/nativeCapture.js +45 -0
- package/lib/module/features/session/outboxFrameCapture.js +77 -0
- package/lib/module/features/session/sessionTypes.js +226 -0
- package/lib/module/features/session/viewportPlausibility.js +137 -0
- package/lib/module/features/skan/skanBridge.js +48 -0
- package/lib/module/features/skan/skanConversionManager.js +128 -0
- package/lib/module/index.js +80 -0
- package/lib/module/integrations/fetch/fetchInterceptor.js +169 -0
- package/lib/module/integrations/navigation/screenTracker.js +2 -0
- package/lib/module/integrations/network/bodyCapture.js +320 -0
- package/lib/module/integrations/xhr/xhrInterceptor.js +219 -0
- package/lib/module/metro/composeSourceMap.js +97 -0
- package/lib/module/metro/featureModules.js +123 -0
- package/lib/module/metro/index.js +218 -0
- package/lib/module/metro/optionalDependencyStub.js +14 -0
- package/lib/module/metro/optionalModules.js +25 -0
- package/lib/module/metro/serializerCompose.js +152 -0
- package/lib/module/pipeline/dispatcher/dispatcher.js +21 -0
- package/lib/module/pipeline/envelope/envelope.js +11 -0
- package/lib/module/pipeline/envelope/serializer.js +8 -0
- package/lib/module/pipeline/processors/dedupe.js +2 -0
- package/lib/module/pipeline/processors/enrich.js +10 -0
- package/lib/module/pipeline/processors/sampling.js +2 -0
- package/lib/module/pipeline/processors/sanitize.js +22 -0
- package/lib/module/pipeline/queue/flushQueue.js +102 -0
- package/lib/module/pipeline/queue/memoryQueue.js +24 -0
- package/lib/module/pipeline/queue/persistentQueue.js +336 -0
- package/lib/module/pipeline/queue/queuePolicy.js +2 -0
- package/lib/module/pipeline/scheduler/flushScheduler.js +38 -0
- package/lib/module/pipeline/scheduler/retryPolicy.js +9 -0
- package/lib/module/public/ScaleBunErrorBoundary.js +82 -0
- package/lib/module/public/ScaleBunFacade.js +2038 -0
- package/lib/module/public/ScaleBunProvider.js +54 -0
- package/lib/module/public/typedTracker.js +72 -0
- package/lib/module/public/types.js +2 -0
- package/lib/module/push/PushManager.js +263 -0
- package/lib/module/push/adapters/ManualAdapter.js +79 -0
- package/lib/module/push/adapters/NativeBridgeAdapter.js +124 -0
- package/lib/module/push/adapters/NoopAdapter.js +38 -0
- package/lib/module/push/adapters/RNFirebaseMessagingAdapter.js +241 -0
- package/lib/module/push/adapters/loadMessaging.js +23 -0
- package/lib/module/push/adapters/loadNotifee.js +30 -0
- package/lib/module/push/adapters/selectAdapter.js +147 -0
- package/lib/module/push/detect/capabilities.js +130 -0
- package/lib/module/push/index.js +9 -0
- package/lib/module/push/native/nativeNotifications.js +155 -0
- package/lib/module/push/types.js +2 -0
- package/lib/module/specs/NativeReplaySdk.js +24 -0
- package/lib/module/specs/NativeScaleBunCrash.js +26 -0
- package/lib/module/specs/NativeScaleBunInstallReferrer.js +20 -0
- package/lib/module/specs/NativeScaleBunOta.js +28 -0
- package/lib/module/specs/NativeScaleBunPerformance.js +21 -0
- package/lib/module/specs/NativeScaleBunProfiler.js +22 -0
- package/lib/module/specs/NativeScaleBunStorage.js +36 -0
- package/lib/module/storage/StorageBackend.js +231 -0
- package/lib/module/storage/db/sqlite.js +2 -0
- package/lib/module/storage/files/fileStore.js +2 -0
- package/lib/module/transport/auth/sdkSession.js +21 -0
- package/lib/module/transport/backoff/exponentialJitter.js +10 -0
- package/lib/module/transport/http/endpoints.js +40 -0
- package/lib/module/transport/http/httpClient.js +64 -0
- package/lib/module/transport/rateLimit/retryAfter.js +2 -0
- package/lib/module/transport/signing/requestSigner.js +2 -0
- package/lib/module/vendor/protocol/index.js +312 -0
- package/lib/module/vendor/protocol/internal/validation.js +423 -0
- package/lib/module/vendor/sdk-contracts/bridge.js +2 -0
- package/lib/module/vendor/sdk-contracts/config.js +2 -0
- package/lib/module/vendor/sdk-contracts/events.js +2 -0
- package/lib/module/vendor/sdk-contracts/features.js +2 -0
- package/lib/module/vendor/sdk-contracts/index.js +2 -0
- package/lib/module/vendor/sdk-contracts/platform.js +2 -0
- package/lib/module/vendor/sdk-contracts/session-boundary.js +2 -0
- package/lib/module/vendor/sdk-contracts/session.js +2 -0
- package/lib/module/vendor/vendor.manifest +10 -0
- package/lib/typescript/analytics/EventTracker.d.ts +197 -0
- package/lib/typescript/analytics/automaticEvents.d.ts +30 -0
- package/lib/typescript/analytics/batching.d.ts +33 -0
- package/lib/typescript/analytics/eventLane.d.ts +22 -0
- package/lib/typescript/analytics/revenue.d.ts +94 -0
- package/lib/typescript/analytics/subscription.d.ts +35 -0
- package/lib/typescript/bootstrap/FeatureRegistry.d.ts +36 -0
- package/lib/typescript/bootstrap/SDKBootstrapper.d.ts +82 -0
- package/lib/typescript/bucketing/fnv1a32.d.ts +20 -0
- package/lib/typescript/compat/codepush.d.ts +76 -0
- package/lib/typescript/config/ConfigManager.d.ts +82 -0
- package/lib/typescript/config/configTypes.d.ts +73 -0
- package/lib/typescript/config/otaPolicyState.d.ts +55 -0
- package/lib/typescript/config/quotaState.d.ts +155 -0
- package/lib/typescript/core/architecture.d.ts +29 -0
- package/lib/typescript/core/clock/now.d.ts +5 -0
- package/lib/typescript/core/config/defaults.d.ts +1 -0
- package/lib/typescript/core/config/schema.d.ts +107 -0
- package/lib/typescript/core/constants/endpoints.d.ts +13 -0
- package/lib/typescript/core/constants/protocol.d.ts +23 -0
- package/lib/typescript/core/constants/timings.d.ts +22 -0
- package/lib/typescript/core/constants/version.d.ts +12 -0
- package/lib/typescript/core/context/app.d.ts +1 -0
- package/lib/typescript/core/context/device.d.ts +61 -0
- package/lib/typescript/core/context/session.d.ts +1 -0
- package/lib/typescript/core/context/user.d.ts +24 -0
- package/lib/typescript/core/contracts/IFeature.d.ts +44 -0
- package/lib/typescript/core/di/container.d.ts +9 -0
- package/lib/typescript/core/encoding/base64.d.ts +13 -0
- package/lib/typescript/core/id/deviceId.d.ts +9 -0
- package/lib/typescript/core/id/installationId.d.ts +20 -0
- package/lib/typescript/core/id/sessionId.d.ts +1 -0
- package/lib/typescript/core/lifecycle/appLifecycle.d.ts +14 -0
- package/lib/typescript/core/lifecycle/crashSafe.d.ts +7 -0
- package/lib/typescript/core/logger/errorClassification.d.ts +46 -0
- package/lib/typescript/core/logger/internalLogger.d.ts +24 -0
- package/lib/typescript/core/logger/levels.d.ts +1 -0
- package/lib/typescript/crypto/hmacSha256.d.ts +10 -0
- package/lib/typescript/debug/bootstrap.d.ts +148 -0
- package/lib/typescript/debug/commands.d.ts +77 -0
- package/lib/typescript/debug/configBuilder.d.ts +13 -0
- package/lib/typescript/debug/exportBridge.d.ts +27 -0
- package/lib/typescript/debug/hostResolver.d.ts +14 -0
- package/lib/typescript/debug/index.d.ts +12 -0
- package/lib/typescript/debug/metrics.d.ts +2 -0
- package/lib/typescript/debug/perf.d.ts +43 -0
- package/lib/typescript/debug/perfWiring.d.ts +33 -0
- package/lib/typescript/debug/protocol.d.ts +15 -0
- package/lib/typescript/debug/redaction.d.ts +69 -0
- package/lib/typescript/debug/replayWiring.d.ts +25 -0
- package/lib/typescript/debug/screenTracking.d.ts +16 -0
- package/lib/typescript/debug/sessionWiring.d.ts +16 -0
- package/lib/typescript/debug/stream.d.ts +77 -0
- package/lib/typescript/debug/transport.d.ts +110 -0
- package/lib/typescript/features/bugreport/BugReportFeature.d.ts +59 -0
- package/lib/typescript/features/bugreport/buildPayload.d.ts +51 -0
- package/lib/typescript/features/bugreport/index.d.ts +1 -0
- package/lib/typescript/features/crash/CrashFeature.d.ts +21 -0
- package/lib/typescript/features/crash/CrashReporter.d.ts +107 -0
- package/lib/typescript/features/crash/NativeCrashFeature.d.ts +17 -0
- package/lib/typescript/features/crash/capture.d.ts +22 -0
- package/lib/typescript/features/crash/globalHandler.d.ts +14 -0
- package/lib/typescript/features/crash/index.d.ts +2 -0
- package/lib/typescript/features/crash/nativeCrashBridge.d.ts +43 -0
- package/lib/typescript/features/crash/rejectionHandler.d.ts +65 -0
- package/lib/typescript/features/crash/scrubCrash.d.ts +35 -0
- package/lib/typescript/features/engage/EngageAnchor.d.ts +36 -0
- package/lib/typescript/features/engage/EngageArchetypeRenderers.d.ts +66 -0
- package/lib/typescript/features/engage/EngageInAppView.d.ts +164 -0
- package/lib/typescript/features/engage/EngageInlinePlacement.d.ts +42 -0
- package/lib/typescript/features/engage/EngagePromptProvider.d.ts +233 -0
- package/lib/typescript/features/engage/EngagePromptView.d.ts +97 -0
- package/lib/typescript/features/engage/EngageTransport.d.ts +158 -0
- package/lib/typescript/features/engage/EngageVariantContent.d.ts +12 -0
- package/lib/typescript/features/engage/attachmentCapture.d.ts +17 -0
- package/lib/typescript/features/engage/captureVoiceAttachment.d.ts +31 -0
- package/lib/typescript/features/engage/engageCoachmarkTour.d.ts +18 -0
- package/lib/typescript/features/engage/engageGameLogic.d.ts +34 -0
- package/lib/typescript/features/engage/engageMediaSizing.d.ts +23 -0
- package/lib/typescript/features/engage/engageMultiStepSheet.d.ts +25 -0
- package/lib/typescript/features/engage/engageOutcome.d.ts +38 -0
- package/lib/typescript/features/engage/engagePushTokenBridge.d.ts +30 -0
- package/lib/typescript/features/engage/engageShakeBridge.d.ts +20 -0
- package/lib/typescript/features/engage/engageSignals.d.ts +13 -0
- package/lib/typescript/features/engage/engageStoreReviewBridge.d.ts +23 -0
- package/lib/typescript/features/engage/engageTestSeenStore.d.ts +46 -0
- package/lib/typescript/features/engage/engageThrottle.d.ts +180 -0
- package/lib/typescript/features/engage/engageTriggerEngine.d.ts +16 -0
- package/lib/typescript/features/engage/engageTypes.d.ts +576 -0
- package/lib/typescript/features/engage/engageVariantResolver.d.ts +46 -0
- package/lib/typescript/features/engage/engageWindowInsets.d.ts +25 -0
- package/lib/typescript/features/engage/gestureTriggerDetector.d.ts +20 -0
- package/lib/typescript/features/engage/transcription/TranscriptionProvider.d.ts +51 -0
- package/lib/typescript/features/install-referrer/installReferrer.d.ts +39 -0
- package/lib/typescript/features/journey/ScaleBunDebugRoot.d.ts +49 -0
- package/lib/typescript/features/journey/ScaleBunFlatList.d.ts +20 -0
- package/lib/typescript/features/journey/ScaleBunImpression.d.ts +30 -0
- package/lib/typescript/features/journey/ScaleBunScrollView.d.ts +25 -0
- package/lib/typescript/features/journey/ScaleBunSectionList.d.ts +20 -0
- package/lib/typescript/features/journey/autoInstrumentScroll.d.ts +46 -0
- package/lib/typescript/features/journey/calibrationContext.d.ts +26 -0
- package/lib/typescript/features/journey/gestureBuffer.d.ts +27 -0
- package/lib/typescript/features/journey/gestureDetector.d.ts +40 -0
- package/lib/typescript/features/journey/impression.d.ts +48 -0
- package/lib/typescript/features/journey/interactionProtocol.d.ts +159 -0
- package/lib/typescript/features/journey/journeyManager.d.ts +62 -0
- package/lib/typescript/features/journey/journeyTypes.d.ts +161 -0
- package/lib/typescript/features/journey/nativeScroll.d.ts +47 -0
- package/lib/typescript/features/journey/navDetector.d.ts +42 -0
- package/lib/typescript/features/journey/screenshotHelper.d.ts +33 -0
- package/lib/typescript/features/journey/scrollContext.d.ts +49 -0
- package/lib/typescript/features/journey/targetGeometry.d.ts +126 -0
- package/lib/typescript/features/journey/targetRegistry.d.ts +28 -0
- package/lib/typescript/features/journey/touchTarget.d.ts +174 -0
- package/lib/typescript/features/journey/uiState.d.ts +93 -0
- package/lib/typescript/features/navigation/AutoScreenDetector.d.ts +196 -0
- package/lib/typescript/features/network/NetworkFeature.d.ts +43 -0
- package/lib/typescript/features/network/index.d.ts +46 -0
- package/lib/typescript/features/network/thirdParty.d.ts +95 -0
- package/lib/typescript/features/ota/OtaEventEmitter.d.ts +93 -0
- package/lib/typescript/features/ota/OtaOrchestrator.d.ts +287 -0
- package/lib/typescript/features/ota/OtaTypes.d.ts +193 -0
- package/lib/typescript/features/ota/deviceAttributes.d.ts +18 -0
- package/lib/typescript/features/ota/environment.d.ts +99 -0
- package/lib/typescript/features/ota/geoCountry.d.ts +14 -0
- package/lib/typescript/features/ota/retry.d.ts +53 -0
- package/lib/typescript/features/ota/signedDownload.d.ts +81 -0
- package/lib/typescript/features/ota/useOtaUpdate.d.ts +72 -0
- package/lib/typescript/features/performance/PerformanceFeature.d.ts +132 -0
- package/lib/typescript/features/performance/collectors/AppLaunchCollector.d.ts +27 -0
- package/lib/typescript/features/performance/collectors/AutoScreenLoadCollector.d.ts +70 -0
- package/lib/typescript/features/performance/collectors/CustomTraceCollector.d.ts +35 -0
- package/lib/typescript/features/performance/collectors/FrameMetricsCollector.d.ts +74 -0
- package/lib/typescript/features/performance/collectors/JsStallCollector.d.ts +45 -0
- package/lib/typescript/features/performance/collectors/NetworkPerfCollector.d.ts +23 -0
- package/lib/typescript/features/performance/collectors/ScreenLoadCollector.d.ts +30 -0
- package/lib/typescript/features/performance/collectors/UiHangCollector.d.ts +21 -0
- package/lib/typescript/features/performance/config.d.ts +73 -0
- package/lib/typescript/features/performance/getNativePerformanceModule.d.ts +2 -0
- package/lib/typescript/features/performance/index.d.ts +10 -0
- package/lib/typescript/features/performance/metrics/MetricsEngine.d.ts +69 -0
- package/lib/typescript/features/performance/models.d.ts +169 -0
- package/lib/typescript/features/performance/transport/PerformanceTransport.d.ts +40 -0
- package/lib/typescript/features/profiler/ProfilerFeature.d.ts +92 -0
- package/lib/typescript/features/profiler/config.d.ts +85 -0
- package/lib/typescript/features/profiler/contracts.d.ts +142 -0
- package/lib/typescript/features/profiler/index.d.ts +13 -0
- package/lib/typescript/features/profiler/models.d.ts +332 -0
- package/lib/typescript/features/profiler/transport/ProfilerTransport.d.ts +30 -0
- package/lib/typescript/features/replay/bridge/adapters/bridgeAdapter.d.ts +52 -0
- package/lib/typescript/features/replay/bridge/eventEmitter.d.ts +100 -0
- package/lib/typescript/features/replay/bridge/nativeModule.d.ts +166 -0
- package/lib/typescript/features/replay/bridge/nativeQuota.d.ts +26 -0
- package/lib/typescript/features/replay/core/clock/clock.d.ts +16 -0
- package/lib/typescript/features/replay/core/config/defaults.d.ts +28 -0
- package/lib/typescript/features/replay/core/config/validator.d.ts +13 -0
- package/lib/typescript/features/replay/core/env/environmentDetector.d.ts +14 -0
- package/lib/typescript/features/replay/core/errors/safeCall.d.ts +12 -0
- package/lib/typescript/features/replay/core/ids/sessionId.d.ts +15 -0
- package/lib/typescript/features/replay/core/logger/logger.d.ts +15 -0
- package/lib/typescript/features/replay/core/privacy/privacyTypes.d.ts +24 -0
- package/lib/typescript/features/replay/core/queue/boundedQueue.d.ts +29 -0
- package/lib/typescript/features/replay/integrations/alert/alertInstrumentation.d.ts +48 -0
- package/lib/typescript/features/replay/integrations/logs/consoleIntegration.d.ts +18 -0
- package/lib/typescript/features/replay/integrations/network/networkAdapter.d.ts +31 -0
- package/lib/typescript/features/replay/integrations/react-navigation/navigationIntegration.d.ts +25 -0
- package/lib/typescript/features/replay/integrations/touch/ReplayRoot.d.ts +26 -0
- package/lib/typescript/features/replay/pipeline/batching/batchManager.d.ts +47 -0
- package/lib/typescript/features/replay/pipeline/envelope/envelopeBuilder.d.ts +12 -0
- package/lib/typescript/features/replay/pipeline/retry/retryPolicy.d.ts +17 -0
- package/lib/typescript/features/replay/pipeline/transport/transportTypes.d.ts +40 -0
- package/lib/typescript/features/replay/public/api.d.ts +83 -0
- package/lib/typescript/features/replay/public/enums.d.ts +73 -0
- package/lib/typescript/features/replay/public/types.d.ts +249 -0
- package/lib/typescript/features/replay/replay/breadcrumbs/breadcrumbCollector.d.ts +26 -0
- package/lib/typescript/features/replay/replay/frames/frameModels.d.ts +23 -0
- package/lib/typescript/features/replay/replay/session/sessionOrchestrator.d.ts +53 -0
- package/lib/typescript/features/replay/replay/timeline/timelineModels.d.ts +29 -0
- package/lib/typescript/features/replay/transport/BackendReplayTransport.d.ts +45 -0
- package/lib/typescript/features/replay/transport/CompositeReplayTransport.d.ts +22 -0
- package/lib/typescript/features/replay/transport/DesktopReplayTransport.d.ts +35 -0
- package/lib/typescript/features/replay/transport/ReplayTransport.d.ts +72 -0
- package/lib/typescript/features/session/BackendSessionAdapter.d.ts +528 -0
- package/lib/typescript/features/session/DesktopSessionTransport.d.ts +28 -0
- package/lib/typescript/features/session/JourneyEventPipeline.d.ts +74 -0
- package/lib/typescript/features/session/ReplayCaptureManager.d.ts +391 -0
- package/lib/typescript/features/session/ScrollTracker.d.ts +48 -0
- package/lib/typescript/features/session/SessionManager.d.ts +414 -0
- package/lib/typescript/features/session/SyncDecisionEngine.d.ts +33 -0
- package/lib/typescript/features/session/frameLink.d.ts +27 -0
- package/lib/typescript/features/session/frameScrollState.d.ts +27 -0
- package/lib/typescript/features/session/index.d.ts +23 -0
- package/lib/typescript/features/session/nativeCapture.d.ts +18 -0
- package/lib/typescript/features/session/outboxFrameCapture.d.ts +20 -0
- package/lib/typescript/features/session/sessionTypes.d.ts +362 -0
- package/lib/typescript/features/session/viewportPlausibility.d.ts +72 -0
- package/lib/typescript/features/skan/skanBridge.d.ts +18 -0
- package/lib/typescript/features/skan/skanConversionManager.d.ts +69 -0
- package/lib/typescript/index.d.ts +59 -0
- package/lib/typescript/integrations/fetch/fetchInterceptor.d.ts +41 -0
- package/lib/typescript/integrations/navigation/screenTracker.d.ts +1 -0
- package/lib/typescript/integrations/network/bodyCapture.d.ts +101 -0
- package/lib/typescript/integrations/xhr/xhrInterceptor.d.ts +46 -0
- package/lib/typescript/metro/composeSourceMap.d.ts +26 -0
- package/lib/typescript/metro/featureModules.d.ts +49 -0
- package/lib/typescript/metro/index.d.ts +99 -0
- package/lib/typescript/metro/optionalDependencyStub.d.ts +14 -0
- package/lib/typescript/metro/optionalModules.d.ts +20 -0
- package/lib/typescript/metro/serializerCompose.d.ts +46 -0
- package/lib/typescript/pipeline/dispatcher/dispatcher.d.ts +7 -0
- package/lib/typescript/pipeline/envelope/envelope.d.ts +16 -0
- package/lib/typescript/pipeline/envelope/serializer.d.ts +7 -0
- package/lib/typescript/pipeline/processors/dedupe.d.ts +1 -0
- package/lib/typescript/pipeline/processors/enrich.d.ts +3 -0
- package/lib/typescript/pipeline/processors/sampling.d.ts +1 -0
- package/lib/typescript/pipeline/processors/sanitize.d.ts +3 -0
- package/lib/typescript/pipeline/queue/flushQueue.d.ts +12 -0
- package/lib/typescript/pipeline/queue/memoryQueue.d.ts +12 -0
- package/lib/typescript/pipeline/queue/persistentQueue.d.ts +120 -0
- package/lib/typescript/pipeline/queue/queuePolicy.d.ts +1 -0
- package/lib/typescript/pipeline/scheduler/flushScheduler.d.ts +9 -0
- package/lib/typescript/pipeline/scheduler/retryPolicy.d.ts +5 -0
- package/lib/typescript/public/ScaleBunErrorBoundary.d.ts +44 -0
- package/lib/typescript/public/ScaleBunFacade.d.ts +800 -0
- package/lib/typescript/public/ScaleBunProvider.d.ts +23 -0
- package/lib/typescript/public/typedTracker.d.ts +88 -0
- package/lib/typescript/public/types.d.ts +316 -0
- package/lib/typescript/push/PushManager.d.ts +69 -0
- package/lib/typescript/push/adapters/ManualAdapter.d.ts +40 -0
- package/lib/typescript/push/adapters/NativeBridgeAdapter.d.ts +37 -0
- package/lib/typescript/push/adapters/NoopAdapter.d.ts +21 -0
- package/lib/typescript/push/adapters/RNFirebaseMessagingAdapter.d.ts +39 -0
- package/lib/typescript/push/adapters/loadMessaging.d.ts +17 -0
- package/lib/typescript/push/adapters/loadNotifee.d.ts +15 -0
- package/lib/typescript/push/adapters/selectAdapter.d.ts +20 -0
- package/lib/typescript/push/detect/capabilities.d.ts +15 -0
- package/lib/typescript/push/index.d.ts +10 -0
- package/lib/typescript/push/native/nativeNotifications.d.ts +65 -0
- package/lib/typescript/push/types.d.ts +143 -0
- package/lib/typescript/specs/NativeReplaySdk.d.ts +69 -0
- package/lib/typescript/specs/NativeScaleBunCrash.d.ts +58 -0
- package/lib/typescript/specs/NativeScaleBunInstallReferrer.d.ts +28 -0
- package/lib/typescript/specs/NativeScaleBunOta.d.ts +141 -0
- package/lib/typescript/specs/NativeScaleBunPerformance.d.ts +31 -0
- package/lib/typescript/specs/NativeScaleBunProfiler.d.ts +38 -0
- package/lib/typescript/specs/NativeScaleBunStorage.d.ts +55 -0
- package/lib/typescript/storage/StorageBackend.d.ts +131 -0
- package/lib/typescript/storage/db/sqlite.d.ts +1 -0
- package/lib/typescript/storage/files/fileStore.d.ts +1 -0
- package/lib/typescript/transport/auth/sdkSession.d.ts +10 -0
- package/lib/typescript/transport/backoff/exponentialJitter.d.ts +5 -0
- package/lib/typescript/transport/http/endpoints.d.ts +26 -0
- package/lib/typescript/transport/http/httpClient.d.ts +23 -0
- package/lib/typescript/transport/rateLimit/retryAfter.d.ts +1 -0
- package/lib/typescript/transport/signing/requestSigner.d.ts +1 -0
- package/lib/typescript/vendor/protocol/index.d.ts +345 -0
- package/lib/typescript/vendor/protocol/internal/validation.d.ts +114 -0
- package/lib/typescript/vendor/sdk-contracts/bridge.d.ts +104 -0
- package/lib/typescript/vendor/sdk-contracts/config.d.ts +156 -0
- package/lib/typescript/vendor/sdk-contracts/events.d.ts +42 -0
- package/lib/typescript/vendor/sdk-contracts/features.d.ts +38 -0
- package/lib/typescript/vendor/sdk-contracts/index.d.ts +15 -0
- package/lib/typescript/vendor/sdk-contracts/platform.d.ts +35 -0
- package/lib/typescript/vendor/sdk-contracts/session-boundary.d.ts +42 -0
- package/lib/typescript/vendor/sdk-contracts/session.d.ts +157 -0
- package/package.json +153 -0
- package/react-native.config.js +24 -0
- package/scalebun-react-native.podspec +44 -0
- package/src/analytics/EventTracker.ts +654 -0
- package/src/analytics/automaticEvents.ts +109 -0
- package/src/analytics/batching.ts +54 -0
- package/src/analytics/eventLane.ts +48 -0
- package/src/analytics/revenue.ts +143 -0
- package/src/analytics/subscription.ts +145 -0
- package/src/bootstrap/FeatureRegistry.ts +81 -0
- package/src/bootstrap/SDKBootstrapper.ts +769 -0
- package/src/bucketing/fnv1a32.ts +40 -0
- package/src/compat/codepush.ts +189 -0
- package/src/config/ConfigManager.ts +233 -0
- package/src/config/configTypes.ts +62 -0
- package/src/config/otaPolicyState.ts +79 -0
- package/src/config/quotaState.ts +484 -0
- package/src/core/architecture.ts +39 -0
- package/src/core/clock/now.ts +6 -0
- package/src/core/config/defaults.ts +0 -0
- package/src/core/config/schema.ts +455 -0
- package/src/core/constants/endpoints.ts +12 -0
- package/src/core/constants/protocol.ts +24 -0
- package/src/core/constants/timings.ts +25 -0
- package/src/core/constants/version.ts +11 -0
- package/src/core/context/app.ts +0 -0
- package/src/core/context/device.ts +169 -0
- package/src/core/context/session.ts +0 -0
- package/src/core/context/user.ts +26 -0
- package/src/core/contracts/IFeature.ts +53 -0
- package/src/core/di/container.ts +26 -0
- package/src/core/encoding/base64.ts +46 -0
- package/src/core/id/deviceId.ts +51 -0
- package/src/core/id/installationId.ts +52 -0
- package/src/core/id/sessionId.ts +0 -0
- package/src/core/lifecycle/appLifecycle.ts +33 -0
- package/src/core/lifecycle/crashSafe.ts +29 -0
- package/src/core/logger/errorClassification.ts +108 -0
- package/src/core/logger/internalLogger.ts +65 -0
- package/src/core/logger/levels.ts +0 -0
- package/src/crypto/hmacSha256.ts +106 -0
- package/src/debug/bootstrap.ts +436 -0
- package/src/debug/commands.ts +597 -0
- package/src/debug/configBuilder.ts +56 -0
- package/src/debug/exportBridge.ts +155 -0
- package/src/debug/hostResolver.ts +34 -0
- package/src/debug/index.ts +25 -0
- package/src/debug/metrics.ts +29 -0
- package/src/debug/perf.ts +212 -0
- package/src/debug/perfWiring.ts +119 -0
- package/src/debug/protocol.ts +58 -0
- package/src/debug/redaction.ts +483 -0
- package/src/debug/replayWiring.ts +148 -0
- package/src/debug/screenTracking.ts +55 -0
- package/src/debug/sessionWiring.ts +59 -0
- package/src/debug/stream.ts +561 -0
- package/src/debug/transport.ts +440 -0
- package/src/features/bugreport/BugReportFeature.ts +128 -0
- package/src/features/bugreport/buildPayload.ts +116 -0
- package/src/features/bugreport/index.ts +0 -0
- package/src/features/crash/CrashFeature.ts +87 -0
- package/src/features/crash/CrashReporter.ts +189 -0
- package/src/features/crash/NativeCrashFeature.ts +42 -0
- package/src/features/crash/capture.ts +48 -0
- package/src/features/crash/globalHandler.ts +39 -0
- package/src/features/crash/index.ts +8 -0
- package/src/features/crash/nativeCrashBridge.ts +352 -0
- package/src/features/crash/rejectionHandler.ts +196 -0
- package/src/features/crash/scrubCrash.ts +175 -0
- package/src/features/engage/EngageAnchor.tsx +159 -0
- package/src/features/engage/EngageArchetypeRenderers.tsx +3705 -0
- package/src/features/engage/EngageInAppView.tsx +2678 -0
- package/src/features/engage/EngageInlinePlacement.tsx +169 -0
- package/src/features/engage/EngagePromptProvider.tsx +1318 -0
- package/src/features/engage/EngagePromptView.tsx +1400 -0
- package/src/features/engage/EngageTransport.ts +668 -0
- package/src/features/engage/EngageVariantContent.tsx +1483 -0
- package/src/features/engage/__test-support__/reactNativeStub.js +40 -0
- package/src/features/engage/attachmentCapture.ts +45 -0
- package/src/features/engage/captureVoiceAttachment.ts +81 -0
- package/src/features/engage/engageCoachmarkTour.ts +120 -0
- package/src/features/engage/engageGameLogic.ts +347 -0
- package/src/features/engage/engageMediaSizing.ts +76 -0
- package/src/features/engage/engageMultiStepSheet.ts +53 -0
- package/src/features/engage/engageOutcome.ts +157 -0
- package/src/features/engage/engagePushTokenBridge.ts +84 -0
- package/src/features/engage/engageShakeBridge.ts +67 -0
- package/src/features/engage/engageSignals.ts +40 -0
- package/src/features/engage/engageStoreReviewBridge.ts +48 -0
- package/src/features/engage/engageTestSeenStore.ts +95 -0
- package/src/features/engage/engageThrottle.ts +478 -0
- package/src/features/engage/engageTriggerEngine.ts +350 -0
- package/src/features/engage/engageTypes.ts +712 -0
- package/src/features/engage/engageVariantResolver.ts +364 -0
- package/src/features/engage/engageWindowInsets.ts +108 -0
- package/src/features/engage/gestureTriggerDetector.ts +83 -0
- package/src/features/engage/transcription/TranscriptionProvider.ts +68 -0
- package/src/features/install-referrer/installReferrer.ts +112 -0
- package/src/features/journey/ScaleBunDebugRoot.tsx +1045 -0
- package/src/features/journey/ScaleBunFlatList.tsx +39 -0
- package/src/features/journey/ScaleBunImpression.tsx +109 -0
- package/src/features/journey/ScaleBunScrollView.tsx +101 -0
- package/src/features/journey/ScaleBunSectionList.tsx +39 -0
- package/src/features/journey/autoInstrumentScroll.ts +155 -0
- package/src/features/journey/calibrationContext.ts +44 -0
- package/src/features/journey/gestureBuffer.ts +59 -0
- package/src/features/journey/gestureDetector.ts +162 -0
- package/src/features/journey/impression.ts +92 -0
- package/src/features/journey/interactionProtocol.ts +243 -0
- package/src/features/journey/journeyManager.ts +469 -0
- package/src/features/journey/journeyTypes.ts +215 -0
- package/src/features/journey/nativeScroll.ts +94 -0
- package/src/features/journey/navDetector.ts +149 -0
- package/src/features/journey/screenshotHelper.ts +137 -0
- package/src/features/journey/scrollContext.ts +146 -0
- package/src/features/journey/targetGeometry.ts +197 -0
- package/src/features/journey/targetRegistry.ts +43 -0
- package/src/features/journey/touchTarget.ts +339 -0
- package/src/features/journey/uiState.ts +182 -0
- package/src/features/navigation/AutoScreenDetector.ts +617 -0
- package/src/features/network/NetworkFeature.ts +232 -0
- package/src/features/network/index.ts +59 -0
- package/src/features/network/thirdParty.ts +160 -0
- package/src/features/ota/OtaEventEmitter.ts +187 -0
- package/src/features/ota/OtaOrchestrator.ts +1513 -0
- package/src/features/ota/OtaTypes.ts +230 -0
- package/src/features/ota/deviceAttributes.ts +46 -0
- package/src/features/ota/environment.ts +199 -0
- package/src/features/ota/geoCountry.ts +85 -0
- package/src/features/ota/retry.ts +123 -0
- package/src/features/ota/signedDownload.ts +202 -0
- package/src/features/ota/useOtaUpdate.ts +161 -0
- package/src/features/performance/PerformanceFeature.ts +729 -0
- package/src/features/performance/collectors/AppLaunchCollector.ts +131 -0
- package/src/features/performance/collectors/AutoScreenLoadCollector.ts +258 -0
- package/src/features/performance/collectors/CustomTraceCollector.ts +116 -0
- package/src/features/performance/collectors/FrameMetricsCollector.ts +210 -0
- package/src/features/performance/collectors/JsStallCollector.ts +184 -0
- package/src/features/performance/collectors/NetworkPerfCollector.ts +69 -0
- package/src/features/performance/collectors/ScreenLoadCollector.ts +95 -0
- package/src/features/performance/collectors/UiHangCollector.ts +98 -0
- package/src/features/performance/config.ts +136 -0
- package/src/features/performance/getNativePerformanceModule.ts +38 -0
- package/src/features/performance/index.ts +28 -0
- package/src/features/performance/metrics/MetricsEngine.ts +152 -0
- package/src/features/performance/models.ts +235 -0
- package/src/features/performance/transport/PerformanceTransport.ts +161 -0
- package/src/features/profiler/ProfilerFeature.ts +661 -0
- package/src/features/profiler/config.ts +230 -0
- package/src/features/profiler/contracts.ts +176 -0
- package/src/features/profiler/index.ts +45 -0
- package/src/features/profiler/models.ts +430 -0
- package/src/features/profiler/transport/ProfilerTransport.ts +93 -0
- package/src/features/replay/bridge/adapters/bridgeAdapter.ts +235 -0
- package/src/features/replay/bridge/eventEmitter.ts +176 -0
- package/src/features/replay/bridge/nativeModule.ts +252 -0
- package/src/features/replay/bridge/nativeQuota.ts +111 -0
- package/src/features/replay/core/clock/clock.ts +38 -0
- package/src/features/replay/core/config/defaults.ts +66 -0
- package/src/features/replay/core/config/validator.ts +113 -0
- package/src/features/replay/core/env/environmentDetector.ts +21 -0
- package/src/features/replay/core/errors/safeCall.ts +34 -0
- package/src/features/replay/core/ids/sessionId.ts +44 -0
- package/src/features/replay/core/logger/logger.ts +36 -0
- package/src/features/replay/core/privacy/privacyTypes.ts +41 -0
- package/src/features/replay/core/queue/boundedQueue.ts +71 -0
- package/src/features/replay/integrations/alert/alertInstrumentation.ts +277 -0
- package/src/features/replay/integrations/logs/consoleIntegration.ts +136 -0
- package/src/features/replay/integrations/network/networkAdapter.ts +73 -0
- package/src/features/replay/integrations/react-navigation/navigationIntegration.ts +89 -0
- package/src/features/replay/integrations/touch/ReplayRoot.tsx +114 -0
- package/src/features/replay/pipeline/batching/batchManager.ts +133 -0
- package/src/features/replay/pipeline/envelope/envelopeBuilder.ts +66 -0
- package/src/features/replay/pipeline/retry/retryPolicy.ts +62 -0
- package/src/features/replay/pipeline/transport/transportTypes.ts +85 -0
- package/src/features/replay/public/api.ts +364 -0
- package/src/features/replay/public/enums.ts +78 -0
- package/src/features/replay/public/types.ts +297 -0
- package/src/features/replay/replay/breadcrumbs/breadcrumbCollector.ts +115 -0
- package/src/features/replay/replay/frames/frameModels.ts +45 -0
- package/src/features/replay/replay/session/sessionOrchestrator.ts +286 -0
- package/src/features/replay/replay/timeline/timelineModels.ts +129 -0
- package/src/features/replay/transport/BackendReplayTransport.ts +215 -0
- package/src/features/replay/transport/CompositeReplayTransport.ts +82 -0
- package/src/features/replay/transport/DesktopReplayTransport.ts +140 -0
- package/src/features/replay/transport/ReplayTransport.ts +84 -0
- package/src/features/session/BackendSessionAdapter.ts +1977 -0
- package/src/features/session/DesktopSessionTransport.ts +130 -0
- package/src/features/session/JourneyEventPipeline.ts +278 -0
- package/src/features/session/ReplayCaptureManager.ts +1401 -0
- package/src/features/session/ScrollTracker.ts +166 -0
- package/src/features/session/SessionManager.ts +1687 -0
- package/src/features/session/SyncDecisionEngine.ts +117 -0
- package/src/features/session/frameLink.ts +41 -0
- package/src/features/session/frameScrollState.ts +36 -0
- package/src/features/session/index.ts +88 -0
- package/src/features/session/nativeCapture.ts +43 -0
- package/src/features/session/outboxFrameCapture.ts +79 -0
- package/src/features/session/sessionTypes.ts +528 -0
- package/src/features/session/viewportPlausibility.ts +134 -0
- package/src/features/skan/skanBridge.ts +53 -0
- package/src/features/skan/skanConversionManager.ts +173 -0
- package/src/index.ts +206 -0
- package/src/integrations/fetch/fetchInterceptor.ts +201 -0
- package/src/integrations/navigation/screenTracker.ts +0 -0
- package/src/integrations/network/bodyCapture.ts +328 -0
- package/src/integrations/xhr/xhrInterceptor.ts +259 -0
- package/src/metro/composeSourceMap.ts +104 -0
- package/src/metro/featureModules.ts +143 -0
- package/src/metro/index.ts +336 -0
- package/src/metro/optionalDependencyStub.ts +13 -0
- package/src/metro/optionalModules.ts +27 -0
- package/src/metro/serializerCompose.ts +193 -0
- package/src/pipeline/dispatcher/dispatcher.ts +22 -0
- package/src/pipeline/envelope/envelope.ts +31 -0
- package/src/pipeline/envelope/serializer.ts +14 -0
- package/src/pipeline/processors/dedupe.ts +0 -0
- package/src/pipeline/processors/enrich.ts +11 -0
- package/src/pipeline/processors/sampling.ts +0 -0
- package/src/pipeline/processors/sanitize.ts +23 -0
- package/src/pipeline/queue/flushQueue.ts +144 -0
- package/src/pipeline/queue/memoryQueue.ts +31 -0
- package/src/pipeline/queue/persistentQueue.ts +385 -0
- package/src/pipeline/queue/queuePolicy.ts +0 -0
- package/src/pipeline/scheduler/flushScheduler.ts +47 -0
- package/src/pipeline/scheduler/retryPolicy.ts +8 -0
- package/src/public/ScaleBunErrorBoundary.tsx +91 -0
- package/src/public/ScaleBunFacade.ts +2129 -0
- package/src/public/ScaleBunProvider.tsx +91 -0
- package/src/public/typedTracker.ts +123 -0
- package/src/public/types.ts +362 -0
- package/src/push/PushManager.ts +318 -0
- package/src/push/adapters/ManualAdapter.ts +100 -0
- package/src/push/adapters/NativeBridgeAdapter.ts +142 -0
- package/src/push/adapters/NoopAdapter.ts +46 -0
- package/src/push/adapters/RNFirebaseMessagingAdapter.ts +271 -0
- package/src/push/adapters/loadMessaging.ts +24 -0
- package/src/push/adapters/loadNotifee.ts +29 -0
- package/src/push/adapters/selectAdapter.ts +176 -0
- package/src/push/detect/capabilities.ts +124 -0
- package/src/push/index.ts +22 -0
- package/src/push/native/nativeNotifications.ts +207 -0
- package/src/push/types.ts +159 -0
- package/src/specs/NativeReplaySdk.ts +101 -0
- package/src/specs/NativeScaleBunCrash.ts +64 -0
- package/src/specs/NativeScaleBunInstallReferrer.ts +29 -0
- package/src/specs/NativeScaleBunOta.ts +154 -0
- package/src/specs/NativeScaleBunPerformance.ts +34 -0
- package/src/specs/NativeScaleBunProfiler.ts +41 -0
- package/src/specs/NativeScaleBunStorage.ts +59 -0
- package/src/storage/StorageBackend.ts +272 -0
- package/src/storage/db/sqlite.ts +0 -0
- package/src/storage/files/fileStore.ts +0 -0
- package/src/transport/auth/sdkSession.ts +27 -0
- package/src/transport/backoff/exponentialJitter.ts +9 -0
- package/src/transport/http/endpoints.ts +33 -0
- package/src/transport/http/httpClient.ts +73 -0
- package/src/transport/rateLimit/retryAfter.ts +0 -0
- package/src/transport/signing/requestSigner.ts +0 -0
- package/src/vendor/protocol/index.ts +391 -0
- package/src/vendor/protocol/internal/validation.ts +497 -0
- package/src/vendor/sdk-contracts/bridge.ts +162 -0
- package/src/vendor/sdk-contracts/config.ts +192 -0
- package/src/vendor/sdk-contracts/events.ts +50 -0
- package/src/vendor/sdk-contracts/features.ts +42 -0
- package/src/vendor/sdk-contracts/index.ts +98 -0
- package/src/vendor/sdk-contracts/platform.ts +42 -0
- package/src/vendor/sdk-contracts/session-boundary.ts +55 -0
- package/src/vendor/sdk-contracts/session.ts +225 -0
- package/src/vendor/vendor.manifest +10 -0
|
@@ -0,0 +1,2678 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ScaleBun SDK — Engage In-App Message View (shared cross-platform JS overlay, D4)
|
|
3
|
+
*
|
|
4
|
+
* One renderer, seven layout branches — chosen from `InAppMessageConfig.layout`
|
|
5
|
+
* delivered by the config lane. App developers import and mount ONE component
|
|
6
|
+
* (`EngageInAppView` or via `EngagePromptProvider`) and write zero layout code:
|
|
7
|
+
* the SDK reads the layout field and auto-selects the correct branch.
|
|
8
|
+
*
|
|
9
|
+
* Layout → branch mapping (1:1, config-driven):
|
|
10
|
+
* modal → centered dialog (backdrop + rounded card)
|
|
11
|
+
* fullscreen → edge-to-edge takeover (no margins, no rounded corners)
|
|
12
|
+
* bottom_sheet → slides up from bottom (rounded top corners)
|
|
13
|
+
* top_banner → absolute strip pinned to top
|
|
14
|
+
* bottom_banner→ absolute strip pinned to bottom
|
|
15
|
+
* tooltip → small compact popup (anchored look, top-right close)
|
|
16
|
+
* toast → transient strip, auto-dismisses after 3 seconds
|
|
17
|
+
*
|
|
18
|
+
* Legacy `banner` (old wire value) gracefully maps to `top_banner`.
|
|
19
|
+
*
|
|
20
|
+
* Callbacks (unchanged):
|
|
21
|
+
* onShow() — fired once when first visible (provider records impression)
|
|
22
|
+
* onCta(cta) — primary CTA tap (provider emits `click`; deep link surfaced to host)
|
|
23
|
+
* onComplete() — guided flow finished (provider emits `completion`)
|
|
24
|
+
* onDismiss() — secondary CTA / close / backdrop / auto-dismiss (provider emits `dismiss`)
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import React, { Component, useCallback, useEffect, useMemo, useRef, useState, type ReactElement, type ReactNode } from 'react';
|
|
28
|
+
import {
|
|
29
|
+
AccessibilityInfo,
|
|
30
|
+
Modal,
|
|
31
|
+
Platform,
|
|
32
|
+
SafeAreaView,
|
|
33
|
+
ScrollView,
|
|
34
|
+
StatusBar,
|
|
35
|
+
useWindowDimensions,
|
|
36
|
+
View,
|
|
37
|
+
Text,
|
|
38
|
+
Image,
|
|
39
|
+
KeyboardAvoidingView,
|
|
40
|
+
Pressable,
|
|
41
|
+
type LayoutChangeEvent,
|
|
42
|
+
type StyleProp,
|
|
43
|
+
type ViewStyle,
|
|
44
|
+
type TextStyle,
|
|
45
|
+
type ImageStyle,
|
|
46
|
+
} from 'react-native';
|
|
47
|
+
import type {
|
|
48
|
+
InAppGameRequestHandler,
|
|
49
|
+
InAppGameResult,
|
|
50
|
+
InAppMessageConfig,
|
|
51
|
+
InAppRenderSpec,
|
|
52
|
+
} from './engageTypes';
|
|
53
|
+
import { useEngageAnchorRegistry, type EngageAnchorRect } from './EngageAnchor';
|
|
54
|
+
import {
|
|
55
|
+
coachmarkAnchorError,
|
|
56
|
+
normalizeCoachmarkSteps,
|
|
57
|
+
normalizeLegacyAnchoredStep,
|
|
58
|
+
resolveAnchoredSurfaceKind,
|
|
59
|
+
resolveCoachmarkFinishMode,
|
|
60
|
+
resolveCoachmarkStepIndex,
|
|
61
|
+
} from './engageCoachmarkTour';
|
|
62
|
+
import {
|
|
63
|
+
ZERO_ENGAGE_WINDOW_INSETS,
|
|
64
|
+
useEngageWindowInsets,
|
|
65
|
+
type EngageWindowInsets,
|
|
66
|
+
} from './engageWindowInsets';
|
|
67
|
+
import { logger } from '../../core/logger/internalLogger';
|
|
68
|
+
import { resolveArchetypeContent } from './EngageArchetypeRenderers';
|
|
69
|
+
import { resolveVariantContent } from './EngageVariantContent';
|
|
70
|
+
import {
|
|
71
|
+
resolveInAppMechanic,
|
|
72
|
+
resolveInAppPresentation,
|
|
73
|
+
type InAppArchetype,
|
|
74
|
+
type InAppMountModel,
|
|
75
|
+
type ResolvedInAppPresentation,
|
|
76
|
+
} from './engageVariantResolver';
|
|
77
|
+
import {
|
|
78
|
+
authoredPreviewGameResult,
|
|
79
|
+
buildInAppGameRequest,
|
|
80
|
+
inAppGameAllowedOutcomeIds,
|
|
81
|
+
isInAppGameVariant,
|
|
82
|
+
validateInAppGameResult,
|
|
83
|
+
} from './engageGameLogic';
|
|
84
|
+
import {
|
|
85
|
+
inAppOutcomeIconGlyph,
|
|
86
|
+
inAppOutcomeTerminalForCta,
|
|
87
|
+
resolveInAppOutcomeConfig,
|
|
88
|
+
resolveInAppOutcomeTerminal,
|
|
89
|
+
type InAppOutcomeRequest,
|
|
90
|
+
type InAppOutcomeTerminal,
|
|
91
|
+
type ResolvedInAppOutcomeConfig,
|
|
92
|
+
} from './engageOutcome';
|
|
93
|
+
import {
|
|
94
|
+
resolveInAppMediaAspectRatio,
|
|
95
|
+
resolveInAppMediaHeight,
|
|
96
|
+
} from './engageMediaSizing';
|
|
97
|
+
import {
|
|
98
|
+
resolveMultiStepSheetIndex,
|
|
99
|
+
resolveMultiStepSheetLabels,
|
|
100
|
+
resolveMultiStepSheetTerminalAction,
|
|
101
|
+
type MultiStepSheetTerminalAction,
|
|
102
|
+
} from './engageMultiStepSheet';
|
|
103
|
+
|
|
104
|
+
let gameAttemptSequence = 0;
|
|
105
|
+
|
|
106
|
+
/** The seven distinct presentation branches (config-driven, 1:1 with layout strings). */
|
|
107
|
+
export type InAppLayout =
|
|
108
|
+
| 'modal'
|
|
109
|
+
| 'fullscreen'
|
|
110
|
+
| 'bottom_sheet'
|
|
111
|
+
| 'top_banner'
|
|
112
|
+
| 'bottom_banner'
|
|
113
|
+
| 'tooltip'
|
|
114
|
+
| 'toast';
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Map the contract `layout` string onto one of the seven render branches.
|
|
118
|
+
* Legacy `banner` value → `top_banner` for backward compat with old configs.
|
|
119
|
+
* Any unknown future value → `modal` (safe default).
|
|
120
|
+
*/
|
|
121
|
+
export function resolveInAppLayout(layout: InAppMessageConfig['layout']): InAppLayout {
|
|
122
|
+
switch (layout) {
|
|
123
|
+
case 'modal': return 'modal';
|
|
124
|
+
case 'fullscreen': return 'fullscreen';
|
|
125
|
+
case 'bottom_sheet': return 'bottom_sheet';
|
|
126
|
+
case 'top_banner': return 'top_banner';
|
|
127
|
+
case 'bottom_banner': return 'bottom_banner';
|
|
128
|
+
case 'tooltip': return 'tooltip';
|
|
129
|
+
case 'toast': return 'toast';
|
|
130
|
+
// legacy wire value (old configs sent 'banner' for top strip)
|
|
131
|
+
case 'banner' as string: return 'top_banner';
|
|
132
|
+
default: return 'modal';
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Props every in-app render branch receives (the Open/Closed contract). */
|
|
137
|
+
export interface InAppBranchProps {
|
|
138
|
+
spec: InAppRenderSpec;
|
|
139
|
+
/** Canonical registry key, used to select family-specific content modes. */
|
|
140
|
+
variantKey?: string;
|
|
141
|
+
/** Resolved design tokens (dashboard-matching defaults + spec overrides). */
|
|
142
|
+
theme: InAppTheme;
|
|
143
|
+
/** Primary CTA tapped — provider emits `click` and surfaces `cta.deepLink`. */
|
|
144
|
+
onCta: (cta: NonNullable<InAppRenderSpec['cta']>) => void;
|
|
145
|
+
/** Dismissed (secondary CTA / close / backdrop / auto-timeout) — provider emits `dismiss`. */
|
|
146
|
+
onDismiss: () => void;
|
|
147
|
+
/** Finished a guided flow — provider emits `completion`, never a click/dismiss. */
|
|
148
|
+
onComplete?: () => void;
|
|
149
|
+
/** Present an authored terminal result/confirmation card before the final action. */
|
|
150
|
+
onOutcome?: (request: InAppOutcomeRequest) => void;
|
|
151
|
+
/** Optional additive gameplay telemetry; never used to determine a reward. */
|
|
152
|
+
onInteraction?: (interaction: InAppMechanicInteraction) => void;
|
|
153
|
+
/** Customer-backend result resolver. Retries reuse the same SDK-owned attempt id. */
|
|
154
|
+
requestGameResult?: (
|
|
155
|
+
attempt?: number,
|
|
156
|
+
input?: Record<string, unknown>,
|
|
157
|
+
) => Promise<InAppGameResult>;
|
|
158
|
+
/** Anchored surfaces call this only after their native target has been measured. */
|
|
159
|
+
onReady?: () => void;
|
|
160
|
+
/** Anchored surfaces report a missing/invalid target instead of faking a position. */
|
|
161
|
+
onRenderError?: (reason: string) => void;
|
|
162
|
+
/** Optional family-specific body. The layout branch remains responsible for mounting. */
|
|
163
|
+
children?: ReactNode;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface InAppMechanicInteraction {
|
|
167
|
+
mechanic: string;
|
|
168
|
+
phase: 'started' | 'progress' | 'decision' | 'resolved' | 'claimed' | 'completed';
|
|
169
|
+
attempt?: number;
|
|
170
|
+
progress?: number;
|
|
171
|
+
result?: string;
|
|
172
|
+
value?: string | number | boolean;
|
|
173
|
+
meta?: Record<string, unknown>;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** A render branch for one in-app layout. */
|
|
177
|
+
export type InAppRenderer = (props: InAppBranchProps) => ReactElement | null;
|
|
178
|
+
|
|
179
|
+
export type CoachmarkPlacement = 'auto' | 'top' | 'bottom' | 'left' | 'right';
|
|
180
|
+
|
|
181
|
+
export interface CoachmarkGeometry {
|
|
182
|
+
spotlight: EngageAnchorRect;
|
|
183
|
+
scrims: EngageAnchorRect[];
|
|
184
|
+
tooltip: {
|
|
185
|
+
left: number;
|
|
186
|
+
width: number;
|
|
187
|
+
top?: number;
|
|
188
|
+
bottom?: number;
|
|
189
|
+
maxHeight: number;
|
|
190
|
+
placement: Exclude<CoachmarkPlacement, 'auto'>;
|
|
191
|
+
arrowLeft?: number;
|
|
192
|
+
arrowTop?: number;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const clamp = (value: number, min: number, max: number): number =>
|
|
197
|
+
Math.max(min, Math.min(value, max));
|
|
198
|
+
|
|
199
|
+
type ScreenPosition = 'top' | 'center' | 'bottom';
|
|
200
|
+
|
|
201
|
+
const screenPosition = (value: unknown): ScreenPosition | undefined =>
|
|
202
|
+
value === 'top' || value === 'center' || value === 'bottom' ? value : undefined;
|
|
203
|
+
|
|
204
|
+
const androidInsetPadding = (
|
|
205
|
+
insets: EngageWindowInsets,
|
|
206
|
+
): ViewStyle | undefined => {
|
|
207
|
+
if (Platform.OS !== 'android') return undefined;
|
|
208
|
+
return {
|
|
209
|
+
paddingTop: insets.top,
|
|
210
|
+
paddingRight: insets.right,
|
|
211
|
+
paddingBottom: insets.bottom,
|
|
212
|
+
paddingLeft: insets.left,
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/** Pure geometry shared by iOS/Android and covered without a native measurement mock. */
|
|
217
|
+
export function resolveCoachmarkGeometry(
|
|
218
|
+
anchor: EngageAnchorRect,
|
|
219
|
+
viewport: { width: number; height: number },
|
|
220
|
+
preferred: CoachmarkPlacement = 'auto',
|
|
221
|
+
options: {
|
|
222
|
+
insets?: { top: number; right: number; bottom: number; left: number };
|
|
223
|
+
cardHeight?: number;
|
|
224
|
+
} = {},
|
|
225
|
+
): CoachmarkGeometry {
|
|
226
|
+
const pad = 8;
|
|
227
|
+
const gap = 12;
|
|
228
|
+
const edge = 16;
|
|
229
|
+
const insets = options.insets ?? { top: 0, right: 0, bottom: 0, left: 0 };
|
|
230
|
+
const safeLeft = clamp(insets.left + edge, 0, viewport.width);
|
|
231
|
+
const safeRight = clamp(viewport.width - insets.right - edge, safeLeft, viewport.width);
|
|
232
|
+
const safeTop = clamp(insets.top + edge, 0, viewport.height);
|
|
233
|
+
const safeBottom = clamp(viewport.height - insets.bottom - edge, safeTop, viewport.height);
|
|
234
|
+
const requestedCardHeight = Math.min(
|
|
235
|
+
Math.max(1, options.cardHeight ?? 160),
|
|
236
|
+
Math.max(1, safeBottom - safeTop),
|
|
237
|
+
);
|
|
238
|
+
const left = clamp(anchor.x - pad, 0, viewport.width);
|
|
239
|
+
const top = clamp(anchor.y - pad, 0, viewport.height);
|
|
240
|
+
const right = clamp(anchor.x + anchor.width + pad, left, viewport.width);
|
|
241
|
+
const bottom = clamp(anchor.y + anchor.height + pad, top, viewport.height);
|
|
242
|
+
const spotlight = { x: left, y: top, width: right - left, height: bottom - top };
|
|
243
|
+
const above = Math.max(0, top - gap - safeTop);
|
|
244
|
+
const below = Math.max(0, safeBottom - bottom - gap);
|
|
245
|
+
const verticalPlacement = (): 'top' | 'bottom' => preferred === 'top'
|
|
246
|
+
? (above >= requestedCardHeight || above >= below ? 'top' : 'bottom')
|
|
247
|
+
: preferred === 'bottom'
|
|
248
|
+
? (below >= requestedCardHeight || below >= above ? 'bottom' : 'top')
|
|
249
|
+
: (below >= requestedCardHeight || below >= above ? 'bottom' : 'top');
|
|
250
|
+
const leftRoom = Math.max(0, left - gap - safeLeft);
|
|
251
|
+
const rightRoom = Math.max(0, safeRight - right - gap);
|
|
252
|
+
let placement: Exclude<CoachmarkPlacement, 'auto'>;
|
|
253
|
+
if (preferred === 'left' || preferred === 'right') {
|
|
254
|
+
const preferredRoom = preferred === 'left' ? leftRoom : rightRoom;
|
|
255
|
+
const oppositeRoom = preferred === 'left' ? rightRoom : leftRoom;
|
|
256
|
+
if (preferredRoom >= 100 || (preferredRoom >= 80 && preferredRoom >= oppositeRoom)) {
|
|
257
|
+
placement = preferred;
|
|
258
|
+
} else if (oppositeRoom >= 80) {
|
|
259
|
+
placement = preferred === 'left' ? 'right' : 'left';
|
|
260
|
+
} else {
|
|
261
|
+
placement = below >= requestedCardHeight || below >= above ? 'bottom' : 'top';
|
|
262
|
+
}
|
|
263
|
+
} else {
|
|
264
|
+
placement = verticalPlacement();
|
|
265
|
+
}
|
|
266
|
+
const tooltipWidth = Math.max(0, Math.min(280, safeRight - safeLeft));
|
|
267
|
+
const anchorCenter = anchor.x + anchor.width / 2;
|
|
268
|
+
const verticalLeft = clamp(
|
|
269
|
+
anchorCenter - tooltipWidth / 2,
|
|
270
|
+
safeLeft,
|
|
271
|
+
Math.max(safeLeft, safeRight - tooltipWidth),
|
|
272
|
+
);
|
|
273
|
+
const side = placement === 'left' || placement === 'right';
|
|
274
|
+
const sideWidth = Math.min(240, placement === 'left' ? leftRoom : rightRoom);
|
|
275
|
+
const tooltipLeft = side
|
|
276
|
+
? (placement === 'left' ? left - gap - sideWidth : right + gap)
|
|
277
|
+
: verticalLeft;
|
|
278
|
+
const resolvedWidth = side ? sideWidth : tooltipWidth;
|
|
279
|
+
const tooltipMaxHeight = side
|
|
280
|
+
? Math.max(0, safeBottom - safeTop)
|
|
281
|
+
: placement === 'top'
|
|
282
|
+
? above
|
|
283
|
+
: below;
|
|
284
|
+
const cardHeight = Math.min(requestedCardHeight, tooltipMaxHeight);
|
|
285
|
+
const tooltipTop = clamp(
|
|
286
|
+
anchor.y + anchor.height / 2 - cardHeight / 2,
|
|
287
|
+
safeTop,
|
|
288
|
+
Math.max(safeTop, safeBottom - cardHeight),
|
|
289
|
+
);
|
|
290
|
+
const verticalPosition = placement === 'bottom'
|
|
291
|
+
? { top: clamp(bottom + gap, safeTop, Math.max(safeTop, safeBottom - cardHeight)) }
|
|
292
|
+
: { bottom: Math.max(0, viewport.height - top + gap) };
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
spotlight,
|
|
296
|
+
scrims: [
|
|
297
|
+
{ x: 0, y: 0, width: viewport.width, height: top },
|
|
298
|
+
{ x: 0, y: top, width: left, height: bottom - top },
|
|
299
|
+
{ x: right, y: top, width: viewport.width - right, height: bottom - top },
|
|
300
|
+
{ x: 0, y: bottom, width: viewport.width, height: viewport.height - bottom },
|
|
301
|
+
],
|
|
302
|
+
tooltip: {
|
|
303
|
+
left: tooltipLeft,
|
|
304
|
+
width: resolvedWidth,
|
|
305
|
+
...(side ? { top: tooltipTop } : verticalPosition),
|
|
306
|
+
maxHeight: tooltipMaxHeight,
|
|
307
|
+
placement,
|
|
308
|
+
...(side
|
|
309
|
+
? { arrowTop: clamp(anchor.y + anchor.height / 2 - tooltipTop - 7, 20, Math.max(20, cardHeight - 34)) }
|
|
310
|
+
: { arrowLeft: clamp(anchorCenter - tooltipLeft - 7, 20, Math.max(20, resolvedWidth - 34)) }),
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ─── Normalized theme contract (single source of truth, dashboard-matching) ────
|
|
316
|
+
// The renderer NEVER hardcodes dashboard CSS per message. Instead each token has a
|
|
317
|
+
// light/dark default copied ONCE from the dashboard's in-app preview look, and any
|
|
318
|
+
// `spec.style` key overrides it. This is the design contract the dashboard preview,
|
|
319
|
+
// the backend payload, and the SDK all share.
|
|
320
|
+
|
|
321
|
+
export interface InAppTheme {
|
|
322
|
+
dark: boolean;
|
|
323
|
+
rtl: boolean;
|
|
324
|
+
accent: string;
|
|
325
|
+
cardBg: string;
|
|
326
|
+
titleColor: string;
|
|
327
|
+
bodyColor: string;
|
|
328
|
+
ctaText: string;
|
|
329
|
+
secondaryColor: string;
|
|
330
|
+
couponBg: string;
|
|
331
|
+
couponFg: string;
|
|
332
|
+
couponBorder: string;
|
|
333
|
+
backdrop: string;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// Default tokens — values mirror the dashboard `inapp.theme.css` in-app preview so a
|
|
337
|
+
// message with no style overrides looks identical on device and in the dashboard.
|
|
338
|
+
const LIGHT_DEFAULTS = {
|
|
339
|
+
accent: '#5B4FE0',
|
|
340
|
+
cardBg: '#FFFFFF',
|
|
341
|
+
titleColor: '#0E1422',
|
|
342
|
+
bodyColor: '#697586',
|
|
343
|
+
ctaText: '#FFFFFF',
|
|
344
|
+
secondaryColor: '#697586',
|
|
345
|
+
couponBg: '#F2F1FD',
|
|
346
|
+
couponFg: '#5B4FE0',
|
|
347
|
+
couponBorder: '#5B4FE0',
|
|
348
|
+
backdrop: 'rgba(15,20,32,0.4)',
|
|
349
|
+
} as const;
|
|
350
|
+
const DARK_DEFAULTS = {
|
|
351
|
+
accent: '#5B4FE0',
|
|
352
|
+
cardBg: '#1E2128',
|
|
353
|
+
titleColor: '#E6E8EC',
|
|
354
|
+
bodyColor: '#697586',
|
|
355
|
+
ctaText: '#FFFFFF',
|
|
356
|
+
secondaryColor: '#9AA3AF',
|
|
357
|
+
couponBg: '#23203A',
|
|
358
|
+
couponFg: '#8B81F0',
|
|
359
|
+
couponBorder: '#8B81F0',
|
|
360
|
+
backdrop: 'rgba(15,20,32,0.4)',
|
|
361
|
+
} as const;
|
|
362
|
+
|
|
363
|
+
const KNOWN_STYLE_KEYS = new Set([
|
|
364
|
+
'accent', 'cardBg', 'titleColor', 'bodyColor', 'ctaText',
|
|
365
|
+
'secondaryColor', 'couponBg', 'couponFg', 'couponBorder', 'backdrop',
|
|
366
|
+
]);
|
|
367
|
+
|
|
368
|
+
/** Resolve dashboard-matching tokens, applying `spec.style` overrides on top. */
|
|
369
|
+
export function resolveTheme(spec: InAppRenderSpec): InAppTheme {
|
|
370
|
+
const dark = spec.dark === true;
|
|
371
|
+
const base = dark ? DARK_DEFAULTS : LIGHT_DEFAULTS;
|
|
372
|
+
const style = spec.style ?? {};
|
|
373
|
+
if (__DEV__) {
|
|
374
|
+
for (const k of Object.keys(style)) {
|
|
375
|
+
if (!KNOWN_STYLE_KEYS.has(k)) {
|
|
376
|
+
logger.warn(`[Engage] in-app spec.style has unknown token "${k}" — ignored. Known: ${[...KNOWN_STYLE_KEYS].join(', ')}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
const pick = (k: keyof typeof base): string => style[k] ?? base[k];
|
|
381
|
+
return {
|
|
382
|
+
dark,
|
|
383
|
+
rtl: spec.rtl === true,
|
|
384
|
+
accent: pick('accent'),
|
|
385
|
+
cardBg: pick('cardBg'),
|
|
386
|
+
titleColor: pick('titleColor'),
|
|
387
|
+
bodyColor: pick('bodyColor'),
|
|
388
|
+
ctaText: pick('ctaText'),
|
|
389
|
+
secondaryColor: pick('secondaryColor'),
|
|
390
|
+
couponBg: pick('couponBg'),
|
|
391
|
+
couponFg: pick('couponFg'),
|
|
392
|
+
couponBorder: pick('couponBorder'),
|
|
393
|
+
backdrop: pick('backdrop'),
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ─── Shared primitives ────────────────────────────────────────────────────────
|
|
398
|
+
|
|
399
|
+
function rtlText(theme: InAppTheme): TextStyle {
|
|
400
|
+
return theme.rtl ? { writingDirection: 'rtl', textAlign: 'right' } : {};
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
function CouponChip({ code, theme }: { code: string; theme: InAppTheme }): ReactElement {
|
|
404
|
+
return (
|
|
405
|
+
<View style={[styles.coupon, { backgroundColor: theme.couponBg, borderColor: theme.couponBorder }]}>
|
|
406
|
+
<Text style={[styles.couponText, { color: theme.couponFg }]}>{code}</Text>
|
|
407
|
+
</View>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
function MessageContent({ spec, theme }: { spec: InAppRenderSpec; theme: InAppTheme }): ReactElement {
|
|
412
|
+
const mediaHeight = resolveInAppMediaHeight(spec, 140, 320);
|
|
413
|
+
return (
|
|
414
|
+
<View style={styles.contentBlock}>
|
|
415
|
+
{spec.imageUrl ? (
|
|
416
|
+
<Image
|
|
417
|
+
accessibilityRole="image"
|
|
418
|
+
source={{ uri: spec.imageUrl }}
|
|
419
|
+
style={[
|
|
420
|
+
styles.image,
|
|
421
|
+
mediaHeight === undefined ? null : { height: mediaHeight },
|
|
422
|
+
]}
|
|
423
|
+
resizeMode="cover"
|
|
424
|
+
/>
|
|
425
|
+
) : null}
|
|
426
|
+
{spec.title ? <Text style={[styles.title, { color: theme.titleColor }, rtlText(theme)]}>{spec.title}</Text> : null}
|
|
427
|
+
<Text style={[styles.body, { color: theme.bodyColor }, rtlText(theme)]}>{spec.body}</Text>
|
|
428
|
+
{spec.coupon ? <CouponChip code={spec.coupon} theme={theme} /> : null}
|
|
429
|
+
</View>
|
|
430
|
+
);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function CtaRow({ spec, theme, onCta, onDismiss, onOutcome }: InAppBranchProps): ReactElement | null {
|
|
434
|
+
const cta = spec.cta;
|
|
435
|
+
const secondary = spec.secondaryCta;
|
|
436
|
+
if (!cta && !secondary) return null;
|
|
437
|
+
return (
|
|
438
|
+
<View style={[styles.actions, theme.rtl ? { flexDirection: 'row-reverse' } : null]}>
|
|
439
|
+
{secondary ? (
|
|
440
|
+
<Pressable
|
|
441
|
+
accessibilityRole="button"
|
|
442
|
+
accessibilityLabel={secondary.label}
|
|
443
|
+
onPress={onDismiss}
|
|
444
|
+
style={styles.secondaryBtn}
|
|
445
|
+
>
|
|
446
|
+
<Text style={[styles.secondaryText, { color: theme.secondaryColor }]}>{secondary.label}</Text>
|
|
447
|
+
</Pressable>
|
|
448
|
+
) : null}
|
|
449
|
+
{cta ? (
|
|
450
|
+
<Pressable
|
|
451
|
+
accessibilityRole="button"
|
|
452
|
+
accessibilityLabel={cta.label}
|
|
453
|
+
onPress={() => {
|
|
454
|
+
if (onOutcome) {
|
|
455
|
+
onOutcome({ fallback: inAppOutcomeTerminalForCta(cta) });
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
if (cta.action === 'dismiss') onDismiss();
|
|
459
|
+
else onCta(cta);
|
|
460
|
+
}}
|
|
461
|
+
style={[styles.primaryBtn, { backgroundColor: theme.accent }]}
|
|
462
|
+
>
|
|
463
|
+
<Text style={[styles.primaryText, { color: theme.ctaText }]}>{cta.label}</Text>
|
|
464
|
+
</Pressable>
|
|
465
|
+
) : null}
|
|
466
|
+
</View>
|
|
467
|
+
);
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
function InAppOutcomeModal({
|
|
471
|
+
outcome,
|
|
472
|
+
resultLabel,
|
|
473
|
+
theme,
|
|
474
|
+
onAction,
|
|
475
|
+
onRequestClose,
|
|
476
|
+
}: {
|
|
477
|
+
outcome: ResolvedInAppOutcomeConfig;
|
|
478
|
+
resultLabel?: string;
|
|
479
|
+
theme: InAppTheme;
|
|
480
|
+
onAction: () => void;
|
|
481
|
+
onRequestClose: () => void;
|
|
482
|
+
}): ReactElement {
|
|
483
|
+
const announcement = [outcome.title, outcome.body, resultLabel]
|
|
484
|
+
.filter(Boolean)
|
|
485
|
+
.join('. ');
|
|
486
|
+
return (
|
|
487
|
+
<Modal
|
|
488
|
+
visible
|
|
489
|
+
transparent
|
|
490
|
+
animationType="fade"
|
|
491
|
+
statusBarTranslucent
|
|
492
|
+
onRequestClose={onRequestClose}
|
|
493
|
+
onShow={() => AccessibilityInfo.announceForAccessibility(announcement)}
|
|
494
|
+
>
|
|
495
|
+
<SafeAreaView
|
|
496
|
+
style={[
|
|
497
|
+
outcomeStyles.backdrop,
|
|
498
|
+
{ backgroundColor: theme.backdrop },
|
|
499
|
+
]}
|
|
500
|
+
>
|
|
501
|
+
<View
|
|
502
|
+
accessibilityViewIsModal
|
|
503
|
+
style={[
|
|
504
|
+
outcomeStyles.card,
|
|
505
|
+
{
|
|
506
|
+
backgroundColor: theme.cardBg,
|
|
507
|
+
borderColor: theme.couponBorder,
|
|
508
|
+
},
|
|
509
|
+
]}
|
|
510
|
+
>
|
|
511
|
+
<View
|
|
512
|
+
accessible
|
|
513
|
+
accessibilityRole="alert"
|
|
514
|
+
accessibilityLabel={announcement}
|
|
515
|
+
accessibilityLiveRegion="assertive"
|
|
516
|
+
style={outcomeStyles.copy}
|
|
517
|
+
>
|
|
518
|
+
<View
|
|
519
|
+
importantForAccessibility="no-hide-descendants"
|
|
520
|
+
style={[
|
|
521
|
+
outcomeStyles.icon,
|
|
522
|
+
{ backgroundColor: theme.couponBg },
|
|
523
|
+
]}
|
|
524
|
+
>
|
|
525
|
+
<Text
|
|
526
|
+
style={[
|
|
527
|
+
outcomeStyles.iconText,
|
|
528
|
+
{ color: theme.couponFg },
|
|
529
|
+
]}
|
|
530
|
+
>
|
|
531
|
+
{inAppOutcomeIconGlyph(outcome.icon)}
|
|
532
|
+
</Text>
|
|
533
|
+
</View>
|
|
534
|
+
<Text
|
|
535
|
+
style={[
|
|
536
|
+
outcomeStyles.title,
|
|
537
|
+
{ color: theme.titleColor },
|
|
538
|
+
rtlText(theme),
|
|
539
|
+
]}
|
|
540
|
+
>
|
|
541
|
+
{outcome.title}
|
|
542
|
+
</Text>
|
|
543
|
+
<Text
|
|
544
|
+
style={[
|
|
545
|
+
outcomeStyles.body,
|
|
546
|
+
{ color: theme.bodyColor },
|
|
547
|
+
rtlText(theme),
|
|
548
|
+
]}
|
|
549
|
+
>
|
|
550
|
+
{outcome.body}
|
|
551
|
+
</Text>
|
|
552
|
+
{resultLabel ? (
|
|
553
|
+
<View
|
|
554
|
+
style={[
|
|
555
|
+
outcomeStyles.result,
|
|
556
|
+
{ backgroundColor: theme.couponBg },
|
|
557
|
+
]}
|
|
558
|
+
>
|
|
559
|
+
<Text
|
|
560
|
+
style={[
|
|
561
|
+
outcomeStyles.resultText,
|
|
562
|
+
{ color: theme.couponFg },
|
|
563
|
+
rtlText(theme),
|
|
564
|
+
]}
|
|
565
|
+
>
|
|
566
|
+
{resultLabel}
|
|
567
|
+
</Text>
|
|
568
|
+
</View>
|
|
569
|
+
) : null}
|
|
570
|
+
</View>
|
|
571
|
+
<Pressable
|
|
572
|
+
accessibilityRole="button"
|
|
573
|
+
accessibilityLabel={outcome.buttonLabel}
|
|
574
|
+
onPress={onAction}
|
|
575
|
+
style={[
|
|
576
|
+
outcomeStyles.button,
|
|
577
|
+
{ backgroundColor: theme.accent },
|
|
578
|
+
]}
|
|
579
|
+
>
|
|
580
|
+
<Text
|
|
581
|
+
style={[
|
|
582
|
+
outcomeStyles.buttonText,
|
|
583
|
+
{ color: theme.ctaText },
|
|
584
|
+
]}
|
|
585
|
+
>
|
|
586
|
+
{outcome.buttonLabel}
|
|
587
|
+
</Text>
|
|
588
|
+
</Pressable>
|
|
589
|
+
</View>
|
|
590
|
+
</SafeAreaView>
|
|
591
|
+
</Modal>
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** Default legacy content when a registry mechanic does not provide a custom body. */
|
|
596
|
+
function BranchContent(props: InAppBranchProps): ReactElement {
|
|
597
|
+
if (props.children !== undefined) return <>{props.children}</>;
|
|
598
|
+
return (
|
|
599
|
+
<>
|
|
600
|
+
<MessageContent spec={props.spec} theme={props.theme} />
|
|
601
|
+
<CtaRow {...props} />
|
|
602
|
+
</>
|
|
603
|
+
);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
function CloseBtn({ onPress, style }: { onPress: () => void; style?: ViewStyle }): ReactElement {
|
|
607
|
+
return (
|
|
608
|
+
<Pressable
|
|
609
|
+
accessibilityRole="button"
|
|
610
|
+
accessibilityLabel="Dismiss"
|
|
611
|
+
onPress={onPress}
|
|
612
|
+
hitSlop={8}
|
|
613
|
+
style={[styles.closeBtn, style]}
|
|
614
|
+
>
|
|
615
|
+
<Text style={styles.closeBtnText}>×</Text>
|
|
616
|
+
</Pressable>
|
|
617
|
+
);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function ScreenEdgeSurface({
|
|
621
|
+
edge,
|
|
622
|
+
contentStyle,
|
|
623
|
+
children,
|
|
624
|
+
}: {
|
|
625
|
+
edge: Exclude<ScreenPosition, 'center'>;
|
|
626
|
+
contentStyle: StyleProp<ViewStyle>;
|
|
627
|
+
children: ReactNode;
|
|
628
|
+
}): ReactElement {
|
|
629
|
+
const insets = useEngageWindowInsets(true) ?? ZERO_ENGAGE_WINDOW_INSETS;
|
|
630
|
+
const content = (
|
|
631
|
+
<View pointerEvents="box-none" style={contentStyle}>
|
|
632
|
+
{children}
|
|
633
|
+
</View>
|
|
634
|
+
);
|
|
635
|
+
return (
|
|
636
|
+
<SafeAreaView
|
|
637
|
+
pointerEvents="box-none"
|
|
638
|
+
style={[
|
|
639
|
+
styles.screenEdge,
|
|
640
|
+
edge === 'top' ? styles.screenEdgeTop : styles.screenEdgeBottom,
|
|
641
|
+
androidInsetPadding(insets),
|
|
642
|
+
]}
|
|
643
|
+
>
|
|
644
|
+
{edge === 'bottom' ? (
|
|
645
|
+
<KeyboardAvoidingView
|
|
646
|
+
pointerEvents="box-none"
|
|
647
|
+
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
|
|
648
|
+
style={styles.screenEdgeKeyboard}
|
|
649
|
+
>
|
|
650
|
+
{content}
|
|
651
|
+
</KeyboardAvoidingView>
|
|
652
|
+
) : content}
|
|
653
|
+
</SafeAreaView>
|
|
654
|
+
);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// ─── 1. modal — centered dialog ───────────────────────────────────────────────
|
|
658
|
+
|
|
659
|
+
function ModalInApp(props: InAppBranchProps): ReactElement {
|
|
660
|
+
const { spec, theme, onDismiss } = props;
|
|
661
|
+
const centerDrawer = props.variantKey === 'center_drawer';
|
|
662
|
+
const position = screenPosition(spec.ext?.position)
|
|
663
|
+
?? screenPosition(spec.ext?.layoutPosition)
|
|
664
|
+
?? 'center';
|
|
665
|
+
return (
|
|
666
|
+
<Modal
|
|
667
|
+
visible
|
|
668
|
+
transparent
|
|
669
|
+
animationType="fade"
|
|
670
|
+
statusBarTranslucent={false}
|
|
671
|
+
onRequestClose={onDismiss}
|
|
672
|
+
>
|
|
673
|
+
<SafeAreaView
|
|
674
|
+
style={[
|
|
675
|
+
styles.modalSafeArea,
|
|
676
|
+
{ backgroundColor: theme.backdrop },
|
|
677
|
+
]}
|
|
678
|
+
>
|
|
679
|
+
<KeyboardAvoidingView
|
|
680
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
681
|
+
style={styles.keyboardAvoider}
|
|
682
|
+
>
|
|
683
|
+
<Pressable
|
|
684
|
+
style={[
|
|
685
|
+
styles.modalBackdrop,
|
|
686
|
+
position === 'top' ? styles.modalBackdropTop : null,
|
|
687
|
+
position === 'bottom' ? styles.modalBackdropBottom : null,
|
|
688
|
+
{ backgroundColor: theme.backdrop },
|
|
689
|
+
]}
|
|
690
|
+
onPress={onDismiss}
|
|
691
|
+
accessibilityRole="none"
|
|
692
|
+
>
|
|
693
|
+
<Pressable
|
|
694
|
+
style={[
|
|
695
|
+
styles.modalCard,
|
|
696
|
+
centerDrawer && styles.centerDrawerCard,
|
|
697
|
+
{ backgroundColor: theme.cardBg },
|
|
698
|
+
]}
|
|
699
|
+
onPress={() => {}}
|
|
700
|
+
accessibilityRole="none"
|
|
701
|
+
>
|
|
702
|
+
<CloseBtn onPress={onDismiss} style={styles.modalClosePos} />
|
|
703
|
+
<ScrollView
|
|
704
|
+
style={styles.modalScroll}
|
|
705
|
+
contentContainerStyle={styles.modalScrollContent}
|
|
706
|
+
showsVerticalScrollIndicator={false}
|
|
707
|
+
keyboardShouldPersistTaps="handled"
|
|
708
|
+
>
|
|
709
|
+
<BranchContent {...props} />
|
|
710
|
+
</ScrollView>
|
|
711
|
+
</Pressable>
|
|
712
|
+
</Pressable>
|
|
713
|
+
</KeyboardAvoidingView>
|
|
714
|
+
</SafeAreaView>
|
|
715
|
+
</Modal>
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
// ─── 2. fullscreen — edge-to-edge takeover ────────────────────────────────────
|
|
720
|
+
|
|
721
|
+
function FullScreenInApp(props: InAppBranchProps): ReactElement {
|
|
722
|
+
const { spec, theme, onDismiss } = props;
|
|
723
|
+
const mediaAspectRatio = resolveInAppMediaAspectRatio(spec, 16 / 9);
|
|
724
|
+
const mediaMaxHeight = resolveInAppMediaHeight(spec, 320, 480);
|
|
725
|
+
return (
|
|
726
|
+
<Modal
|
|
727
|
+
visible
|
|
728
|
+
transparent={false}
|
|
729
|
+
animationType="slide"
|
|
730
|
+
presentationStyle="fullScreen"
|
|
731
|
+
onRequestClose={onDismiss}
|
|
732
|
+
>
|
|
733
|
+
<SafeAreaView style={[styles.fullscreenCard, { backgroundColor: theme.cardBg }]}>
|
|
734
|
+
<View style={styles.fullscreenHeader}>
|
|
735
|
+
<CloseBtn onPress={onDismiss} />
|
|
736
|
+
</View>
|
|
737
|
+
<ScrollView
|
|
738
|
+
style={styles.fullscreenScroll}
|
|
739
|
+
contentContainerStyle={styles.fullscreenScrollContent}
|
|
740
|
+
showsVerticalScrollIndicator={false}
|
|
741
|
+
keyboardShouldPersistTaps="handled"
|
|
742
|
+
>
|
|
743
|
+
{props.children === undefined && spec.imageUrl ? (
|
|
744
|
+
<Image
|
|
745
|
+
accessibilityRole="image"
|
|
746
|
+
source={{ uri: spec.imageUrl }}
|
|
747
|
+
style={[
|
|
748
|
+
styles.fullscreenImage,
|
|
749
|
+
mediaAspectRatio === undefined
|
|
750
|
+
? null
|
|
751
|
+
: {
|
|
752
|
+
aspectRatio: mediaAspectRatio,
|
|
753
|
+
maxHeight: mediaMaxHeight,
|
|
754
|
+
},
|
|
755
|
+
]}
|
|
756
|
+
resizeMode="cover"
|
|
757
|
+
/>
|
|
758
|
+
) : null}
|
|
759
|
+
<View style={styles.fullscreenContent}>
|
|
760
|
+
{props.children !== undefined ? <>{props.children}</> : (
|
|
761
|
+
<>
|
|
762
|
+
{spec.title ? <Text style={[styles.fullscreenTitle, { color: theme.titleColor }, rtlText(theme)]}>{spec.title}</Text> : null}
|
|
763
|
+
{spec.body ? <Text style={[styles.fullscreenBody, { color: theme.bodyColor }, rtlText(theme)]}>{spec.body}</Text> : null}
|
|
764
|
+
{spec.coupon ? <CouponChip code={spec.coupon} theme={theme} /> : null}
|
|
765
|
+
<CtaRow {...props} />
|
|
766
|
+
</>
|
|
767
|
+
)}
|
|
768
|
+
</View>
|
|
769
|
+
</ScrollView>
|
|
770
|
+
</SafeAreaView>
|
|
771
|
+
</Modal>
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
// ─── 3. bottom_sheet — slides up from bottom ──────────────────────────────────
|
|
776
|
+
|
|
777
|
+
function SheetSurface({
|
|
778
|
+
theme,
|
|
779
|
+
onDismiss,
|
|
780
|
+
children,
|
|
781
|
+
}: Pick<InAppBranchProps, 'theme' | 'onDismiss'> & {
|
|
782
|
+
children: ReactNode;
|
|
783
|
+
}): ReactElement {
|
|
784
|
+
return (
|
|
785
|
+
<Modal
|
|
786
|
+
visible
|
|
787
|
+
transparent
|
|
788
|
+
animationType="slide"
|
|
789
|
+
statusBarTranslucent={false}
|
|
790
|
+
onRequestClose={onDismiss}
|
|
791
|
+
>
|
|
792
|
+
<KeyboardAvoidingView
|
|
793
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
794
|
+
style={styles.keyboardAvoider}
|
|
795
|
+
>
|
|
796
|
+
<Pressable
|
|
797
|
+
style={[styles.sheetBackdrop, { backgroundColor: theme.backdrop }]}
|
|
798
|
+
onPress={onDismiss}
|
|
799
|
+
accessibilityRole="none"
|
|
800
|
+
>
|
|
801
|
+
<Pressable
|
|
802
|
+
style={[styles.sheetCard, { backgroundColor: theme.cardBg }]}
|
|
803
|
+
onPress={() => {}}
|
|
804
|
+
accessibilityRole="none"
|
|
805
|
+
>
|
|
806
|
+
<SafeAreaView
|
|
807
|
+
style={[
|
|
808
|
+
styles.sheetSafeArea,
|
|
809
|
+
{ backgroundColor: theme.cardBg },
|
|
810
|
+
]}
|
|
811
|
+
>
|
|
812
|
+
<ScrollView
|
|
813
|
+
style={styles.sheetScroll}
|
|
814
|
+
contentContainerStyle={styles.sheetContent}
|
|
815
|
+
showsVerticalScrollIndicator={false}
|
|
816
|
+
keyboardShouldPersistTaps="handled"
|
|
817
|
+
>
|
|
818
|
+
<View style={styles.sheetHandle} />
|
|
819
|
+
{children}
|
|
820
|
+
</ScrollView>
|
|
821
|
+
</SafeAreaView>
|
|
822
|
+
</Pressable>
|
|
823
|
+
</Pressable>
|
|
824
|
+
</KeyboardAvoidingView>
|
|
825
|
+
</Modal>
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
function BottomSheetInApp(props: InAppBranchProps): ReactElement {
|
|
830
|
+
return (
|
|
831
|
+
<SheetSurface theme={props.theme} onDismiss={props.onDismiss}>
|
|
832
|
+
<BranchContent {...props} />
|
|
833
|
+
</SheetSurface>
|
|
834
|
+
);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
// ─── Additive surfaces — canonical variants outside the legacy seven ────────
|
|
838
|
+
|
|
839
|
+
function MultiStepSheetInApp(props: InAppBranchProps): ReactElement {
|
|
840
|
+
const rawSteps = Array.isArray(props.spec.ext?.steps) ? props.spec.ext.steps : [];
|
|
841
|
+
const steps = rawSteps.filter((step): step is Record<string, unknown> =>
|
|
842
|
+
step !== null && typeof step === 'object' && !Array.isArray(step),
|
|
843
|
+
);
|
|
844
|
+
const [stepIndex, setStepIndex] = useState(0);
|
|
845
|
+
const stepCount = steps.length;
|
|
846
|
+
const current = steps[Math.min(stepIndex, Math.max(0, stepCount - 1))];
|
|
847
|
+
const title = typeof current?.title === 'string' ? current.title : props.spec.title;
|
|
848
|
+
const body = typeof current?.body === 'string' ? current.body : props.spec.body;
|
|
849
|
+
const image = typeof current?.image === 'string'
|
|
850
|
+
? current.image
|
|
851
|
+
: typeof current?.stepImage === 'string'
|
|
852
|
+
? current.stepImage
|
|
853
|
+
: undefined;
|
|
854
|
+
const mediaHeight = resolveInAppMediaHeight(props.spec, 140, 320);
|
|
855
|
+
const last = stepCount === 0 || stepIndex >= stepCount - 1;
|
|
856
|
+
const labels = resolveMultiStepSheetLabels(props.spec);
|
|
857
|
+
const progressAt = (index: number): number =>
|
|
858
|
+
stepCount > 0 ? (index + 1) / stepCount : 0;
|
|
859
|
+
const runTerminal = (action: MultiStepSheetTerminalAction): void => {
|
|
860
|
+
if (action.kind === 'cta') props.onCta(action.cta);
|
|
861
|
+
else props.onDismiss();
|
|
862
|
+
};
|
|
863
|
+
const back = (): void => {
|
|
864
|
+
const previousIndex = resolveMultiStepSheetIndex(stepIndex, stepCount, 'back');
|
|
865
|
+
setStepIndex(previousIndex);
|
|
866
|
+
props.onInteraction?.({
|
|
867
|
+
mechanic: 'multi_step_sheet',
|
|
868
|
+
phase: 'progress',
|
|
869
|
+
progress: progressAt(previousIndex),
|
|
870
|
+
result: 'back',
|
|
871
|
+
value: previousIndex + 1,
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
const skip = (): void => {
|
|
875
|
+
props.onInteraction?.({
|
|
876
|
+
mechanic: 'multi_step_sheet',
|
|
877
|
+
phase: 'decision',
|
|
878
|
+
progress: progressAt(stepIndex),
|
|
879
|
+
result: 'skipped',
|
|
880
|
+
value: stepIndex + 1,
|
|
881
|
+
});
|
|
882
|
+
runTerminal(resolveMultiStepSheetTerminalAction(props.spec.secondaryCta));
|
|
883
|
+
};
|
|
884
|
+
const next = (): void => {
|
|
885
|
+
if (!last) {
|
|
886
|
+
const nextIndex = resolveMultiStepSheetIndex(stepIndex, stepCount, 'next');
|
|
887
|
+
setStepIndex(nextIndex);
|
|
888
|
+
props.onInteraction?.({
|
|
889
|
+
mechanic: 'multi_step_sheet',
|
|
890
|
+
phase: 'progress',
|
|
891
|
+
progress: progressAt(nextIndex),
|
|
892
|
+
result: 'next',
|
|
893
|
+
value: nextIndex + 1,
|
|
894
|
+
});
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
props.onInteraction?.({
|
|
898
|
+
mechanic: 'multi_step_sheet',
|
|
899
|
+
phase: 'completed',
|
|
900
|
+
progress: 1,
|
|
901
|
+
result: 'finished',
|
|
902
|
+
value: stepCount > 0 ? stepCount : 1,
|
|
903
|
+
});
|
|
904
|
+
const terminal = resolveMultiStepSheetTerminalAction(props.spec.cta);
|
|
905
|
+
if (props.onOutcome) {
|
|
906
|
+
props.onOutcome({
|
|
907
|
+
fallback: terminal.kind === 'cta'
|
|
908
|
+
? terminal
|
|
909
|
+
: { kind: 'dismiss' },
|
|
910
|
+
});
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
runTerminal(terminal);
|
|
914
|
+
};
|
|
915
|
+
return (
|
|
916
|
+
<SheetSurface theme={props.theme} onDismiss={props.onDismiss}>
|
|
917
|
+
{stepCount > 1 ? (
|
|
918
|
+
<View
|
|
919
|
+
accessibilityRole="progressbar"
|
|
920
|
+
accessibilityLabel={`Step ${stepIndex + 1} of ${stepCount}`}
|
|
921
|
+
accessibilityValue={{ min: 1, max: stepCount, now: stepIndex + 1 }}
|
|
922
|
+
style={styles.stepProgress}
|
|
923
|
+
>
|
|
924
|
+
<Text
|
|
925
|
+
style={[styles.stepLabel, { color: props.theme.secondaryColor }]}
|
|
926
|
+
>{`Step ${stepIndex + 1} of ${stepCount}`}</Text>
|
|
927
|
+
<View style={styles.stepTrack}>
|
|
928
|
+
<View
|
|
929
|
+
style={[
|
|
930
|
+
styles.stepFill,
|
|
931
|
+
{
|
|
932
|
+
backgroundColor: props.theme.accent,
|
|
933
|
+
width: `${((stepIndex + 1) / stepCount) * 100}%`,
|
|
934
|
+
},
|
|
935
|
+
]}
|
|
936
|
+
/>
|
|
937
|
+
</View>
|
|
938
|
+
</View>
|
|
939
|
+
) : null}
|
|
940
|
+
<View style={styles.contentBlock}>
|
|
941
|
+
{image ? (
|
|
942
|
+
<Image
|
|
943
|
+
source={{ uri: image }}
|
|
944
|
+
resizeMode="cover"
|
|
945
|
+
style={[
|
|
946
|
+
styles.image,
|
|
947
|
+
mediaHeight === undefined ? null : { height: mediaHeight },
|
|
948
|
+
]}
|
|
949
|
+
/>
|
|
950
|
+
) : null}
|
|
951
|
+
{title ? <Text style={[styles.title, { color: props.theme.titleColor }]}>{title}</Text> : null}
|
|
952
|
+
{body ? <Text style={[styles.body, { color: props.theme.bodyColor }]}>{body}</Text> : null}
|
|
953
|
+
</View>
|
|
954
|
+
<View style={styles.actions}>
|
|
955
|
+
{stepIndex > 0 ? (
|
|
956
|
+
<Pressable
|
|
957
|
+
accessibilityRole="button"
|
|
958
|
+
accessibilityLabel={labels.back}
|
|
959
|
+
onPress={back}
|
|
960
|
+
style={styles.secondaryBtn}
|
|
961
|
+
>
|
|
962
|
+
<Text style={[styles.secondaryText, { color: props.theme.secondaryColor }]}>{labels.back}</Text>
|
|
963
|
+
</Pressable>
|
|
964
|
+
) : null}
|
|
965
|
+
<Pressable
|
|
966
|
+
accessibilityRole="button"
|
|
967
|
+
accessibilityLabel={labels.skip}
|
|
968
|
+
onPress={skip}
|
|
969
|
+
style={styles.secondaryBtn}
|
|
970
|
+
>
|
|
971
|
+
<Text style={[styles.secondaryText, { color: props.theme.secondaryColor }]}>{labels.skip}</Text>
|
|
972
|
+
</Pressable>
|
|
973
|
+
<Pressable
|
|
974
|
+
accessibilityRole="button"
|
|
975
|
+
accessibilityLabel={last ? labels.finish : labels.next}
|
|
976
|
+
onPress={next}
|
|
977
|
+
style={[styles.primaryBtn, { backgroundColor: props.theme.accent }]}
|
|
978
|
+
>
|
|
979
|
+
<Text style={[styles.primaryText, { color: props.theme.ctaText }]}>
|
|
980
|
+
{last ? labels.finish : labels.next}
|
|
981
|
+
</Text>
|
|
982
|
+
</Pressable>
|
|
983
|
+
</View>
|
|
984
|
+
</SheetSurface>
|
|
985
|
+
);
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
function SideSheetInApp(props: InAppBranchProps): ReactElement {
|
|
989
|
+
const { theme, onDismiss } = props;
|
|
990
|
+
const side = props.spec.ext?.sidePosition === 'left' ? 'left' : 'right';
|
|
991
|
+
return (
|
|
992
|
+
<Modal
|
|
993
|
+
visible
|
|
994
|
+
transparent
|
|
995
|
+
animationType="fade"
|
|
996
|
+
statusBarTranslucent={false}
|
|
997
|
+
onRequestClose={onDismiss}
|
|
998
|
+
>
|
|
999
|
+
<KeyboardAvoidingView
|
|
1000
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
1001
|
+
style={styles.keyboardAvoider}
|
|
1002
|
+
>
|
|
1003
|
+
<Pressable
|
|
1004
|
+
accessibilityRole="none"
|
|
1005
|
+
onPress={onDismiss}
|
|
1006
|
+
style={[
|
|
1007
|
+
styles.sideSheetBackdrop,
|
|
1008
|
+
{ backgroundColor: theme.backdrop },
|
|
1009
|
+
side === 'left' ? styles.sideSheetLeft : styles.sideSheetRight,
|
|
1010
|
+
]}
|
|
1011
|
+
>
|
|
1012
|
+
<Pressable
|
|
1013
|
+
accessibilityRole="none"
|
|
1014
|
+
onPress={() => {}}
|
|
1015
|
+
style={[
|
|
1016
|
+
styles.sideSheetPanel,
|
|
1017
|
+
{ backgroundColor: theme.cardBg },
|
|
1018
|
+
side === 'left' ? styles.sideSheetPanelLeft : styles.sideSheetPanelRight,
|
|
1019
|
+
]}
|
|
1020
|
+
>
|
|
1021
|
+
<SafeAreaView style={styles.sideSheetSafeArea}>
|
|
1022
|
+
<View style={styles.sideSheetHeader}>
|
|
1023
|
+
<CloseBtn onPress={onDismiss} />
|
|
1024
|
+
</View>
|
|
1025
|
+
<ScrollView
|
|
1026
|
+
style={styles.sideSheetScroll}
|
|
1027
|
+
contentContainerStyle={styles.sideSheetContent}
|
|
1028
|
+
showsVerticalScrollIndicator={false}
|
|
1029
|
+
keyboardShouldPersistTaps="handled"
|
|
1030
|
+
>
|
|
1031
|
+
<BranchContent {...props} />
|
|
1032
|
+
</ScrollView>
|
|
1033
|
+
</SafeAreaView>
|
|
1034
|
+
</Pressable>
|
|
1035
|
+
</Pressable>
|
|
1036
|
+
</KeyboardAvoidingView>
|
|
1037
|
+
</Modal>
|
|
1038
|
+
);
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
function PeekCardInApp(props: InAppBranchProps): ReactElement {
|
|
1042
|
+
const [expanded, setExpanded] = useState(false);
|
|
1043
|
+
const peekLabel = typeof props.spec.ext?.peekLabel === 'string' ? props.spec.ext.peekLabel : 'View more';
|
|
1044
|
+
return (
|
|
1045
|
+
<Modal
|
|
1046
|
+
visible
|
|
1047
|
+
transparent
|
|
1048
|
+
animationType="slide"
|
|
1049
|
+
statusBarTranslucent={false}
|
|
1050
|
+
onRequestClose={props.onDismiss}
|
|
1051
|
+
>
|
|
1052
|
+
<KeyboardAvoidingView
|
|
1053
|
+
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
|
|
1054
|
+
style={styles.peekRoot}
|
|
1055
|
+
pointerEvents="box-none"
|
|
1056
|
+
>
|
|
1057
|
+
{expanded ? (
|
|
1058
|
+
<Pressable style={[styles.peekExpanded, { backgroundColor: props.theme.cardBg }]} onPress={() => {}}>
|
|
1059
|
+
<SafeAreaView
|
|
1060
|
+
style={[
|
|
1061
|
+
styles.peekSafeArea,
|
|
1062
|
+
{ backgroundColor: props.theme.cardBg },
|
|
1063
|
+
]}
|
|
1064
|
+
>
|
|
1065
|
+
<ScrollView
|
|
1066
|
+
style={styles.peekScroll}
|
|
1067
|
+
contentContainerStyle={styles.peekExpandedContent}
|
|
1068
|
+
showsVerticalScrollIndicator={false}
|
|
1069
|
+
keyboardShouldPersistTaps="handled"
|
|
1070
|
+
>
|
|
1071
|
+
<View style={styles.sheetHandle} />
|
|
1072
|
+
<CloseBtn onPress={props.onDismiss} style={styles.peekClose} />
|
|
1073
|
+
<BranchContent {...props} />
|
|
1074
|
+
</ScrollView>
|
|
1075
|
+
</SafeAreaView>
|
|
1076
|
+
</Pressable>
|
|
1077
|
+
) : (
|
|
1078
|
+
<Pressable
|
|
1079
|
+
accessibilityRole="button"
|
|
1080
|
+
accessibilityLabel={peekLabel}
|
|
1081
|
+
onPress={() => {
|
|
1082
|
+
setExpanded(true);
|
|
1083
|
+
props.onInteraction?.({ mechanic: 'peek_card', phase: 'started' });
|
|
1084
|
+
}}
|
|
1085
|
+
style={[styles.peekCollapsed, { backgroundColor: props.theme.cardBg, borderColor: props.theme.accent }]}
|
|
1086
|
+
>
|
|
1087
|
+
<SafeAreaView
|
|
1088
|
+
style={[
|
|
1089
|
+
styles.peekSafeArea,
|
|
1090
|
+
{ backgroundColor: props.theme.cardBg },
|
|
1091
|
+
]}
|
|
1092
|
+
>
|
|
1093
|
+
<View style={styles.peekCollapsedContent}>
|
|
1094
|
+
<View style={styles.sheetHandle} />
|
|
1095
|
+
<Text style={[styles.peekLabel, { color: props.theme.titleColor }]}>{peekLabel}</Text>
|
|
1096
|
+
</View>
|
|
1097
|
+
</SafeAreaView>
|
|
1098
|
+
</Pressable>
|
|
1099
|
+
)}
|
|
1100
|
+
</KeyboardAvoidingView>
|
|
1101
|
+
</Modal>
|
|
1102
|
+
);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
const ADDITIVE_INAPP_RENDERERS: Partial<Record<InAppArchetype, InAppRenderer>> = {
|
|
1106
|
+
multiStepSheet: MultiStepSheetInApp,
|
|
1107
|
+
sideSheet: SideSheetInApp,
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// ─── 4. top_banner — strip pinned to top ─────────────────────────────────────
|
|
1111
|
+
|
|
1112
|
+
function TopBannerInApp(props: InAppBranchProps): ReactElement {
|
|
1113
|
+
const { spec, theme, onDismiss } = props;
|
|
1114
|
+
const window = useWindowDimensions();
|
|
1115
|
+
const edge = screenPosition(spec.ext?.position)
|
|
1116
|
+
?? screenPosition(spec.ext?.layoutPosition)
|
|
1117
|
+
?? 'top';
|
|
1118
|
+
const rawProgress = spec.ext?.progress;
|
|
1119
|
+
const stickyProgress = props.variantKey === 'sticky_header_bar' && typeof rawProgress === 'number'
|
|
1120
|
+
? clamp(rawProgress <= 1 ? rawProgress * 100 : rawProgress, 0, 100)
|
|
1121
|
+
: null;
|
|
1122
|
+
return (
|
|
1123
|
+
<ScreenEdgeSurface edge={edge === 'bottom' ? 'bottom' : 'top'} contentStyle={styles.bannerWrap}>
|
|
1124
|
+
<View style={[styles.bannerCard, { backgroundColor: theme.cardBg }, theme.rtl ? { flexDirection: 'row-reverse' } : null]}>
|
|
1125
|
+
<ScrollView
|
|
1126
|
+
style={[styles.bannerContent, { maxHeight: Math.max(120, window.height * 0.45) }]}
|
|
1127
|
+
showsVerticalScrollIndicator={false}
|
|
1128
|
+
keyboardShouldPersistTaps="handled"
|
|
1129
|
+
>
|
|
1130
|
+
{props.variantKey === 'sticky_header_bar' ? <Text style={[styles.stickyLabel, { color: theme.accent }]}>PINNED</Text> : null}
|
|
1131
|
+
<BranchContent {...props} />
|
|
1132
|
+
{stickyProgress !== null ? (
|
|
1133
|
+
<View
|
|
1134
|
+
accessibilityRole="progressbar"
|
|
1135
|
+
accessibilityValue={{ min: 0, max: 100, now: Math.round(stickyProgress) }}
|
|
1136
|
+
style={styles.stickyTrack}
|
|
1137
|
+
>
|
|
1138
|
+
<View style={[styles.stickyFill, { backgroundColor: theme.accent, width: `${stickyProgress}%` }]} />
|
|
1139
|
+
</View>
|
|
1140
|
+
) : null}
|
|
1141
|
+
</ScrollView>
|
|
1142
|
+
<CloseBtn onPress={onDismiss} style={styles.bannerClosePos} />
|
|
1143
|
+
</View>
|
|
1144
|
+
</ScreenEdgeSurface>
|
|
1145
|
+
);
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
// ─── 5. bottom_banner — strip pinned to bottom ───────────────────────────────
|
|
1149
|
+
|
|
1150
|
+
function BottomBannerInApp(props: InAppBranchProps): ReactElement {
|
|
1151
|
+
const { spec, theme, onDismiss } = props;
|
|
1152
|
+
const window = useWindowDimensions();
|
|
1153
|
+
const edge = screenPosition(spec.ext?.position)
|
|
1154
|
+
?? screenPosition(spec.ext?.layoutPosition)
|
|
1155
|
+
?? 'bottom';
|
|
1156
|
+
return (
|
|
1157
|
+
<ScreenEdgeSurface edge={edge === 'top' ? 'top' : 'bottom'} contentStyle={styles.bannerWrap}>
|
|
1158
|
+
<View style={[styles.bannerCard, { backgroundColor: theme.cardBg }, theme.rtl ? { flexDirection: 'row-reverse' } : null]}>
|
|
1159
|
+
<ScrollView
|
|
1160
|
+
style={[styles.bannerContent, { maxHeight: Math.max(120, window.height * 0.45) }]}
|
|
1161
|
+
showsVerticalScrollIndicator={false}
|
|
1162
|
+
keyboardShouldPersistTaps="handled"
|
|
1163
|
+
>
|
|
1164
|
+
{props.variantKey === 'sticky_footer_bar' ? <Text style={[styles.stickyLabel, { color: theme.accent }]}>PINNED</Text> : null}
|
|
1165
|
+
<BranchContent {...props} />
|
|
1166
|
+
</ScrollView>
|
|
1167
|
+
<CloseBtn onPress={onDismiss} style={styles.bannerClosePos} />
|
|
1168
|
+
</View>
|
|
1169
|
+
</ScreenEdgeSurface>
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// ─── 6. floating tooltip (bubble fallback only) ──────────────────────────────
|
|
1174
|
+
|
|
1175
|
+
function FloatingTooltipInApp(props: InAppBranchProps): ReactElement {
|
|
1176
|
+
const { spec, theme, onDismiss } = props;
|
|
1177
|
+
const window = useWindowDimensions();
|
|
1178
|
+
const floatingBubble = props.variantKey === 'floating_bubble';
|
|
1179
|
+
const [expanded, setExpanded] = useState(!floatingBubble);
|
|
1180
|
+
const authoredPosition = typeof spec.ext?.position === 'string'
|
|
1181
|
+
? spec.ext.position.toLowerCase()
|
|
1182
|
+
: typeof spec.ext?.layoutPosition === 'string'
|
|
1183
|
+
? spec.ext.layoutPosition.toLowerCase()
|
|
1184
|
+
: 'bottom-right';
|
|
1185
|
+
const edge = authoredPosition.includes('top') ? 'top' : 'bottom';
|
|
1186
|
+
const edgeStyle = [
|
|
1187
|
+
styles.floatingEdge,
|
|
1188
|
+
authoredPosition.includes('left') ? styles.edgeAlignLeft : styles.edgeAlignRight,
|
|
1189
|
+
];
|
|
1190
|
+
if (floatingBubble && !expanded) {
|
|
1191
|
+
const label = typeof spec.ext?.bubbleLabel === 'string' ? spec.ext.bubbleLabel : 'Open';
|
|
1192
|
+
return (
|
|
1193
|
+
<ScreenEdgeSurface edge={edge} contentStyle={edgeStyle}>
|
|
1194
|
+
<Pressable
|
|
1195
|
+
accessibilityRole="button"
|
|
1196
|
+
accessibilityLabel={label}
|
|
1197
|
+
onPress={() => {
|
|
1198
|
+
setExpanded(true);
|
|
1199
|
+
props.onInteraction?.({ mechanic: 'floating_bubble', phase: 'started', value: spec.ext?.tapAction as string | undefined });
|
|
1200
|
+
}}
|
|
1201
|
+
style={[styles.floatingBubble, { backgroundColor: theme.accent }]}
|
|
1202
|
+
>
|
|
1203
|
+
<Text style={[styles.floatingBubbleText, { color: theme.ctaText }]}>{label}</Text>
|
|
1204
|
+
</Pressable>
|
|
1205
|
+
</ScreenEdgeSurface>
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
return (
|
|
1209
|
+
<ScreenEdgeSurface edge={edge} contentStyle={edgeStyle}>
|
|
1210
|
+
<View style={[styles.floatingPanel, { maxHeight: Math.max(120, window.height * 0.6) }]}>
|
|
1211
|
+
<View style={[styles.tooltipCard, { backgroundColor: theme.cardBg }]}>
|
|
1212
|
+
<CloseBtn onPress={onDismiss} style={styles.tooltipClosePos} />
|
|
1213
|
+
<ScrollView
|
|
1214
|
+
style={styles.floatingScroll}
|
|
1215
|
+
showsVerticalScrollIndicator={false}
|
|
1216
|
+
keyboardShouldPersistTaps="handled"
|
|
1217
|
+
>
|
|
1218
|
+
{props.children !== undefined ? <>{props.children}</> : (
|
|
1219
|
+
<>
|
|
1220
|
+
{spec.title ? <Text style={[styles.tooltipTitle, { color: theme.titleColor }, rtlText(theme)]}>{spec.title}</Text> : null}
|
|
1221
|
+
<Text style={[styles.tooltipBody, { color: theme.bodyColor }, rtlText(theme)]}>{spec.body}</Text>
|
|
1222
|
+
{spec.coupon ? <CouponChip code={spec.coupon} theme={theme} /> : null}
|
|
1223
|
+
{spec.cta ? (
|
|
1224
|
+
<Pressable
|
|
1225
|
+
accessibilityRole="button"
|
|
1226
|
+
accessibilityLabel={spec.cta.label}
|
|
1227
|
+
onPress={() => spec.cta!.action === 'dismiss' ? onDismiss() : props.onCta(spec.cta!)}
|
|
1228
|
+
style={styles.tooltipCta}
|
|
1229
|
+
>
|
|
1230
|
+
<Text style={[styles.tooltipCtaText, { color: theme.accent }]}>{spec.cta.label}</Text>
|
|
1231
|
+
</Pressable>
|
|
1232
|
+
) : null}
|
|
1233
|
+
</>
|
|
1234
|
+
)}
|
|
1235
|
+
</ScrollView>
|
|
1236
|
+
</View>
|
|
1237
|
+
</View>
|
|
1238
|
+
</ScreenEdgeSurface>
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
/** A placement-only micro popover; unlike coachmarks it does not require a measured anchor. */
|
|
1243
|
+
function MiniPopoverInApp(props: InAppBranchProps): ReactElement {
|
|
1244
|
+
const placement = props.spec.ext?.placement;
|
|
1245
|
+
const atBottom = placement === 'bottom';
|
|
1246
|
+
const window = useWindowDimensions();
|
|
1247
|
+
return (
|
|
1248
|
+
<ScreenEdgeSurface
|
|
1249
|
+
edge={atBottom ? 'bottom' : 'top'}
|
|
1250
|
+
contentStyle={[
|
|
1251
|
+
styles.floatingEdge,
|
|
1252
|
+
placement === 'left' ? styles.edgeAlignLeft : styles.edgeAlignRight,
|
|
1253
|
+
]}
|
|
1254
|
+
>
|
|
1255
|
+
<View style={[styles.miniPopoverPanel, { maxHeight: Math.max(120, window.height * 0.6) }]}>
|
|
1256
|
+
<View style={[styles.tooltipCard, { backgroundColor: props.theme.cardBg }]}>
|
|
1257
|
+
<CloseBtn onPress={props.onDismiss} style={styles.tooltipClosePos} />
|
|
1258
|
+
<ScrollView
|
|
1259
|
+
style={styles.floatingScroll}
|
|
1260
|
+
showsVerticalScrollIndicator={false}
|
|
1261
|
+
keyboardShouldPersistTaps="handled"
|
|
1262
|
+
>
|
|
1263
|
+
<BranchContent {...props} />
|
|
1264
|
+
</ScrollView>
|
|
1265
|
+
</View>
|
|
1266
|
+
</View>
|
|
1267
|
+
</ScreenEdgeSurface>
|
|
1268
|
+
);
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
const rectStyle = (rect: EngageAnchorRect): ViewStyle => ({
|
|
1272
|
+
position: 'absolute',
|
|
1273
|
+
left: rect.x,
|
|
1274
|
+
top: rect.y,
|
|
1275
|
+
width: rect.width,
|
|
1276
|
+
height: rect.height,
|
|
1277
|
+
});
|
|
1278
|
+
|
|
1279
|
+
type MeasuredCoachmark = {
|
|
1280
|
+
anchorKey: string;
|
|
1281
|
+
anchor: EngageAnchorRect;
|
|
1282
|
+
viewport: { width: number; height: number };
|
|
1283
|
+
};
|
|
1284
|
+
|
|
1285
|
+
interface MeasuredAnchorOptions {
|
|
1286
|
+
anchorKey: string;
|
|
1287
|
+
readyKey?: string;
|
|
1288
|
+
onReady?: () => void;
|
|
1289
|
+
onRenderError?: (reason: string) => void;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
/** Measure an anchor relative to its overlay and repeat after rotation/layout changes. */
|
|
1293
|
+
function useMeasuredAnchor({
|
|
1294
|
+
anchorKey,
|
|
1295
|
+
readyKey = anchorKey,
|
|
1296
|
+
onReady,
|
|
1297
|
+
onRenderError,
|
|
1298
|
+
}: MeasuredAnchorOptions): {
|
|
1299
|
+
overlayRef: React.RefObject<View>;
|
|
1300
|
+
measured: MeasuredCoachmark | null;
|
|
1301
|
+
remeasureOverlay: () => void;
|
|
1302
|
+
} {
|
|
1303
|
+
const registry = useEngageAnchorRegistry();
|
|
1304
|
+
const overlayRef = useRef<View>(null);
|
|
1305
|
+
const onReadyRef = useRef(onReady);
|
|
1306
|
+
const onErrorRef = useRef(onRenderError);
|
|
1307
|
+
const readyKeyRef = useRef<string | null>(null);
|
|
1308
|
+
const [measured, setMeasured] = useState<MeasuredCoachmark | null>(null);
|
|
1309
|
+
const [overlayRevision, setOverlayRevision] = useState(0);
|
|
1310
|
+
const window = useWindowDimensions();
|
|
1311
|
+
|
|
1312
|
+
onReadyRef.current = onReady;
|
|
1313
|
+
onErrorRef.current = onRenderError;
|
|
1314
|
+
|
|
1315
|
+
const remeasureOverlay = useCallback((): void => {
|
|
1316
|
+
setOverlayRevision((revision) => revision + 1);
|
|
1317
|
+
}, []);
|
|
1318
|
+
|
|
1319
|
+
useEffect(() => {
|
|
1320
|
+
setMeasured(null);
|
|
1321
|
+
readyKeyRef.current = null;
|
|
1322
|
+
if (!anchorKey) {
|
|
1323
|
+
onErrorRef.current?.('missing_anchor_key');
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
let cancelled = false;
|
|
1328
|
+
let exhausted = false;
|
|
1329
|
+
let attempts = 0;
|
|
1330
|
+
let retry: ReturnType<typeof setTimeout> | null = null;
|
|
1331
|
+
|
|
1332
|
+
const failOrRetry = (): void => {
|
|
1333
|
+
if (cancelled || exhausted) return;
|
|
1334
|
+
if (attempts >= 20) {
|
|
1335
|
+
exhausted = true;
|
|
1336
|
+
onErrorRef.current?.(coachmarkAnchorError(anchorKey));
|
|
1337
|
+
return;
|
|
1338
|
+
}
|
|
1339
|
+
attempts += 1;
|
|
1340
|
+
retry = setTimeout(measure, 100);
|
|
1341
|
+
};
|
|
1342
|
+
|
|
1343
|
+
const measure = (): void => {
|
|
1344
|
+
if (cancelled || exhausted) return;
|
|
1345
|
+
const overlay = overlayRef.current;
|
|
1346
|
+
if (!overlay) {
|
|
1347
|
+
failOrRetry();
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
overlay.measureInWindow((overlayX, overlayY, overlayWidth, overlayHeight) => {
|
|
1351
|
+
if (cancelled || overlayWidth <= 0 || overlayHeight <= 0) {
|
|
1352
|
+
failOrRetry();
|
|
1353
|
+
return;
|
|
1354
|
+
}
|
|
1355
|
+
const found = registry.measure(anchorKey, (anchor) => {
|
|
1356
|
+
if (cancelled) return;
|
|
1357
|
+
if (!anchor) {
|
|
1358
|
+
failOrRetry();
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
const local = {
|
|
1362
|
+
x: anchor.x - overlayX,
|
|
1363
|
+
y: anchor.y - overlayY,
|
|
1364
|
+
width: anchor.width,
|
|
1365
|
+
height: anchor.height,
|
|
1366
|
+
};
|
|
1367
|
+
const visible = local.x + local.width > 0 &&
|
|
1368
|
+
local.y + local.height > 0 &&
|
|
1369
|
+
local.x < overlayWidth &&
|
|
1370
|
+
local.y < overlayHeight;
|
|
1371
|
+
if (!visible) {
|
|
1372
|
+
failOrRetry();
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
setMeasured({
|
|
1376
|
+
anchorKey,
|
|
1377
|
+
anchor: local,
|
|
1378
|
+
viewport: { width: overlayWidth, height: overlayHeight },
|
|
1379
|
+
});
|
|
1380
|
+
if (readyKeyRef.current !== readyKey) {
|
|
1381
|
+
readyKeyRef.current = readyKey;
|
|
1382
|
+
onReadyRef.current?.();
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
if (!found) failOrRetry();
|
|
1386
|
+
});
|
|
1387
|
+
};
|
|
1388
|
+
|
|
1389
|
+
const unsubscribe = registry.subscribe(anchorKey, () => {
|
|
1390
|
+
attempts = 0;
|
|
1391
|
+
if (retry) clearTimeout(retry);
|
|
1392
|
+
measure();
|
|
1393
|
+
});
|
|
1394
|
+
const kickoff = setTimeout(measure, 0);
|
|
1395
|
+
return () => {
|
|
1396
|
+
cancelled = true;
|
|
1397
|
+
clearTimeout(kickoff);
|
|
1398
|
+
if (retry) clearTimeout(retry);
|
|
1399
|
+
unsubscribe();
|
|
1400
|
+
};
|
|
1401
|
+
}, [anchorKey, overlayRevision, readyKey, registry, window.height, window.width]);
|
|
1402
|
+
|
|
1403
|
+
return {
|
|
1404
|
+
overlayRef,
|
|
1405
|
+
measured: measured?.anchorKey === anchorKey ? measured : null,
|
|
1406
|
+
remeasureOverlay,
|
|
1407
|
+
};
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
interface AnchoredCardProps {
|
|
1411
|
+
geometry: CoachmarkGeometry;
|
|
1412
|
+
theme: InAppTheme;
|
|
1413
|
+
onDismiss: () => void;
|
|
1414
|
+
onLayout: (event: LayoutChangeEvent) => void;
|
|
1415
|
+
children: ReactNode;
|
|
1416
|
+
}
|
|
1417
|
+
|
|
1418
|
+
/** Shared measured card/arrow; spotlight and tooltip differ only in their root. */
|
|
1419
|
+
function AnchoredCard({
|
|
1420
|
+
geometry,
|
|
1421
|
+
theme,
|
|
1422
|
+
onDismiss,
|
|
1423
|
+
onLayout,
|
|
1424
|
+
children,
|
|
1425
|
+
}: AnchoredCardProps): ReactElement {
|
|
1426
|
+
return (
|
|
1427
|
+
<View
|
|
1428
|
+
style={[
|
|
1429
|
+
styles.coachmarkTooltipWrap,
|
|
1430
|
+
{
|
|
1431
|
+
left: geometry.tooltip.left,
|
|
1432
|
+
width: geometry.tooltip.width,
|
|
1433
|
+
...(geometry.tooltip.top !== undefined
|
|
1434
|
+
? { top: geometry.tooltip.top }
|
|
1435
|
+
: { bottom: geometry.tooltip.bottom }),
|
|
1436
|
+
},
|
|
1437
|
+
]}
|
|
1438
|
+
>
|
|
1439
|
+
<View
|
|
1440
|
+
pointerEvents="none"
|
|
1441
|
+
style={[
|
|
1442
|
+
styles.coachmarkArrow,
|
|
1443
|
+
{
|
|
1444
|
+
...(geometry.tooltip.arrowLeft !== undefined
|
|
1445
|
+
? { left: geometry.tooltip.arrowLeft }
|
|
1446
|
+
: { top: geometry.tooltip.arrowTop }),
|
|
1447
|
+
backgroundColor: theme.cardBg,
|
|
1448
|
+
},
|
|
1449
|
+
geometry.tooltip.placement === 'bottom'
|
|
1450
|
+
? styles.coachmarkArrowTop
|
|
1451
|
+
: geometry.tooltip.placement === 'top'
|
|
1452
|
+
? styles.coachmarkArrowBottom
|
|
1453
|
+
: geometry.tooltip.placement === 'left'
|
|
1454
|
+
? styles.coachmarkArrowRight
|
|
1455
|
+
: styles.coachmarkArrowLeft,
|
|
1456
|
+
]}
|
|
1457
|
+
/>
|
|
1458
|
+
<View
|
|
1459
|
+
onLayout={onLayout}
|
|
1460
|
+
style={[
|
|
1461
|
+
styles.coachmarkCard,
|
|
1462
|
+
{ backgroundColor: theme.cardBg, maxHeight: geometry.tooltip.maxHeight },
|
|
1463
|
+
]}
|
|
1464
|
+
>
|
|
1465
|
+
<CloseBtn onPress={onDismiss} style={styles.tooltipClosePos} />
|
|
1466
|
+
<ScrollView
|
|
1467
|
+
style={styles.coachmarkScroll}
|
|
1468
|
+
showsVerticalScrollIndicator={false}
|
|
1469
|
+
keyboardShouldPersistTaps="handled"
|
|
1470
|
+
>
|
|
1471
|
+
{children}
|
|
1472
|
+
</ScrollView>
|
|
1473
|
+
</View>
|
|
1474
|
+
</View>
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
const coachmarkLabel = (value: unknown, fallback: string): string =>
|
|
1479
|
+
typeof value === 'string' && value.trim() ? value.trim() : fallback;
|
|
1480
|
+
|
|
1481
|
+
/** Plain tooltip: attached to an anchor without dimming or blocking the host screen. */
|
|
1482
|
+
function AnchoredTooltipInApp(props: InAppBranchProps): ReactElement {
|
|
1483
|
+
const { spec, theme, onDismiss } = props;
|
|
1484
|
+
const step = useMemo(() => normalizeLegacyAnchoredStep(spec), [spec]);
|
|
1485
|
+
const [cardHeight, setCardHeight] = useState(160);
|
|
1486
|
+
// Android's RN content root commonly consumes system bars; iOS needs the raw
|
|
1487
|
+
// safe-area because an absolute sibling can extend beneath a cutout.
|
|
1488
|
+
const nativeInsets = useEngageWindowInsets(Platform.OS === 'android');
|
|
1489
|
+
const safeInsets = nativeInsets ?? (Platform.OS === 'ios'
|
|
1490
|
+
? { top: 44, right: 0, bottom: 34, left: 0 }
|
|
1491
|
+
: ZERO_ENGAGE_WINDOW_INSETS);
|
|
1492
|
+
const { overlayRef, measured, remeasureOverlay } = useMeasuredAnchor({
|
|
1493
|
+
anchorKey: step?.anchorKey ?? '',
|
|
1494
|
+
onReady: props.onReady,
|
|
1495
|
+
onRenderError: props.onRenderError,
|
|
1496
|
+
});
|
|
1497
|
+
const geometry = measured && step
|
|
1498
|
+
? resolveCoachmarkGeometry(measured.anchor, measured.viewport, step.placement, {
|
|
1499
|
+
cardHeight,
|
|
1500
|
+
insets: safeInsets,
|
|
1501
|
+
})
|
|
1502
|
+
: null;
|
|
1503
|
+
const measureCard = useCallback((event: LayoutChangeEvent): void => {
|
|
1504
|
+
const next = Math.round(event.nativeEvent.layout.height);
|
|
1505
|
+
if (next > 0) setCardHeight((current) => Math.abs(current - next) > 1 ? next : current);
|
|
1506
|
+
}, []);
|
|
1507
|
+
|
|
1508
|
+
return (
|
|
1509
|
+
<View
|
|
1510
|
+
ref={overlayRef}
|
|
1511
|
+
collapsable={false}
|
|
1512
|
+
pointerEvents="box-none"
|
|
1513
|
+
style={styles.anchoredTooltipRoot}
|
|
1514
|
+
onLayout={remeasureOverlay}
|
|
1515
|
+
>
|
|
1516
|
+
{geometry && step ? (
|
|
1517
|
+
<AnchoredCard
|
|
1518
|
+
geometry={geometry}
|
|
1519
|
+
theme={theme}
|
|
1520
|
+
onDismiss={onDismiss}
|
|
1521
|
+
onLayout={measureCard}
|
|
1522
|
+
>
|
|
1523
|
+
{props.variantKey === 'fab_prompt' ? (
|
|
1524
|
+
<Text style={[styles.coachmarkEyebrow, { color: theme.accent }]}>+ QUICK ACTION</Text>
|
|
1525
|
+
) : null}
|
|
1526
|
+
{step.title ? <Text style={[styles.tooltipTitle, { color: theme.titleColor }, rtlText(theme)]}>{step.title}</Text> : null}
|
|
1527
|
+
{step.body ? <Text style={[styles.tooltipBody, { color: theme.bodyColor }, rtlText(theme)]}>{step.body}</Text> : null}
|
|
1528
|
+
{step.cta ? (
|
|
1529
|
+
<Pressable
|
|
1530
|
+
accessibilityRole="button"
|
|
1531
|
+
accessibilityLabel={step.cta.label}
|
|
1532
|
+
onPress={() => step.cta!.action === 'dismiss' ? onDismiss() : props.onCta(step.cta!)}
|
|
1533
|
+
style={styles.tooltipCta}
|
|
1534
|
+
>
|
|
1535
|
+
<Text style={[styles.tooltipCtaText, { color: theme.accent }]}>{step.cta.label}</Text>
|
|
1536
|
+
</Pressable>
|
|
1537
|
+
) : null}
|
|
1538
|
+
</AnchoredCard>
|
|
1539
|
+
) : null}
|
|
1540
|
+
</View>
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
/** Guided tour: one measured spotlight per ordered step, with full-screen scrim. */
|
|
1545
|
+
function CoachmarkSpotlightInApp(props: InAppBranchProps): ReactElement {
|
|
1546
|
+
const { spec, theme, onDismiss } = props;
|
|
1547
|
+
const steps = useMemo(() => normalizeCoachmarkSteps(spec), [spec]);
|
|
1548
|
+
const [stepIndex, setStepIndex] = useState(0);
|
|
1549
|
+
const [cardHeight, setCardHeight] = useState(160);
|
|
1550
|
+
const viewedStepsRef = useRef(new Set<number>());
|
|
1551
|
+
const step = steps[stepIndex];
|
|
1552
|
+
const nativeInsets = useEngageWindowInsets();
|
|
1553
|
+
const safeInsets = nativeInsets ?? (Platform.OS === 'ios'
|
|
1554
|
+
? { top: 59, right: 44, bottom: 34, left: 44 }
|
|
1555
|
+
: { top: StatusBar.currentHeight ?? 0, right: 0, bottom: 16, left: 0 });
|
|
1556
|
+
|
|
1557
|
+
useEffect(() => {
|
|
1558
|
+
setStepIndex(0);
|
|
1559
|
+
setCardHeight(160);
|
|
1560
|
+
viewedStepsRef.current.clear();
|
|
1561
|
+
}, [steps]);
|
|
1562
|
+
|
|
1563
|
+
const handleStepReady = useCallback((): void => {
|
|
1564
|
+
props.onReady?.();
|
|
1565
|
+
if (viewedStepsRef.current.has(stepIndex)) return;
|
|
1566
|
+
viewedStepsRef.current.add(stepIndex);
|
|
1567
|
+
props.onInteraction?.({
|
|
1568
|
+
mechanic: 'coachmark_spotlight',
|
|
1569
|
+
phase: stepIndex === 0 ? 'started' : 'progress',
|
|
1570
|
+
result: 'step_viewed',
|
|
1571
|
+
meta: { anchorKey: step?.anchorKey, step: stepIndex + 1, totalSteps: steps.length },
|
|
1572
|
+
});
|
|
1573
|
+
}, [props, step?.anchorKey, stepIndex, steps.length]);
|
|
1574
|
+
|
|
1575
|
+
const { overlayRef, measured, remeasureOverlay } = useMeasuredAnchor({
|
|
1576
|
+
anchorKey: step?.anchorKey ?? '',
|
|
1577
|
+
readyKey: `${stepIndex}:${step?.anchorKey ?? ''}`,
|
|
1578
|
+
onReady: handleStepReady,
|
|
1579
|
+
onRenderError: props.onRenderError,
|
|
1580
|
+
});
|
|
1581
|
+
|
|
1582
|
+
const geometry = measured
|
|
1583
|
+
? resolveCoachmarkGeometry(measured.anchor, measured.viewport, step?.placement, {
|
|
1584
|
+
cardHeight,
|
|
1585
|
+
insets: safeInsets,
|
|
1586
|
+
})
|
|
1587
|
+
: null;
|
|
1588
|
+
const measureCard = useCallback((event: LayoutChangeEvent): void => {
|
|
1589
|
+
const next = Math.round(event.nativeEvent.layout.height);
|
|
1590
|
+
if (next > 0) setCardHeight((current) => Math.abs(current - next) > 1 ? next : current);
|
|
1591
|
+
}, []);
|
|
1592
|
+
const scrim = spec.style?.backdrop ?? 'rgba(0,0,0,0.68)';
|
|
1593
|
+
const radius = typeof spec.ext?.spotlightRadius === 'number'
|
|
1594
|
+
? clamp(spec.ext.spotlightRadius, 0, 40)
|
|
1595
|
+
: 14;
|
|
1596
|
+
const finalCta = stepIndex === steps.length - 1 ? step?.cta ?? spec.cta : undefined;
|
|
1597
|
+
const goTo = (result: 'next' | 'back'): void => {
|
|
1598
|
+
const nextIndex = resolveCoachmarkStepIndex(stepIndex, steps.length, result);
|
|
1599
|
+
props.onInteraction?.({
|
|
1600
|
+
mechanic: 'coachmark_spotlight',
|
|
1601
|
+
phase: 'progress',
|
|
1602
|
+
result,
|
|
1603
|
+
meta: {
|
|
1604
|
+
anchorKey: step?.anchorKey,
|
|
1605
|
+
fromStep: stepIndex + 1,
|
|
1606
|
+
toStep: nextIndex + 1,
|
|
1607
|
+
totalSteps: steps.length,
|
|
1608
|
+
},
|
|
1609
|
+
});
|
|
1610
|
+
setCardHeight(160);
|
|
1611
|
+
setStepIndex(nextIndex);
|
|
1612
|
+
};
|
|
1613
|
+
const skip = (): void => {
|
|
1614
|
+
props.onInteraction?.({
|
|
1615
|
+
mechanic: 'coachmark_spotlight',
|
|
1616
|
+
phase: 'decision',
|
|
1617
|
+
result: 'skipped',
|
|
1618
|
+
meta: { anchorKey: step?.anchorKey, step: stepIndex + 1, totalSteps: steps.length },
|
|
1619
|
+
});
|
|
1620
|
+
onDismiss();
|
|
1621
|
+
};
|
|
1622
|
+
const finish = (): void => {
|
|
1623
|
+
props.onInteraction?.({
|
|
1624
|
+
mechanic: 'coachmark_spotlight',
|
|
1625
|
+
phase: 'completed',
|
|
1626
|
+
result: 'finished',
|
|
1627
|
+
meta: { anchorKey: step?.anchorKey, step: stepIndex + 1, totalSteps: steps.length },
|
|
1628
|
+
});
|
|
1629
|
+
if (resolveCoachmarkFinishMode(finalCta) === 'cta' && finalCta) props.onCta(finalCta);
|
|
1630
|
+
else if (props.onComplete) props.onComplete();
|
|
1631
|
+
else onDismiss();
|
|
1632
|
+
};
|
|
1633
|
+
|
|
1634
|
+
return (
|
|
1635
|
+
<Modal
|
|
1636
|
+
visible
|
|
1637
|
+
transparent
|
|
1638
|
+
animationType="fade"
|
|
1639
|
+
statusBarTranslucent
|
|
1640
|
+
onRequestClose={onDismiss}
|
|
1641
|
+
>
|
|
1642
|
+
<View
|
|
1643
|
+
ref={overlayRef}
|
|
1644
|
+
collapsable={false}
|
|
1645
|
+
style={styles.coachmarkRoot}
|
|
1646
|
+
onLayout={remeasureOverlay}
|
|
1647
|
+
pointerEvents="box-none"
|
|
1648
|
+
>
|
|
1649
|
+
{geometry && step ? <>
|
|
1650
|
+
{geometry.scrims.map((rect, index) => (
|
|
1651
|
+
<Pressable
|
|
1652
|
+
key={index}
|
|
1653
|
+
accessibilityRole="none"
|
|
1654
|
+
onPress={onDismiss}
|
|
1655
|
+
style={[rectStyle(rect), { backgroundColor: scrim }]}
|
|
1656
|
+
/>
|
|
1657
|
+
))}
|
|
1658
|
+
<View
|
|
1659
|
+
pointerEvents="none"
|
|
1660
|
+
style={[
|
|
1661
|
+
styles.coachmarkSpotlight,
|
|
1662
|
+
rectStyle(geometry.spotlight),
|
|
1663
|
+
{ borderRadius: radius, borderColor: theme.accent },
|
|
1664
|
+
]}
|
|
1665
|
+
/>
|
|
1666
|
+
<AnchoredCard
|
|
1667
|
+
geometry={geometry}
|
|
1668
|
+
theme={theme}
|
|
1669
|
+
onDismiss={skip}
|
|
1670
|
+
onLayout={measureCard}
|
|
1671
|
+
>
|
|
1672
|
+
<Text style={[styles.coachmarkEyebrow, { color: theme.accent }]}>STEP {stepIndex + 1} OF {steps.length}</Text>
|
|
1673
|
+
{step.title ? <Text style={[styles.tooltipTitle, { color: theme.titleColor }, rtlText(theme)]}>{step.title}</Text> : null}
|
|
1674
|
+
{step.body ? <Text style={[styles.tooltipBody, { color: theme.bodyColor }, rtlText(theme)]}>{step.body}</Text> : null}
|
|
1675
|
+
<View style={styles.coachmarkActions}>
|
|
1676
|
+
<Pressable
|
|
1677
|
+
accessibilityRole="button"
|
|
1678
|
+
accessibilityLabel={coachmarkLabel(spec.ext?.skipLabel, 'Skip tour')}
|
|
1679
|
+
onPress={skip}
|
|
1680
|
+
style={styles.coachmarkTextButton}
|
|
1681
|
+
>
|
|
1682
|
+
<Text style={[styles.coachmarkSecondaryText, { color: theme.bodyColor }]}>{coachmarkLabel(spec.ext?.skipLabel, 'Skip')}</Text>
|
|
1683
|
+
</Pressable>
|
|
1684
|
+
<View style={styles.coachmarkNavActions}>
|
|
1685
|
+
{stepIndex > 0 ? (
|
|
1686
|
+
<Pressable
|
|
1687
|
+
accessibilityRole="button"
|
|
1688
|
+
accessibilityLabel={coachmarkLabel(spec.ext?.backLabel, 'Previous step')}
|
|
1689
|
+
onPress={() => goTo('back')}
|
|
1690
|
+
style={styles.coachmarkTextButton}
|
|
1691
|
+
>
|
|
1692
|
+
<Text style={[styles.coachmarkSecondaryText, { color: theme.bodyColor }]}>{coachmarkLabel(spec.ext?.backLabel, 'Back')}</Text>
|
|
1693
|
+
</Pressable>
|
|
1694
|
+
) : null}
|
|
1695
|
+
<Pressable
|
|
1696
|
+
accessibilityRole="button"
|
|
1697
|
+
accessibilityLabel={stepIndex < steps.length - 1
|
|
1698
|
+
? coachmarkLabel(spec.ext?.nextLabel, 'Next step')
|
|
1699
|
+
: coachmarkLabel(spec.ext?.finishLabel, finalCta?.label ?? spec.cta?.label ?? 'Finish tour')}
|
|
1700
|
+
onPress={() => stepIndex < steps.length - 1
|
|
1701
|
+
? goTo('next')
|
|
1702
|
+
: finish()}
|
|
1703
|
+
style={[styles.coachmarkPrimaryButton, { backgroundColor: theme.accent }]}
|
|
1704
|
+
>
|
|
1705
|
+
<Text style={[styles.coachmarkPrimaryText, { color: theme.ctaText }]}>
|
|
1706
|
+
{stepIndex < steps.length - 1
|
|
1707
|
+
? coachmarkLabel(spec.ext?.nextLabel, 'Next')
|
|
1708
|
+
: coachmarkLabel(spec.ext?.finishLabel, finalCta?.label ?? spec.cta?.label ?? 'Finish')}
|
|
1709
|
+
</Text>
|
|
1710
|
+
</Pressable>
|
|
1711
|
+
</View>
|
|
1712
|
+
</View>
|
|
1713
|
+
</AnchoredCard>
|
|
1714
|
+
</> : null}
|
|
1715
|
+
</View>
|
|
1716
|
+
</Modal>
|
|
1717
|
+
);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
function AnchoredInApp(props: InAppBranchProps): ReactElement {
|
|
1721
|
+
return resolveAnchoredSurfaceKind(props.variantKey) === 'spotlight'
|
|
1722
|
+
? <CoachmarkSpotlightInApp {...props} />
|
|
1723
|
+
: <AnchoredTooltipInApp {...props} />;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
// ─── inline — participates in host layout and never opens an overlay ─────────
|
|
1727
|
+
|
|
1728
|
+
function InlineInApp(props: InAppBranchProps): ReactElement {
|
|
1729
|
+
const { theme, onDismiss } = props;
|
|
1730
|
+
return (
|
|
1731
|
+
<View style={[styles.inlineCard, { backgroundColor: theme.cardBg }]}>
|
|
1732
|
+
<CloseBtn onPress={onDismiss} style={styles.inlineClosePos} />
|
|
1733
|
+
<BranchContent {...props} />
|
|
1734
|
+
</View>
|
|
1735
|
+
);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// ─── 7. toast — transient strip, auto-dismisses after 3 s ────────────────────
|
|
1739
|
+
|
|
1740
|
+
export function resolveToastDuration(value: unknown): number {
|
|
1741
|
+
return clamp(typeof value === 'number' && Number.isFinite(value) ? value : 3000, 1000, 60_000);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
function ToastInApp(props: InAppBranchProps): ReactElement {
|
|
1745
|
+
const { spec, onDismiss } = props;
|
|
1746
|
+
const window = useWindowDimensions();
|
|
1747
|
+
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
1748
|
+
const autoDismiss = spec.ext?.autoDismiss !== false;
|
|
1749
|
+
const duration = resolveToastDuration(
|
|
1750
|
+
typeof spec.ext?.autoDismiss === 'number' ? spec.ext.autoDismiss : spec.ext?.durationMs,
|
|
1751
|
+
);
|
|
1752
|
+
useEffect(() => {
|
|
1753
|
+
if (!autoDismiss) return;
|
|
1754
|
+
timerRef.current = setTimeout(onDismiss, duration);
|
|
1755
|
+
return () => { if (timerRef.current) clearTimeout(timerRef.current); };
|
|
1756
|
+
// onDismiss identity stable (memoized in provider); exhaustive-deps would re-arm on every render
|
|
1757
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1758
|
+
}, [autoDismiss, duration]);
|
|
1759
|
+
const { theme } = props;
|
|
1760
|
+
const position = screenPosition(spec.ext?.position)
|
|
1761
|
+
?? screenPosition(spec.ext?.layoutPosition)
|
|
1762
|
+
?? 'bottom';
|
|
1763
|
+
const edge = position === 'top' ? 'top' : 'bottom';
|
|
1764
|
+
return (
|
|
1765
|
+
<ScreenEdgeSurface edge={edge} contentStyle={styles.toastWrap}>
|
|
1766
|
+
<Pressable style={[styles.toastCard, { backgroundColor: theme.cardBg }]} onPress={onDismiss} accessibilityRole="none">
|
|
1767
|
+
<ScrollView
|
|
1768
|
+
style={[styles.toastScroll, { maxHeight: Math.max(96, window.height * 0.4) }]}
|
|
1769
|
+
showsVerticalScrollIndicator={false}
|
|
1770
|
+
keyboardShouldPersistTaps="handled"
|
|
1771
|
+
>
|
|
1772
|
+
{props.children !== undefined ? <>{props.children}</> : (
|
|
1773
|
+
<>
|
|
1774
|
+
{spec.title ? <Text style={[styles.toastTitle, { color: theme.titleColor }, rtlText(theme)]}>{spec.title}</Text> : null}
|
|
1775
|
+
<Text style={[styles.toastBody, { color: theme.bodyColor }, rtlText(theme)]} numberOfLines={2}>{spec.body}</Text>
|
|
1776
|
+
{spec.cta ? (
|
|
1777
|
+
<Pressable
|
|
1778
|
+
accessibilityRole="button"
|
|
1779
|
+
accessibilityLabel={spec.cta.label}
|
|
1780
|
+
onPress={() => spec.cta!.action === 'dismiss' ? onDismiss() : props.onCta(spec.cta!)}
|
|
1781
|
+
>
|
|
1782
|
+
<Text style={[styles.toastCtaText, { color: theme.accent }]}>{spec.cta.label}</Text>
|
|
1783
|
+
</Pressable>
|
|
1784
|
+
) : null}
|
|
1785
|
+
</>
|
|
1786
|
+
)}
|
|
1787
|
+
</ScrollView>
|
|
1788
|
+
</Pressable>
|
|
1789
|
+
</ScreenEdgeSurface>
|
|
1790
|
+
);
|
|
1791
|
+
}
|
|
1792
|
+
|
|
1793
|
+
// ─── Open/Closed registry ─────────────────────────────────────────────────────
|
|
1794
|
+
|
|
1795
|
+
export const INAPP_RENDERERS: Record<InAppLayout, InAppRenderer> = {
|
|
1796
|
+
modal: ModalInApp,
|
|
1797
|
+
fullscreen: FullScreenInApp,
|
|
1798
|
+
bottom_sheet: BottomSheetInApp,
|
|
1799
|
+
top_banner: TopBannerInApp,
|
|
1800
|
+
bottom_banner: BottomBannerInApp,
|
|
1801
|
+
tooltip: AnchoredInApp,
|
|
1802
|
+
toast: ToastInApp,
|
|
1803
|
+
};
|
|
1804
|
+
|
|
1805
|
+
const MOUNT_MODEL_RENDERERS: Record<InAppMountModel, InAppRenderer> = {
|
|
1806
|
+
overlay: ModalInApp,
|
|
1807
|
+
sheet: BottomSheetInApp,
|
|
1808
|
+
banner: TopBannerInApp,
|
|
1809
|
+
fullscreen: FullScreenInApp,
|
|
1810
|
+
toast: ToastInApp,
|
|
1811
|
+
bubble: FloatingTooltipInApp,
|
|
1812
|
+
anchored: AnchoredInApp,
|
|
1813
|
+
inline: InlineInApp,
|
|
1814
|
+
};
|
|
1815
|
+
|
|
1816
|
+
/** Resolve the render branch for a config layout (always defined). */
|
|
1817
|
+
export function resolveInAppRenderer(layout: InAppMessageConfig['layout']): InAppRenderer {
|
|
1818
|
+
return INAPP_RENDERERS[resolveInAppLayout(layout)];
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/**
|
|
1822
|
+
* Resolve canonical additive surfaces before degrading to the stable seven-layout
|
|
1823
|
+
* registry. Content remains a child of the selected surface in either path.
|
|
1824
|
+
*/
|
|
1825
|
+
export function resolveInAppPresentationRenderer(
|
|
1826
|
+
presentation: Pick<ResolvedInAppPresentation, 'archetype' | 'mountModel' | 'legacyLayout' | 'variantKey'>,
|
|
1827
|
+
mountModelOverride?: InAppMountModel,
|
|
1828
|
+
): InAppRenderer {
|
|
1829
|
+
if (mountModelOverride) return MOUNT_MODEL_RENDERERS[mountModelOverride];
|
|
1830
|
+
const additive = ADDITIVE_INAPP_RENDERERS[presentation.archetype];
|
|
1831
|
+
if (additive) return additive;
|
|
1832
|
+
if (presentation.variantKey === 'mini_popover') return MiniPopoverInApp;
|
|
1833
|
+
if (presentation.variantKey === 'peek_card') return PeekCardInApp;
|
|
1834
|
+
if (presentation.mountModel === 'banner' && presentation.legacyLayout === 'bottom_banner') {
|
|
1835
|
+
return BottomBannerInApp;
|
|
1836
|
+
}
|
|
1837
|
+
return MOUNT_MODEL_RENDERERS[presentation.mountModel];
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
// ─── Render-failure boundary (T1 G/render honesty) ────────────────────────────
|
|
1841
|
+
// A malformed render spec (or a downstream render throw) must NEVER crash the host
|
|
1842
|
+
// app and must NEVER silently vanish. This boundary catches the render error, reports
|
|
1843
|
+
// it via `onError(reason)` (provider → `render_failed` diagnostic, which also marks a
|
|
1844
|
+
// test preview failed server-side), and renders nothing in its place. Reset keys on
|
|
1845
|
+
// the message id so a new message after a failure gets a fresh attempt.
|
|
1846
|
+
interface InAppErrorBoundaryProps {
|
|
1847
|
+
resetKey: string;
|
|
1848
|
+
onError: (reason: string) => void;
|
|
1849
|
+
children: ReactNode;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
class InAppErrorBoundary extends Component<InAppErrorBoundaryProps, { failed: boolean }> {
|
|
1853
|
+
constructor(props: InAppErrorBoundaryProps) {
|
|
1854
|
+
super(props);
|
|
1855
|
+
this.state = { failed: false };
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
static getDerivedStateFromError(): { failed: boolean } {
|
|
1859
|
+
return { failed: true };
|
|
1860
|
+
}
|
|
1861
|
+
|
|
1862
|
+
componentDidUpdate(prev: InAppErrorBoundaryProps): void {
|
|
1863
|
+
// New message after a prior failure → clear the failed state and retry render.
|
|
1864
|
+
if (prev.resetKey !== this.props.resetKey && this.state.failed) {
|
|
1865
|
+
this.setState({ failed: false });
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
componentDidCatch(error: Error): void {
|
|
1870
|
+
this.props.onError(error?.message || 'render_error');
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
render(): ReactNode {
|
|
1874
|
+
return this.state.failed ? null : this.props.children;
|
|
1875
|
+
}
|
|
1876
|
+
}
|
|
1877
|
+
|
|
1878
|
+
// ─── Public mount point ───────────────────────────────────────────────────────
|
|
1879
|
+
|
|
1880
|
+
export interface EngageInAppViewProps {
|
|
1881
|
+
message: InAppMessageConfig | null;
|
|
1882
|
+
visible: boolean;
|
|
1883
|
+
/**
|
|
1884
|
+
* Optional render spec override (A/B experiment, D8/J6). When supplied, this
|
|
1885
|
+
* spec is rendered instead of `message.spec` — the provider resolves the chosen
|
|
1886
|
+
* variant's content and passes it here. Omitted ⇒ render `message.spec`.
|
|
1887
|
+
*/
|
|
1888
|
+
spec?: InAppRenderSpec;
|
|
1889
|
+
/**
|
|
1890
|
+
* Provider-only graceful degradation for an unavailable host placement.
|
|
1891
|
+
* Content still resolves from the canonical variant; only its physical mount changes.
|
|
1892
|
+
*/
|
|
1893
|
+
mountModelOverride?: InAppMountModel;
|
|
1894
|
+
/** Fired once when the message first becomes visible (provider → impression). */
|
|
1895
|
+
onShow: () => void;
|
|
1896
|
+
/** Primary CTA tapped — provider emits `click` + surfaces the deep link. */
|
|
1897
|
+
onCta: (cta: NonNullable<InAppRenderSpec['cta']>) => void;
|
|
1898
|
+
/** Dismissed — provider emits `dismiss`. */
|
|
1899
|
+
onDismiss: () => void;
|
|
1900
|
+
/** Guided flow finished — provider emits `completion`. */
|
|
1901
|
+
onComplete?: () => void;
|
|
1902
|
+
/** Optional host-visible mechanic lifecycle callback. */
|
|
1903
|
+
onInteraction?: (interaction: InAppMechanicInteraction) => void;
|
|
1904
|
+
/** Customer-owned backend resolver for the eight gamified variants. */
|
|
1905
|
+
onInAppGameRequest?: InAppGameRequestHandler;
|
|
1906
|
+
/** Render failed (malformed spec / render throw) — provider emits `render_failed`. */
|
|
1907
|
+
onRenderError?: (reason: string) => void;
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
/**
|
|
1911
|
+
* Single mount point for in-app messages. Reads `message.layout`, auto-selects
|
|
1912
|
+
* the correct renderer from the registry, fires `onShow()` exactly once per
|
|
1913
|
+
* message. App developers write zero layout code.
|
|
1914
|
+
*/
|
|
1915
|
+
export function EngageInAppView({
|
|
1916
|
+
message,
|
|
1917
|
+
visible,
|
|
1918
|
+
spec,
|
|
1919
|
+
mountModelOverride,
|
|
1920
|
+
onShow,
|
|
1921
|
+
onCta,
|
|
1922
|
+
onDismiss,
|
|
1923
|
+
onComplete,
|
|
1924
|
+
onInteraction,
|
|
1925
|
+
onInAppGameRequest,
|
|
1926
|
+
onRenderError,
|
|
1927
|
+
}: EngageInAppViewProps): ReactElement | null {
|
|
1928
|
+
const effectiveSpec = spec ?? message?.spec;
|
|
1929
|
+
const presentation = message && effectiveSpec
|
|
1930
|
+
? resolveInAppPresentation({
|
|
1931
|
+
layout: message.layout,
|
|
1932
|
+
variantKey: message.variantKey,
|
|
1933
|
+
spec: effectiveSpec,
|
|
1934
|
+
})
|
|
1935
|
+
: null;
|
|
1936
|
+
const effectiveMountModel = mountModelOverride ?? presentation?.mountModel;
|
|
1937
|
+
const gameAttemptsRef = useRef<{
|
|
1938
|
+
messageId: string | null;
|
|
1939
|
+
ids: Map<string, string>;
|
|
1940
|
+
}>({ messageId: null, ids: new Map() });
|
|
1941
|
+
if (gameAttemptsRef.current.messageId !== (message?.id ?? null)) {
|
|
1942
|
+
gameAttemptsRef.current = { messageId: message?.id ?? null, ids: new Map() };
|
|
1943
|
+
}
|
|
1944
|
+
const requestGameResult = useCallback(async (
|
|
1945
|
+
rawAttempt = 1,
|
|
1946
|
+
input?: Record<string, unknown>,
|
|
1947
|
+
): Promise<InAppGameResult> => {
|
|
1948
|
+
if (!message || !effectiveSpec || !isInAppGameVariant(presentation?.variantKey)) {
|
|
1949
|
+
throw new Error('Game result requested by a non-gamified message');
|
|
1950
|
+
}
|
|
1951
|
+
const variantKey = presentation.variantKey;
|
|
1952
|
+
const attempt = Number.isFinite(rawAttempt)
|
|
1953
|
+
? Math.max(1, Math.floor(rawAttempt))
|
|
1954
|
+
: 1;
|
|
1955
|
+
const idKey = `${variantKey}:${attempt}`;
|
|
1956
|
+
let attemptId = gameAttemptsRef.current.ids.get(idKey);
|
|
1957
|
+
if (!attemptId) {
|
|
1958
|
+
gameAttemptSequence += 1;
|
|
1959
|
+
attemptId = `scalebun_game_${Date.now().toString(36)}_${gameAttemptSequence.toString(36)}`;
|
|
1960
|
+
gameAttemptsRef.current.ids.set(idKey, attemptId);
|
|
1961
|
+
}
|
|
1962
|
+
const rawExt = effectiveSpec.ext as Record<string, unknown> | undefined;
|
|
1963
|
+
const gameKey = typeof rawExt?.gameKey === 'string' ? rawExt.gameKey.trim() : '';
|
|
1964
|
+
const isPreview = message.preview === true || message.isTest === true;
|
|
1965
|
+
if (!isPreview && !gameKey) throw new Error('Game key is missing');
|
|
1966
|
+
const request = buildInAppGameRequest({
|
|
1967
|
+
campaignId: message.id,
|
|
1968
|
+
gameKey: gameKey || `preview:${variantKey}`,
|
|
1969
|
+
variantKey,
|
|
1970
|
+
attemptId,
|
|
1971
|
+
attempt,
|
|
1972
|
+
payload: input,
|
|
1973
|
+
allowedOutcomeIds: inAppGameAllowedOutcomeIds(effectiveSpec),
|
|
1974
|
+
});
|
|
1975
|
+
if (isPreview) {
|
|
1976
|
+
const previewResult = authoredPreviewGameResult(request, effectiveSpec);
|
|
1977
|
+
if (!previewResult) throw new Error('Preview outcome is not configured');
|
|
1978
|
+
return previewResult;
|
|
1979
|
+
}
|
|
1980
|
+
if (!onInAppGameRequest) throw new Error('Game result handler is not configured');
|
|
1981
|
+
return validateInAppGameResult(request, await onInAppGameRequest(request));
|
|
1982
|
+
}, [message, effectiveSpec, presentation?.variantKey, onInAppGameRequest]);
|
|
1983
|
+
const outcomeConfig = useMemo(
|
|
1984
|
+
() => resolveInAppOutcomeConfig(effectiveSpec),
|
|
1985
|
+
[effectiveSpec],
|
|
1986
|
+
);
|
|
1987
|
+
const [pendingOutcome, setPendingOutcome] = useState<InAppOutcomeRequest | null>(null);
|
|
1988
|
+
useEffect(() => {
|
|
1989
|
+
setPendingOutcome(null);
|
|
1990
|
+
}, [message?.id, visible]);
|
|
1991
|
+
const presentOutcome = useCallback((request: InAppOutcomeRequest): void => {
|
|
1992
|
+
setPendingOutcome((current) => current ?? request);
|
|
1993
|
+
}, []);
|
|
1994
|
+
const outcomeAwareCta = useCallback((cta: NonNullable<InAppRenderSpec['cta']>): void => {
|
|
1995
|
+
if (outcomeConfig) {
|
|
1996
|
+
presentOutcome({ fallback: inAppOutcomeTerminalForCta(cta) });
|
|
1997
|
+
return;
|
|
1998
|
+
}
|
|
1999
|
+
onCta(cta);
|
|
2000
|
+
}, [onCta, outcomeConfig, presentOutcome]);
|
|
2001
|
+
const outcomeAwareComplete = useCallback((): void => {
|
|
2002
|
+
if (outcomeConfig) {
|
|
2003
|
+
presentOutcome({ fallback: { kind: 'complete' } });
|
|
2004
|
+
return;
|
|
2005
|
+
}
|
|
2006
|
+
if (onComplete) onComplete();
|
|
2007
|
+
else onDismiss();
|
|
2008
|
+
}, [onComplete, onDismiss, outcomeConfig, presentOutcome]);
|
|
2009
|
+
const runOutcomeAction = useCallback((): void => {
|
|
2010
|
+
if (!outcomeConfig || !pendingOutcome) return;
|
|
2011
|
+
const terminal: InAppOutcomeTerminal = resolveInAppOutcomeTerminal(
|
|
2012
|
+
outcomeConfig,
|
|
2013
|
+
pendingOutcome.fallback,
|
|
2014
|
+
);
|
|
2015
|
+
setPendingOutcome(null);
|
|
2016
|
+
if (terminal.kind === 'cta') {
|
|
2017
|
+
onCta(terminal.cta);
|
|
2018
|
+
} else if (terminal.kind === 'complete') {
|
|
2019
|
+
if (onComplete) onComplete();
|
|
2020
|
+
else onDismiss();
|
|
2021
|
+
} else {
|
|
2022
|
+
onDismiss();
|
|
2023
|
+
}
|
|
2024
|
+
}, [onComplete, onCta, onDismiss, outcomeConfig, pendingOutcome]);
|
|
2025
|
+
const waitsForAnchor = presentation !== null &&
|
|
2026
|
+
effectiveMountModel === 'anchored';
|
|
2027
|
+
const [readyMessageId, setReadyMessageId] = useState<string | null>(null);
|
|
2028
|
+
// Mechanics such as wheel, quiz, and checklist can be fully authored in `ext`
|
|
2029
|
+
// without generic body copy. Reject only a truly empty render model.
|
|
2030
|
+
const contentMissing = !effectiveSpec || !(
|
|
2031
|
+
effectiveSpec.title ||
|
|
2032
|
+
effectiveSpec.body ||
|
|
2033
|
+
effectiveSpec.imageUrl ||
|
|
2034
|
+
effectiveSpec.coupon ||
|
|
2035
|
+
effectiveSpec.cta ||
|
|
2036
|
+
(effectiveSpec.assets && Object.keys(effectiveSpec.assets).length > 0) ||
|
|
2037
|
+
(effectiveSpec.ext && Object.keys(effectiveSpec.ext).length > 0)
|
|
2038
|
+
);
|
|
2039
|
+
|
|
2040
|
+
const shownIdRef = useRef<string | null>(null);
|
|
2041
|
+
useEffect(() => {
|
|
2042
|
+
if (visible && message && shownIdRef.current !== message.id) {
|
|
2043
|
+
if (contentMissing) {
|
|
2044
|
+
shownIdRef.current = message.id;
|
|
2045
|
+
onRenderError?.('missing_content');
|
|
2046
|
+
} else if (!waitsForAnchor || readyMessageId === message.id) {
|
|
2047
|
+
shownIdRef.current = message.id;
|
|
2048
|
+
onShow();
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
if (!visible) shownIdRef.current = null;
|
|
2052
|
+
}, [visible, message, onShow, onRenderError, contentMissing, waitsForAnchor, readyMessageId]);
|
|
2053
|
+
|
|
2054
|
+
if (!message || !visible || contentMissing || !effectiveSpec || !presentation) return null;
|
|
2055
|
+
|
|
2056
|
+
const mechanic = resolveInAppMechanic({
|
|
2057
|
+
variantKey: message.variantKey,
|
|
2058
|
+
spec: effectiveSpec,
|
|
2059
|
+
});
|
|
2060
|
+
const MechanicContent = resolveArchetypeContent(mechanic ?? presentation.archetype);
|
|
2061
|
+
const Content = MechanicContent ?? resolveVariantContent(presentation.variantKey ?? undefined);
|
|
2062
|
+
const Branch = resolveInAppPresentationRenderer(presentation, mountModelOverride);
|
|
2063
|
+
const theme = resolveTheme(effectiveSpec);
|
|
2064
|
+
if (__DEV__) {
|
|
2065
|
+
__DEV__ && logger.debug(
|
|
2066
|
+
`[Engage] in-app ${message.id} rendering variant="${presentation.variantKey ?? 'legacy'}" archetype="${presentation.archetype}" mount="${effectiveMountModel}" layout="${presentation.legacyLayout}" fallback="${presentation.fallback?.reason ?? 'none'}"${message.isTest ? ` (test ${message.testRunId ?? message.previewId ?? message.id})` : ''}`,
|
|
2067
|
+
);
|
|
2068
|
+
}
|
|
2069
|
+
return (
|
|
2070
|
+
<InAppErrorBoundary resetKey={message.id} onError={(reason) => onRenderError?.(reason)}>
|
|
2071
|
+
<Branch
|
|
2072
|
+
key={`${message.id}:${presentation.variantKey ?? presentation.archetype}`}
|
|
2073
|
+
spec={effectiveSpec}
|
|
2074
|
+
variantKey={presentation.variantKey ?? undefined}
|
|
2075
|
+
theme={theme}
|
|
2076
|
+
onCta={outcomeAwareCta}
|
|
2077
|
+
onDismiss={onDismiss}
|
|
2078
|
+
onComplete={outcomeAwareComplete}
|
|
2079
|
+
onOutcome={outcomeConfig ? presentOutcome : undefined}
|
|
2080
|
+
onInteraction={onInteraction}
|
|
2081
|
+
requestGameResult={requestGameResult}
|
|
2082
|
+
onReady={() => setReadyMessageId(message.id)}
|
|
2083
|
+
onRenderError={onRenderError}
|
|
2084
|
+
>
|
|
2085
|
+
{Content ? (
|
|
2086
|
+
<Content
|
|
2087
|
+
spec={effectiveSpec}
|
|
2088
|
+
variantKey={presentation.variantKey ?? undefined}
|
|
2089
|
+
theme={theme}
|
|
2090
|
+
onCta={outcomeAwareCta}
|
|
2091
|
+
onDismiss={onDismiss}
|
|
2092
|
+
onComplete={outcomeAwareComplete}
|
|
2093
|
+
onOutcome={outcomeConfig ? presentOutcome : undefined}
|
|
2094
|
+
onInteraction={onInteraction}
|
|
2095
|
+
requestGameResult={requestGameResult}
|
|
2096
|
+
/>
|
|
2097
|
+
) : undefined}
|
|
2098
|
+
</Branch>
|
|
2099
|
+
{pendingOutcome && outcomeConfig ? (
|
|
2100
|
+
<InAppOutcomeModal
|
|
2101
|
+
outcome={outcomeConfig}
|
|
2102
|
+
resultLabel={pendingOutcome.resultLabel}
|
|
2103
|
+
theme={theme}
|
|
2104
|
+
onAction={runOutcomeAction}
|
|
2105
|
+
onRequestClose={() => {
|
|
2106
|
+
setPendingOutcome(null);
|
|
2107
|
+
onDismiss();
|
|
2108
|
+
}}
|
|
2109
|
+
/>
|
|
2110
|
+
) : null}
|
|
2111
|
+
</InAppErrorBoundary>
|
|
2112
|
+
);
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
// ─── Styles ───────────────────────────────────────────────────────────────────
|
|
2116
|
+
|
|
2117
|
+
const CARD_BG = '#FFFFFF';
|
|
2118
|
+
const SHADOW: ViewStyle = {
|
|
2119
|
+
shadowColor: '#000000',
|
|
2120
|
+
shadowOpacity: 0.15,
|
|
2121
|
+
shadowRadius: 12,
|
|
2122
|
+
shadowOffset: { width: 0, height: 4 },
|
|
2123
|
+
elevation: 6,
|
|
2124
|
+
};
|
|
2125
|
+
|
|
2126
|
+
const outcomeStyles: Record<string, ViewStyle & TextStyle> = {
|
|
2127
|
+
backdrop: {
|
|
2128
|
+
flex: 1,
|
|
2129
|
+
alignItems: 'center',
|
|
2130
|
+
justifyContent: 'center',
|
|
2131
|
+
padding: 24,
|
|
2132
|
+
},
|
|
2133
|
+
card: {
|
|
2134
|
+
width: '100%',
|
|
2135
|
+
maxWidth: 340,
|
|
2136
|
+
borderWidth: 1,
|
|
2137
|
+
borderRadius: 24,
|
|
2138
|
+
padding: 24,
|
|
2139
|
+
alignItems: 'center',
|
|
2140
|
+
...SHADOW,
|
|
2141
|
+
},
|
|
2142
|
+
copy: { alignSelf: 'stretch', alignItems: 'center' },
|
|
2143
|
+
icon: {
|
|
2144
|
+
width: 64,
|
|
2145
|
+
height: 64,
|
|
2146
|
+
borderRadius: 20,
|
|
2147
|
+
alignItems: 'center',
|
|
2148
|
+
justifyContent: 'center',
|
|
2149
|
+
marginBottom: 14,
|
|
2150
|
+
},
|
|
2151
|
+
iconText: { fontSize: 30, fontWeight: '800' },
|
|
2152
|
+
title: { fontSize: 21, fontWeight: '800', textAlign: 'center' },
|
|
2153
|
+
body: { fontSize: 14, lineHeight: 20, textAlign: 'center', marginTop: 7 },
|
|
2154
|
+
result: {
|
|
2155
|
+
alignSelf: 'stretch',
|
|
2156
|
+
borderRadius: 12,
|
|
2157
|
+
padding: 10,
|
|
2158
|
+
marginTop: 12,
|
|
2159
|
+
},
|
|
2160
|
+
resultText: { fontSize: 17, fontWeight: '800', textAlign: 'center' },
|
|
2161
|
+
button: {
|
|
2162
|
+
alignSelf: 'stretch',
|
|
2163
|
+
minHeight: 44,
|
|
2164
|
+
borderRadius: 12,
|
|
2165
|
+
alignItems: 'center',
|
|
2166
|
+
justifyContent: 'center',
|
|
2167
|
+
paddingHorizontal: 16,
|
|
2168
|
+
marginTop: 18,
|
|
2169
|
+
},
|
|
2170
|
+
buttonText: { fontSize: 15, fontWeight: '800', textAlign: 'center' },
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
const styles: {
|
|
2174
|
+
// shared content
|
|
2175
|
+
contentBlock: ViewStyle;
|
|
2176
|
+
image: ImageStyle;
|
|
2177
|
+
title: TextStyle;
|
|
2178
|
+
body: TextStyle;
|
|
2179
|
+
actions: ViewStyle;
|
|
2180
|
+
primaryBtn: ViewStyle;
|
|
2181
|
+
primaryText: TextStyle;
|
|
2182
|
+
secondaryBtn: ViewStyle;
|
|
2183
|
+
secondaryText: TextStyle;
|
|
2184
|
+
coupon: ViewStyle;
|
|
2185
|
+
couponText: TextStyle;
|
|
2186
|
+
closeBtn: ViewStyle;
|
|
2187
|
+
closeBtnText: TextStyle;
|
|
2188
|
+
keyboardAvoider: ViewStyle;
|
|
2189
|
+
screenEdgeKeyboard: ViewStyle;
|
|
2190
|
+
screenEdge: ViewStyle;
|
|
2191
|
+
screenEdgeTop: ViewStyle;
|
|
2192
|
+
screenEdgeBottom: ViewStyle;
|
|
2193
|
+
// modal
|
|
2194
|
+
modalSafeArea: ViewStyle;
|
|
2195
|
+
modalBackdrop: ViewStyle;
|
|
2196
|
+
modalBackdropTop: ViewStyle;
|
|
2197
|
+
modalBackdropBottom: ViewStyle;
|
|
2198
|
+
modalCard: ViewStyle;
|
|
2199
|
+
modalScroll: ViewStyle;
|
|
2200
|
+
modalScrollContent: ViewStyle;
|
|
2201
|
+
centerDrawerCard: ViewStyle;
|
|
2202
|
+
modalClosePos: ViewStyle;
|
|
2203
|
+
// fullscreen
|
|
2204
|
+
fullscreenCard: ViewStyle;
|
|
2205
|
+
fullscreenHeader: ViewStyle;
|
|
2206
|
+
fullscreenScroll: ViewStyle;
|
|
2207
|
+
fullscreenScrollContent: ViewStyle;
|
|
2208
|
+
fullscreenImage: ImageStyle;
|
|
2209
|
+
fullscreenContent: ViewStyle;
|
|
2210
|
+
fullscreenTitle: TextStyle;
|
|
2211
|
+
fullscreenBody: TextStyle;
|
|
2212
|
+
// bottom_sheet
|
|
2213
|
+
sheetBackdrop: ViewStyle;
|
|
2214
|
+
sheetCard: ViewStyle;
|
|
2215
|
+
sheetSafeArea: ViewStyle;
|
|
2216
|
+
sheetScroll: ViewStyle;
|
|
2217
|
+
sheetContent: ViewStyle;
|
|
2218
|
+
sheetHandle: ViewStyle;
|
|
2219
|
+
stepProgress: ViewStyle;
|
|
2220
|
+
stepLabel: TextStyle;
|
|
2221
|
+
stepTrack: ViewStyle;
|
|
2222
|
+
stepFill: ViewStyle;
|
|
2223
|
+
// additive side_sheet
|
|
2224
|
+
sideSheetBackdrop: ViewStyle;
|
|
2225
|
+
sideSheetLeft: ViewStyle;
|
|
2226
|
+
sideSheetRight: ViewStyle;
|
|
2227
|
+
sideSheetPanel: ViewStyle;
|
|
2228
|
+
sideSheetPanelLeft: ViewStyle;
|
|
2229
|
+
sideSheetPanelRight: ViewStyle;
|
|
2230
|
+
sideSheetSafeArea: ViewStyle;
|
|
2231
|
+
sideSheetHeader: ViewStyle;
|
|
2232
|
+
sideSheetScroll: ViewStyle;
|
|
2233
|
+
sideSheetContent: ViewStyle;
|
|
2234
|
+
peekRoot: ViewStyle;
|
|
2235
|
+
peekExpanded: ViewStyle;
|
|
2236
|
+
peekCollapsed: ViewStyle;
|
|
2237
|
+
peekSafeArea: ViewStyle;
|
|
2238
|
+
peekScroll: ViewStyle;
|
|
2239
|
+
peekExpandedContent: ViewStyle;
|
|
2240
|
+
peekCollapsedContent: ViewStyle;
|
|
2241
|
+
peekClose: ViewStyle;
|
|
2242
|
+
peekLabel: TextStyle;
|
|
2243
|
+
// banners
|
|
2244
|
+
bannerWrap: ViewStyle;
|
|
2245
|
+
bannerCard: ViewStyle;
|
|
2246
|
+
bannerContent: ViewStyle;
|
|
2247
|
+
bannerClosePos: ViewStyle;
|
|
2248
|
+
stickyLabel: TextStyle;
|
|
2249
|
+
stickyTrack: ViewStyle;
|
|
2250
|
+
stickyFill: ViewStyle;
|
|
2251
|
+
// tooltip
|
|
2252
|
+
floatingEdge: ViewStyle;
|
|
2253
|
+
edgeAlignLeft: ViewStyle;
|
|
2254
|
+
edgeAlignRight: ViewStyle;
|
|
2255
|
+
floatingBubble: ViewStyle;
|
|
2256
|
+
floatingBubbleText: TextStyle;
|
|
2257
|
+
floatingPanel: ViewStyle;
|
|
2258
|
+
floatingScroll: ViewStyle;
|
|
2259
|
+
miniPopoverPanel: ViewStyle;
|
|
2260
|
+
tooltipCard: ViewStyle;
|
|
2261
|
+
tooltipClosePos: ViewStyle;
|
|
2262
|
+
tooltipTitle: TextStyle;
|
|
2263
|
+
tooltipBody: TextStyle;
|
|
2264
|
+
tooltipCta: ViewStyle;
|
|
2265
|
+
tooltipCtaText: TextStyle;
|
|
2266
|
+
anchoredTooltipRoot: ViewStyle;
|
|
2267
|
+
coachmarkRoot: ViewStyle;
|
|
2268
|
+
coachmarkSpotlight: ViewStyle;
|
|
2269
|
+
coachmarkTooltipWrap: ViewStyle;
|
|
2270
|
+
coachmarkArrow: ViewStyle;
|
|
2271
|
+
coachmarkArrowTop: ViewStyle;
|
|
2272
|
+
coachmarkArrowBottom: ViewStyle;
|
|
2273
|
+
coachmarkArrowLeft: ViewStyle;
|
|
2274
|
+
coachmarkArrowRight: ViewStyle;
|
|
2275
|
+
coachmarkCard: ViewStyle;
|
|
2276
|
+
coachmarkScroll: ViewStyle;
|
|
2277
|
+
coachmarkEyebrow: TextStyle;
|
|
2278
|
+
coachmarkActions: ViewStyle;
|
|
2279
|
+
coachmarkNavActions: ViewStyle;
|
|
2280
|
+
coachmarkTextButton: ViewStyle;
|
|
2281
|
+
coachmarkSecondaryText: TextStyle;
|
|
2282
|
+
coachmarkPrimaryButton: ViewStyle;
|
|
2283
|
+
coachmarkPrimaryText: TextStyle;
|
|
2284
|
+
// inline
|
|
2285
|
+
inlineCard: ViewStyle;
|
|
2286
|
+
inlineClosePos: ViewStyle;
|
|
2287
|
+
// toast
|
|
2288
|
+
toastWrap: ViewStyle;
|
|
2289
|
+
toastCard: ViewStyle;
|
|
2290
|
+
toastScroll: ViewStyle;
|
|
2291
|
+
toastTitle: TextStyle;
|
|
2292
|
+
toastBody: TextStyle;
|
|
2293
|
+
toastCtaText: TextStyle;
|
|
2294
|
+
} = {
|
|
2295
|
+
// ── shared content ──
|
|
2296
|
+
contentBlock: { marginBottom: 12 },
|
|
2297
|
+
image: { width: '100%', height: 140, borderRadius: 12, marginBottom: 12 },
|
|
2298
|
+
title: { fontSize: 17, fontWeight: '700', color: '#11151C', marginBottom: 6 },
|
|
2299
|
+
body: { fontSize: 14, color: '#3A4250', lineHeight: 20 },
|
|
2300
|
+
actions: {
|
|
2301
|
+
flexDirection: 'row',
|
|
2302
|
+
flexWrap: 'wrap',
|
|
2303
|
+
justifyContent: 'flex-end',
|
|
2304
|
+
alignItems: 'center',
|
|
2305
|
+
gap: 8,
|
|
2306
|
+
},
|
|
2307
|
+
primaryBtn: {
|
|
2308
|
+
flexGrow: 1,
|
|
2309
|
+
flexShrink: 1,
|
|
2310
|
+
minWidth: 120,
|
|
2311
|
+
maxWidth: '100%',
|
|
2312
|
+
paddingVertical: 10,
|
|
2313
|
+
paddingHorizontal: 20,
|
|
2314
|
+
borderRadius: 10,
|
|
2315
|
+
backgroundColor: '#2F6BFF',
|
|
2316
|
+
},
|
|
2317
|
+
primaryText: { fontSize: 15, color: '#FFFFFF', fontWeight: '600', textAlign: 'center', flexShrink: 1 },
|
|
2318
|
+
secondaryBtn: { maxWidth: '100%', flexShrink: 1, paddingVertical: 10, paddingHorizontal: 16 },
|
|
2319
|
+
secondaryText: { fontSize: 15, color: '#6B7280', fontWeight: '500', textAlign: 'center', flexShrink: 1 },
|
|
2320
|
+
coupon: {
|
|
2321
|
+
marginTop: 10,
|
|
2322
|
+
borderWidth: 1.5,
|
|
2323
|
+
borderStyle: 'dashed',
|
|
2324
|
+
borderRadius: 8,
|
|
2325
|
+
paddingVertical: 8,
|
|
2326
|
+
paddingHorizontal: 10,
|
|
2327
|
+
alignItems: 'center',
|
|
2328
|
+
},
|
|
2329
|
+
couponText: { fontSize: 14, fontWeight: '700', letterSpacing: 1.2 },
|
|
2330
|
+
closeBtn: {
|
|
2331
|
+
width: 32,
|
|
2332
|
+
height: 32,
|
|
2333
|
+
padding: 0,
|
|
2334
|
+
alignItems: 'center',
|
|
2335
|
+
justifyContent: 'center',
|
|
2336
|
+
},
|
|
2337
|
+
closeBtnText: {
|
|
2338
|
+
fontSize: 18,
|
|
2339
|
+
color: '#9097A3',
|
|
2340
|
+
fontWeight: '600',
|
|
2341
|
+
lineHeight: 20,
|
|
2342
|
+
textAlign: 'center',
|
|
2343
|
+
includeFontPadding: false,
|
|
2344
|
+
transform: [{ translateY: -1 }],
|
|
2345
|
+
},
|
|
2346
|
+
keyboardAvoider: { flex: 1 },
|
|
2347
|
+
screenEdgeKeyboard: { width: '100%' },
|
|
2348
|
+
screenEdge: {
|
|
2349
|
+
position: 'absolute',
|
|
2350
|
+
top: 0,
|
|
2351
|
+
bottom: 0,
|
|
2352
|
+
left: 0,
|
|
2353
|
+
right: 0,
|
|
2354
|
+
zIndex: 1000,
|
|
2355
|
+
},
|
|
2356
|
+
screenEdgeTop: { justifyContent: 'flex-start' },
|
|
2357
|
+
screenEdgeBottom: { justifyContent: 'flex-end' },
|
|
2358
|
+
|
|
2359
|
+
// ── modal ──
|
|
2360
|
+
modalSafeArea: { flex: 1 },
|
|
2361
|
+
modalBackdrop: {
|
|
2362
|
+
flex: 1,
|
|
2363
|
+
backgroundColor: 'rgba(0,0,0,0.52)',
|
|
2364
|
+
justifyContent: 'center',
|
|
2365
|
+
alignItems: 'center',
|
|
2366
|
+
padding: 20,
|
|
2367
|
+
},
|
|
2368
|
+
modalBackdropTop: { justifyContent: 'flex-start' },
|
|
2369
|
+
modalBackdropBottom: { justifyContent: 'flex-end' },
|
|
2370
|
+
modalCard: {
|
|
2371
|
+
width: '100%',
|
|
2372
|
+
maxWidth: 420,
|
|
2373
|
+
maxHeight: '100%',
|
|
2374
|
+
backgroundColor: CARD_BG,
|
|
2375
|
+
borderRadius: 18,
|
|
2376
|
+
padding: 22,
|
|
2377
|
+
...SHADOW,
|
|
2378
|
+
},
|
|
2379
|
+
modalScroll: { flexShrink: 1 },
|
|
2380
|
+
modalScrollContent: {},
|
|
2381
|
+
centerDrawerCard: { maxHeight: '78%' },
|
|
2382
|
+
modalClosePos: { position: 'absolute', top: 12, right: 12, zIndex: 1 },
|
|
2383
|
+
|
|
2384
|
+
// ── fullscreen ──
|
|
2385
|
+
fullscreenCard: {
|
|
2386
|
+
flex: 1,
|
|
2387
|
+
backgroundColor: CARD_BG,
|
|
2388
|
+
},
|
|
2389
|
+
fullscreenHeader: {
|
|
2390
|
+
minHeight: 44,
|
|
2391
|
+
paddingHorizontal: 16,
|
|
2392
|
+
alignItems: 'flex-end',
|
|
2393
|
+
justifyContent: 'center',
|
|
2394
|
+
},
|
|
2395
|
+
fullscreenScroll: { flex: 1 },
|
|
2396
|
+
fullscreenScrollContent: { flexGrow: 1 },
|
|
2397
|
+
fullscreenImage: { width: '100%', maxWidth: 600, alignSelf: 'center', aspectRatio: 16 / 9, maxHeight: 320 },
|
|
2398
|
+
fullscreenContent: {
|
|
2399
|
+
flexGrow: 1,
|
|
2400
|
+
width: '100%',
|
|
2401
|
+
maxWidth: 600,
|
|
2402
|
+
alignSelf: 'center',
|
|
2403
|
+
paddingHorizontal: 24,
|
|
2404
|
+
paddingTop: 8,
|
|
2405
|
+
paddingBottom: 24,
|
|
2406
|
+
},
|
|
2407
|
+
fullscreenTitle: {
|
|
2408
|
+
fontSize: 22,
|
|
2409
|
+
fontWeight: '800',
|
|
2410
|
+
color: '#11151C',
|
|
2411
|
+
marginBottom: 10,
|
|
2412
|
+
},
|
|
2413
|
+
fullscreenBody: {
|
|
2414
|
+
fontSize: 15,
|
|
2415
|
+
color: '#3A4250',
|
|
2416
|
+
lineHeight: 22,
|
|
2417
|
+
marginBottom: 24,
|
|
2418
|
+
},
|
|
2419
|
+
|
|
2420
|
+
// ── bottom_sheet ──
|
|
2421
|
+
sheetBackdrop: {
|
|
2422
|
+
flex: 1,
|
|
2423
|
+
backgroundColor: 'rgba(0,0,0,0.48)',
|
|
2424
|
+
justifyContent: 'flex-end',
|
|
2425
|
+
alignItems: 'center',
|
|
2426
|
+
},
|
|
2427
|
+
sheetCard: {
|
|
2428
|
+
width: '100%',
|
|
2429
|
+
maxWidth: 600,
|
|
2430
|
+
maxHeight: '92%',
|
|
2431
|
+
backgroundColor: CARD_BG,
|
|
2432
|
+
borderTopLeftRadius: 22,
|
|
2433
|
+
borderTopRightRadius: 22,
|
|
2434
|
+
overflow: 'hidden',
|
|
2435
|
+
...SHADOW,
|
|
2436
|
+
},
|
|
2437
|
+
sheetSafeArea: { width: '100%' },
|
|
2438
|
+
sheetScroll: { flexShrink: 1 },
|
|
2439
|
+
sheetContent: { padding: 22, paddingBottom: 20 },
|
|
2440
|
+
sheetHandle: {
|
|
2441
|
+
width: 38,
|
|
2442
|
+
height: 4,
|
|
2443
|
+
borderRadius: 2,
|
|
2444
|
+
backgroundColor: '#D1D5DB',
|
|
2445
|
+
alignSelf: 'center',
|
|
2446
|
+
marginBottom: 16,
|
|
2447
|
+
},
|
|
2448
|
+
stepProgress: { marginBottom: 16 },
|
|
2449
|
+
stepLabel: { fontSize: 12, fontWeight: '600', marginBottom: 7 },
|
|
2450
|
+
stepTrack: {
|
|
2451
|
+
height: 4,
|
|
2452
|
+
borderRadius: 2,
|
|
2453
|
+
backgroundColor: '#E5E7EB',
|
|
2454
|
+
overflow: 'hidden',
|
|
2455
|
+
},
|
|
2456
|
+
stepFill: { height: '100%', borderRadius: 2 },
|
|
2457
|
+
|
|
2458
|
+
// ── additive side_sheet ──
|
|
2459
|
+
sideSheetBackdrop: { flex: 1, flexDirection: 'row' },
|
|
2460
|
+
sideSheetLeft: { justifyContent: 'flex-start' },
|
|
2461
|
+
sideSheetRight: { justifyContent: 'flex-end' },
|
|
2462
|
+
sideSheetPanel: {
|
|
2463
|
+
width: '82%',
|
|
2464
|
+
maxWidth: 420,
|
|
2465
|
+
height: '100%',
|
|
2466
|
+
...SHADOW,
|
|
2467
|
+
},
|
|
2468
|
+
sideSheetPanelLeft: { borderTopRightRadius: 22, borderBottomRightRadius: 22 },
|
|
2469
|
+
sideSheetPanelRight: { borderTopLeftRadius: 22, borderBottomLeftRadius: 22 },
|
|
2470
|
+
sideSheetSafeArea: { flex: 1 },
|
|
2471
|
+
sideSheetHeader: {
|
|
2472
|
+
minHeight: 44,
|
|
2473
|
+
paddingHorizontal: 14,
|
|
2474
|
+
alignItems: 'flex-end',
|
|
2475
|
+
justifyContent: 'center',
|
|
2476
|
+
},
|
|
2477
|
+
sideSheetScroll: { flex: 1 },
|
|
2478
|
+
sideSheetContent: { flexGrow: 1, paddingHorizontal: 22, paddingTop: 8, paddingBottom: 24 },
|
|
2479
|
+
peekRoot: { flex: 1, justifyContent: 'flex-end', alignItems: 'center', paddingHorizontal: 14 },
|
|
2480
|
+
peekExpanded: {
|
|
2481
|
+
width: '100%',
|
|
2482
|
+
maxWidth: 600,
|
|
2483
|
+
maxHeight: '92%',
|
|
2484
|
+
borderTopLeftRadius: 22,
|
|
2485
|
+
borderTopRightRadius: 22,
|
|
2486
|
+
overflow: 'hidden',
|
|
2487
|
+
...SHADOW,
|
|
2488
|
+
},
|
|
2489
|
+
peekCollapsed: {
|
|
2490
|
+
width: '100%',
|
|
2491
|
+
maxWidth: 600,
|
|
2492
|
+
minHeight: 72,
|
|
2493
|
+
borderTopLeftRadius: 18,
|
|
2494
|
+
borderTopRightRadius: 18,
|
|
2495
|
+
borderWidth: 1,
|
|
2496
|
+
borderBottomWidth: 0,
|
|
2497
|
+
overflow: 'hidden',
|
|
2498
|
+
...SHADOW,
|
|
2499
|
+
},
|
|
2500
|
+
peekSafeArea: { width: '100%' },
|
|
2501
|
+
peekScroll: { flexShrink: 1 },
|
|
2502
|
+
peekExpandedContent: { padding: 22, paddingBottom: 20 },
|
|
2503
|
+
peekCollapsedContent: { padding: 14 },
|
|
2504
|
+
peekClose: { position: 'absolute', top: 10, right: 12 },
|
|
2505
|
+
peekLabel: { fontSize: 15, fontWeight: '800', textAlign: 'center' },
|
|
2506
|
+
|
|
2507
|
+
// ── banners (shared card shape) ──
|
|
2508
|
+
bannerWrap: {
|
|
2509
|
+
padding: 12,
|
|
2510
|
+
alignItems: 'center',
|
|
2511
|
+
},
|
|
2512
|
+
bannerCard: {
|
|
2513
|
+
width: '100%',
|
|
2514
|
+
maxWidth: 420,
|
|
2515
|
+
backgroundColor: CARD_BG,
|
|
2516
|
+
borderRadius: 14,
|
|
2517
|
+
padding: 14,
|
|
2518
|
+
flexDirection: 'row',
|
|
2519
|
+
alignItems: 'flex-start',
|
|
2520
|
+
...SHADOW,
|
|
2521
|
+
},
|
|
2522
|
+
bannerContent: { flex: 1, paddingRight: 8 },
|
|
2523
|
+
bannerClosePos: { alignSelf: 'flex-start', marginTop: -2 },
|
|
2524
|
+
stickyLabel: { fontSize: 9, fontWeight: '900', letterSpacing: 1, marginBottom: 3 },
|
|
2525
|
+
stickyTrack: { height: 4, borderRadius: 2, backgroundColor: '#E5E7EB', overflow: 'hidden', marginTop: 7 },
|
|
2526
|
+
stickyFill: { height: '100%', borderRadius: 2 },
|
|
2527
|
+
|
|
2528
|
+
// ── tooltip ──
|
|
2529
|
+
floatingEdge: { padding: 16 },
|
|
2530
|
+
edgeAlignLeft: { alignItems: 'flex-start' },
|
|
2531
|
+
edgeAlignRight: { alignItems: 'flex-end' },
|
|
2532
|
+
floatingBubble: {
|
|
2533
|
+
minWidth: 62,
|
|
2534
|
+
minHeight: 62,
|
|
2535
|
+
borderRadius: 31,
|
|
2536
|
+
alignItems: 'center',
|
|
2537
|
+
justifyContent: 'center',
|
|
2538
|
+
paddingHorizontal: 14,
|
|
2539
|
+
...SHADOW,
|
|
2540
|
+
},
|
|
2541
|
+
floatingBubbleText: { fontSize: 12, fontWeight: '800', textAlign: 'center' },
|
|
2542
|
+
floatingPanel: { width: '100%', maxWidth: 260, overflow: 'hidden', borderRadius: 12 },
|
|
2543
|
+
floatingScroll: { flexShrink: 1 },
|
|
2544
|
+
miniPopoverPanel: { width: '100%', maxWidth: 240, overflow: 'hidden', borderRadius: 12 },
|
|
2545
|
+
tooltipCard: {
|
|
2546
|
+
width: '100%',
|
|
2547
|
+
maxHeight: '100%',
|
|
2548
|
+
backgroundColor: CARD_BG,
|
|
2549
|
+
borderRadius: 12,
|
|
2550
|
+
padding: 14,
|
|
2551
|
+
...SHADOW,
|
|
2552
|
+
},
|
|
2553
|
+
tooltipClosePos: { position: 'absolute', top: 4, right: 4 },
|
|
2554
|
+
tooltipTitle: {
|
|
2555
|
+
fontSize: 13,
|
|
2556
|
+
fontWeight: '700',
|
|
2557
|
+
color: '#11151C',
|
|
2558
|
+
marginBottom: 4,
|
|
2559
|
+
paddingRight: 20,
|
|
2560
|
+
},
|
|
2561
|
+
tooltipBody: { fontSize: 12, color: '#3A4250', lineHeight: 17 },
|
|
2562
|
+
tooltipCta: { marginTop: 8 },
|
|
2563
|
+
tooltipCtaText: { fontSize: 12, color: '#2F6BFF', fontWeight: '600' },
|
|
2564
|
+
anchoredTooltipRoot: {
|
|
2565
|
+
position: 'absolute',
|
|
2566
|
+
top: 0,
|
|
2567
|
+
right: 0,
|
|
2568
|
+
bottom: 0,
|
|
2569
|
+
left: 0,
|
|
2570
|
+
zIndex: 9999,
|
|
2571
|
+
elevation: 9999,
|
|
2572
|
+
},
|
|
2573
|
+
coachmarkRoot: { flex: 1 },
|
|
2574
|
+
coachmarkSpotlight: {
|
|
2575
|
+
borderWidth: 2,
|
|
2576
|
+
shadowColor: '#FFFFFF',
|
|
2577
|
+
shadowOpacity: 0.45,
|
|
2578
|
+
shadowRadius: 8,
|
|
2579
|
+
elevation: 2,
|
|
2580
|
+
},
|
|
2581
|
+
coachmarkTooltipWrap: { position: 'absolute', zIndex: 2 },
|
|
2582
|
+
coachmarkArrow: {
|
|
2583
|
+
position: 'absolute',
|
|
2584
|
+
width: 14,
|
|
2585
|
+
height: 14,
|
|
2586
|
+
transform: [{ rotate: '45deg' }],
|
|
2587
|
+
zIndex: 0,
|
|
2588
|
+
},
|
|
2589
|
+
coachmarkArrowTop: { top: -6 },
|
|
2590
|
+
coachmarkArrowBottom: { bottom: -6 },
|
|
2591
|
+
coachmarkArrowLeft: { left: -6 },
|
|
2592
|
+
coachmarkArrowRight: { right: -6 },
|
|
2593
|
+
coachmarkCard: {
|
|
2594
|
+
borderRadius: 14,
|
|
2595
|
+
padding: 16,
|
|
2596
|
+
overflow: 'hidden',
|
|
2597
|
+
zIndex: 1,
|
|
2598
|
+
...SHADOW,
|
|
2599
|
+
},
|
|
2600
|
+
coachmarkScroll: { flexShrink: 1 },
|
|
2601
|
+
coachmarkEyebrow: {
|
|
2602
|
+
fontSize: 10,
|
|
2603
|
+
fontWeight: '800',
|
|
2604
|
+
letterSpacing: 0.8,
|
|
2605
|
+
marginBottom: 5,
|
|
2606
|
+
},
|
|
2607
|
+
coachmarkActions: {
|
|
2608
|
+
alignItems: 'center',
|
|
2609
|
+
flexDirection: 'row',
|
|
2610
|
+
flexWrap: 'wrap',
|
|
2611
|
+
justifyContent: 'space-between',
|
|
2612
|
+
gap: 8,
|
|
2613
|
+
marginTop: 14,
|
|
2614
|
+
},
|
|
2615
|
+
coachmarkNavActions: {
|
|
2616
|
+
alignItems: 'center',
|
|
2617
|
+
flexDirection: 'row',
|
|
2618
|
+
flexWrap: 'wrap',
|
|
2619
|
+
justifyContent: 'flex-end',
|
|
2620
|
+
gap: 6,
|
|
2621
|
+
},
|
|
2622
|
+
coachmarkTextButton: {
|
|
2623
|
+
minHeight: 44,
|
|
2624
|
+
minWidth: 44,
|
|
2625
|
+
alignItems: 'center',
|
|
2626
|
+
justifyContent: 'center',
|
|
2627
|
+
paddingHorizontal: 8,
|
|
2628
|
+
},
|
|
2629
|
+
coachmarkSecondaryText: { fontSize: 13, fontWeight: '700' },
|
|
2630
|
+
coachmarkPrimaryButton: {
|
|
2631
|
+
minHeight: 44,
|
|
2632
|
+
minWidth: 72,
|
|
2633
|
+
alignItems: 'center',
|
|
2634
|
+
justifyContent: 'center',
|
|
2635
|
+
borderRadius: 10,
|
|
2636
|
+
paddingHorizontal: 14,
|
|
2637
|
+
},
|
|
2638
|
+
coachmarkPrimaryText: { fontSize: 13, fontWeight: '800' },
|
|
2639
|
+
|
|
2640
|
+
// ── inline ──
|
|
2641
|
+
inlineCard: {
|
|
2642
|
+
width: '100%',
|
|
2643
|
+
borderRadius: 14,
|
|
2644
|
+
padding: 16,
|
|
2645
|
+
...SHADOW,
|
|
2646
|
+
},
|
|
2647
|
+
inlineClosePos: { position: 'absolute', top: 6, right: 6, zIndex: 1 },
|
|
2648
|
+
|
|
2649
|
+
// ── toast ──
|
|
2650
|
+
toastWrap: {
|
|
2651
|
+
paddingHorizontal: 16,
|
|
2652
|
+
paddingVertical: 12,
|
|
2653
|
+
alignItems: 'center',
|
|
2654
|
+
},
|
|
2655
|
+
toastCard: {
|
|
2656
|
+
width: '100%',
|
|
2657
|
+
maxWidth: 420,
|
|
2658
|
+
backgroundColor: '#1C1C1E',
|
|
2659
|
+
borderRadius: 12,
|
|
2660
|
+
paddingVertical: 12,
|
|
2661
|
+
paddingHorizontal: 16,
|
|
2662
|
+
...SHADOW,
|
|
2663
|
+
},
|
|
2664
|
+
toastScroll: { flexShrink: 1 },
|
|
2665
|
+
toastTitle: {
|
|
2666
|
+
fontSize: 13,
|
|
2667
|
+
fontWeight: '700',
|
|
2668
|
+
color: '#FFFFFF',
|
|
2669
|
+
marginBottom: 2,
|
|
2670
|
+
},
|
|
2671
|
+
toastBody: { fontSize: 13, color: 'rgba(255,255,255,0.8)' },
|
|
2672
|
+
toastCtaText: {
|
|
2673
|
+
fontSize: 13,
|
|
2674
|
+
color: '#60A5FA',
|
|
2675
|
+
fontWeight: '600',
|
|
2676
|
+
marginTop: 6,
|
|
2677
|
+
},
|
|
2678
|
+
};
|