@billdog.io/react-native 1.0.0-beta.2
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/BillDogReactNative.podspec +30 -0
- package/LICENSE +21 -0
- package/README.md +330 -0
- package/android/build.gradle +99 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogABTestModule.kt +317 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogAnalyticsModule.kt +389 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogModule.kt +817 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogPaywallViewManager.kt +383 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogSurveyModule.kt +427 -0
- package/android/src/main/kotlin/io/billdog/reactnative/BillDogVirtualCurrencyModule.kt +407 -0
- package/android/src/main/kotlin/io/billdog/virtualcurrency/BillDogVirtualCurrencyPackage.kt +44 -0
- package/dist/AdvancedPaywallCache.d.ts +70 -0
- package/dist/AdvancedPaywallCache.js +344 -0
- package/dist/BillDog.d.ts +255 -0
- package/dist/BillDog.js +918 -0
- package/dist/BillDogConfiguration.d.ts +145 -0
- package/dist/BillDogConfiguration.js +229 -0
- package/dist/ComponentRenderer.d.ts +17 -0
- package/dist/ComponentRenderer.js +886 -0
- package/dist/LayoutEngine.d.ts +101 -0
- package/dist/LayoutEngine.js +394 -0
- package/dist/LocalizationResolver.d.ts +99 -0
- package/dist/LocalizationResolver.js +266 -0
- package/dist/NativePaywallView.d.ts +36 -0
- package/dist/NativePaywallView.js +59 -0
- package/dist/PaywallCache.d.ts +74 -0
- package/dist/PaywallCache.js +293 -0
- package/dist/PaywallStateManager.d.ts +62 -0
- package/dist/PaywallStateManager.js +147 -0
- package/dist/PaywallView.d.ts +42 -0
- package/dist/PaywallView.js +275 -0
- package/dist/ProductVariableProvider.d.ts +60 -0
- package/dist/ProductVariableProvider.js +239 -0
- package/dist/VariableResolver.d.ts +120 -0
- package/dist/VariableResolver.js +379 -0
- package/dist/WebViewPaywall.d.ts +75 -0
- package/dist/WebViewPaywall.js +360 -0
- package/dist/animations/presets.d.ts +49 -0
- package/dist/animations/presets.js +367 -0
- package/dist/components/AccoladeCpsComponent.d.ts +13 -0
- package/dist/components/AccoladeCpsComponent.js +248 -0
- package/dist/components/AccordionComponent.d.ts +10 -0
- package/dist/components/AccordionComponent.js +187 -0
- package/dist/components/AnimatedWrapper.d.ts +35 -0
- package/dist/components/AnimatedWrapper.js +277 -0
- package/dist/components/CarouselComponent.d.ts +23 -0
- package/dist/components/CarouselComponent.js +484 -0
- package/dist/components/ChartCurveComponent.d.ts +13 -0
- package/dist/components/ChartCurveComponent.js +333 -0
- package/dist/components/CheckboxComponent.d.ts +9 -0
- package/dist/components/CheckboxComponent.js +172 -0
- package/dist/components/ConfettiComponent.d.ts +9 -0
- package/dist/components/ConfettiComponent.js +172 -0
- package/dist/components/CountdownComponent.d.ts +16 -0
- package/dist/components/CountdownComponent.js +414 -0
- package/dist/components/DelayedXComponent.d.ts +12 -0
- package/dist/components/DelayedXComponent.js +240 -0
- package/dist/components/DrawerModalComponent.d.ts +20 -0
- package/dist/components/DrawerModalComponent.js +286 -0
- package/dist/components/GradientView.d.ts +38 -0
- package/dist/components/GradientView.js +126 -0
- package/dist/components/HapticFeedbackComponent.d.ts +16 -0
- package/dist/components/HapticFeedbackComponent.js +64 -0
- package/dist/components/HorizontalProductsComponent.d.ts +17 -0
- package/dist/components/HorizontalProductsComponent.js +284 -0
- package/dist/components/MultiChoiceGridComponent.d.ts +13 -0
- package/dist/components/MultiChoiceGridComponent.js +234 -0
- package/dist/components/NPSScaleComponent.d.ts +16 -0
- package/dist/components/NPSScaleComponent.js +260 -0
- package/dist/components/NavigationComponent.d.ts +26 -0
- package/dist/components/NavigationComponent.js +302 -0
- package/dist/components/OAuthButtonComponent.d.ts +20 -0
- package/dist/components/OAuthButtonComponent.js +237 -0
- package/dist/components/ProgressLoaderComponent.d.ts +13 -0
- package/dist/components/ProgressLoaderComponent.js +308 -0
- package/dist/components/ProgressStepperComponent.d.ts +18 -0
- package/dist/components/ProgressStepperComponent.js +228 -0
- package/dist/components/SegmentedPickerComponent.d.ts +10 -0
- package/dist/components/SegmentedPickerComponent.js +221 -0
- package/dist/components/ShareButtonsComponent.d.ts +21 -0
- package/dist/components/ShareButtonsComponent.js +265 -0
- package/dist/components/ShareCodeComponent.d.ts +16 -0
- package/dist/components/ShareCodeComponent.js +274 -0
- package/dist/components/SingleChoiceGridComponent.d.ts +13 -0
- package/dist/components/SingleChoiceGridComponent.js +210 -0
- package/dist/components/SliderComponent.d.ts +9 -0
- package/dist/components/SliderComponent.js +263 -0
- package/dist/components/StarRatingInputComponent.d.ts +20 -0
- package/dist/components/StarRatingInputComponent.js +198 -0
- package/dist/components/StickerCompositeComponent.d.ts +13 -0
- package/dist/components/StickerCompositeComponent.js +136 -0
- package/dist/components/TabsComponent.d.ts +19 -0
- package/dist/components/TabsComponent.js +431 -0
- package/dist/components/TextInputComponent.d.ts +18 -0
- package/dist/components/TextInputComponent.js +227 -0
- package/dist/components/TimelineComponent.d.ts +19 -0
- package/dist/components/TimelineComponent.js +104 -0
- package/dist/components/ToggleComponent.d.ts +14 -0
- package/dist/components/ToggleComponent.js +132 -0
- package/dist/components/VerticalProductsComponent.d.ts +17 -0
- package/dist/components/VerticalProductsComponent.js +311 -0
- package/dist/dynamicValues.d.ts +36 -0
- package/dist/dynamicValues.js +142 -0
- package/dist/filters/dateFilters.d.ts +50 -0
- package/dist/filters/dateFilters.js +390 -0
- package/dist/filters/index.d.ts +18 -0
- package/dist/filters/index.js +253 -0
- package/dist/hooks/useOfferings.d.ts +76 -0
- package/dist/hooks/useOfferings.js +99 -0
- package/dist/hooks/usePaywall.d.ts +27 -0
- package/dist/hooks/usePaywall.js +114 -0
- package/dist/hooks/usePlacement.d.ts +34 -0
- package/dist/hooks/usePlacement.js +89 -0
- package/dist/hooks/useSubscription.d.ts +40 -0
- package/dist/hooks/useSubscription.js +97 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +198 -0
- package/dist/models/BillDogError.d.ts +40 -0
- package/dist/models/BillDogError.js +11 -0
- package/dist/models/CacheFetchPolicy.d.ts +8 -0
- package/dist/models/CacheFetchPolicy.js +4 -0
- package/dist/models/CustomProduct.d.ts +32 -0
- package/dist/models/CustomProduct.js +15 -0
- package/dist/models/CustomerInfo.d.ts +17 -0
- package/dist/models/CustomerInfo.js +11 -0
- package/dist/models/Delegate.d.ts +20 -0
- package/dist/models/Delegate.js +11 -0
- package/dist/models/EntitlementInfo.d.ts +19 -0
- package/dist/models/EntitlementInfo.js +2 -0
- package/dist/models/Placement.d.ts +54 -0
- package/dist/models/Placement.js +15 -0
- package/dist/models/PurchaseParams.d.ts +39 -0
- package/dist/models/PurchaseParams.js +60 -0
- package/dist/models/PurchaseResult.d.ts +30 -0
- package/dist/models/PurchaseResult.js +15 -0
- package/dist/models/RestoreResult.d.ts +30 -0
- package/dist/models/RestoreResult.js +22 -0
- package/dist/models/RestoredItem.d.ts +26 -0
- package/dist/models/RestoredItem.js +13 -0
- package/dist/modules/ABTest.d.ts +65 -0
- package/dist/modules/ABTest.js +113 -0
- package/dist/modules/Analytics.d.ts +91 -0
- package/dist/modules/Analytics.js +182 -0
- package/dist/modules/Survey.d.ts +65 -0
- package/dist/modules/Survey.js +82 -0
- package/dist/modules/VirtualCurrency.d.ts +63 -0
- package/dist/modules/VirtualCurrency.js +147 -0
- package/dist/murmur.d.ts +23 -0
- package/dist/murmur.js +104 -0
- package/dist/notifications/LiveActivitiesManager.d.ts +47 -0
- package/dist/notifications/LiveActivitiesManager.js +106 -0
- package/dist/notifications/NotificationScheduler.d.ts +55 -0
- package/dist/notifications/NotificationScheduler.js +199 -0
- package/dist/notifications/PurchaseNotificationHandler.d.ts +24 -0
- package/dist/notifications/PurchaseNotificationHandler.js +55 -0
- package/dist/notifications/useDeviceToken.d.ts +36 -0
- package/dist/notifications/useDeviceToken.js +97 -0
- package/dist/notifications/useLiveActivity.d.ts +39 -0
- package/dist/notifications/useLiveActivity.js +104 -0
- package/dist/review/ReviewAnalytics.d.ts +34 -0
- package/dist/review/ReviewAnalytics.js +73 -0
- package/dist/review/ReviewManager.d.ts +83 -0
- package/dist/review/ReviewManager.js +339 -0
- package/dist/review/ReviewTimingManager.d.ts +82 -0
- package/dist/review/ReviewTimingManager.js +224 -0
- package/dist/survey-core/types.d.ts +215 -0
- package/dist/survey-core/types.js +8 -0
- package/dist/types.d.ts +438 -0
- package/dist/types.js +158 -0
- package/dist/utils/ApiClient.d.ts +65 -0
- package/dist/utils/ApiClient.js +132 -0
- package/dist/utils/CSSConverter.d.ts +49 -0
- package/dist/utils/CSSConverter.js +470 -0
- package/dist/utils/animations.d.ts +41 -0
- package/dist/utils/animations.js +194 -0
- package/dist/utils/calendarIntegration.d.ts +36 -0
- package/dist/utils/calendarIntegration.js +89 -0
- package/dist/utils/configurationResolver.d.ts +23 -0
- package/dist/utils/configurationResolver.js +78 -0
- package/dist/utils/deviceDetection.d.ts +38 -0
- package/dist/utils/deviceDetection.js +59 -0
- package/dist/utils/hapticFeedback.d.ts +17 -0
- package/dist/utils/hapticFeedback.js +53 -0
- package/dist/utils/iconMapper.d.ts +26 -0
- package/dist/utils/iconMapper.js +113 -0
- package/dist/utils/notificationPermissions.d.ts +13 -0
- package/dist/utils/notificationPermissions.js +51 -0
- package/dist/utils/priceFormatting.d.ts +19 -0
- package/dist/utils/priceFormatting.js +99 -0
- package/dist/utils/shareSheet.d.ts +17 -0
- package/dist/utils/shareSheet.js +42 -0
- package/dist/utils/subscriptionUpgrade.d.ts +84 -0
- package/dist/utils/subscriptionUpgrade.js +100 -0
- package/dist/valueUtils.d.ts +48 -0
- package/dist/valueUtils.js +129 -0
- package/dist/xFlowTags.d.ts +18 -0
- package/dist/xFlowTags.js +385 -0
- package/ios/BillDogABTest.m +50 -0
- package/ios/BillDogABTest.swift +188 -0
- package/ios/BillDogAnalytics.m +105 -0
- package/ios/BillDogAnalytics.swift +324 -0
- package/ios/BillDogBridge.m +222 -0
- package/ios/BillDogBridge.swift +715 -0
- package/ios/BillDogLiveActivities.m +41 -0
- package/ios/BillDogLiveActivities.swift +104 -0
- package/ios/BillDogPaywallViewManager.m +39 -0
- package/ios/BillDogPaywallViewManager.swift +361 -0
- package/ios/BillDogSurvey.m +34 -0
- package/ios/BillDogSurvey.swift +257 -0
- package/ios/BillDogVirtualCurrencyBridge.m +63 -0
- package/ios/BillDogVirtualCurrencyBridge.swift +511 -0
- package/junit.xml +25 -0
- package/package.json +61 -0
- package/react-native.config.js +13 -0
- package/src/AdvancedPaywallCache.ts +433 -0
- package/src/BillDog.ts +983 -0
- package/src/BillDogConfiguration.ts +318 -0
- package/src/ComponentRenderer.tsx +1325 -0
- package/src/LayoutEngine.ts +459 -0
- package/src/LocalizationResolver.ts +311 -0
- package/src/NativePaywallView.tsx +132 -0
- package/src/PaywallCache.ts +358 -0
- package/src/PaywallStateManager.ts +154 -0
- package/src/PaywallView.tsx +328 -0
- package/src/ProductVariableProvider.ts +282 -0
- package/src/VariableResolver.ts +516 -0
- package/src/WebViewPaywall.tsx +454 -0
- package/src/animations/presets.ts +421 -0
- package/src/components/AccoladeCpsComponent.tsx +259 -0
- package/src/components/AccordionComponent.tsx +213 -0
- package/src/components/AnimatedWrapper.tsx +316 -0
- package/src/components/CarouselComponent.tsx +615 -0
- package/src/components/ChartCurveComponent.tsx +452 -0
- package/src/components/CheckboxComponent.tsx +185 -0
- package/src/components/ConfettiComponent.tsx +178 -0
- package/src/components/CountdownComponent.tsx +454 -0
- package/src/components/DelayedXComponent.tsx +266 -0
- package/src/components/DrawerModalComponent.tsx +324 -0
- package/src/components/GradientView.tsx +129 -0
- package/src/components/HapticFeedbackComponent.tsx +39 -0
- package/src/components/HorizontalProductsComponent.tsx +329 -0
- package/src/components/MultiChoiceGridComponent.tsx +265 -0
- package/src/components/NPSScaleComponent.tsx +294 -0
- package/src/components/NavigationComponent.tsx +329 -0
- package/src/components/OAuthButtonComponent.tsx +266 -0
- package/src/components/ProgressLoaderComponent.tsx +366 -0
- package/src/components/ProgressStepperComponent.tsx +250 -0
- package/src/components/SegmentedPickerComponent.tsx +245 -0
- package/src/components/ShareButtonsComponent.tsx +299 -0
- package/src/components/ShareCodeComponent.tsx +303 -0
- package/src/components/SingleChoiceGridComponent.tsx +229 -0
- package/src/components/SliderComponent.tsx +280 -0
- package/src/components/StarRatingInputComponent.tsx +223 -0
- package/src/components/StickerCompositeComponent.tsx +168 -0
- package/src/components/TabsComponent.tsx +496 -0
- package/src/components/TextInputComponent.tsx +258 -0
- package/src/components/TimelineComponent.tsx +129 -0
- package/src/components/ToggleComponent.tsx +142 -0
- package/src/components/VerticalProductsComponent.tsx +357 -0
- package/src/dynamicValues.ts +180 -0
- package/src/filters/dateFilters.ts +411 -0
- package/src/filters/index.ts +281 -0
- package/src/hooks/useOfferings.ts +192 -0
- package/src/hooks/usePaywall.ts +154 -0
- package/src/hooks/usePlacement.ts +143 -0
- package/src/hooks/useSubscription.ts +154 -0
- package/src/index.ts +245 -0
- package/src/models/BillDogError.ts +24 -0
- package/src/models/CacheFetchPolicy.ts +13 -0
- package/src/models/CustomProduct.ts +33 -0
- package/src/models/CustomerInfo.ts +26 -0
- package/src/models/Delegate.ts +22 -0
- package/src/models/EntitlementInfo.ts +27 -0
- package/src/models/Placement.ts +50 -0
- package/src/models/PurchaseParams.ts +81 -0
- package/src/models/PurchaseResult.ts +32 -0
- package/src/models/RestoreResult.ts +27 -0
- package/src/models/RestoredItem.ts +25 -0
- package/src/modules/ABTest.ts +131 -0
- package/src/modules/Analytics.ts +227 -0
- package/src/modules/Survey.ts +126 -0
- package/src/modules/VirtualCurrency.ts +223 -0
- package/src/murmur.ts +102 -0
- package/src/notifications/LiveActivitiesManager.ts +140 -0
- package/src/notifications/NotificationScheduler.ts +292 -0
- package/src/notifications/PurchaseNotificationHandler.ts +67 -0
- package/src/notifications/useDeviceToken.ts +116 -0
- package/src/notifications/useLiveActivity.ts +125 -0
- package/src/review/ReviewAnalytics.ts +89 -0
- package/src/review/ReviewManager.ts +355 -0
- package/src/review/ReviewTimingManager.ts +265 -0
- package/src/survey-core/types.ts +244 -0
- package/src/types/ambient.d.ts +9 -0
- package/src/types.ts +680 -0
- package/src/utils/ApiClient.ts +163 -0
- package/src/utils/CSSConverter.ts +552 -0
- package/src/utils/animations.ts +232 -0
- package/src/utils/calendarIntegration.ts +113 -0
- package/src/utils/configurationResolver.ts +106 -0
- package/src/utils/deviceDetection.ts +83 -0
- package/src/utils/hapticFeedback.ts +55 -0
- package/src/utils/iconMapper.ts +102 -0
- package/src/utils/notificationPermissions.ts +48 -0
- package/src/utils/priceFormatting.ts +119 -0
- package/src/utils/shareSheet.ts +55 -0
- package/src/utils/subscriptionUpgrade.ts +183 -0
- package/src/valueUtils.ts +108 -0
- package/src/xFlowTags.ts +463 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default API base URL — routes through BillDog's Cloudflare proxy.
|
|
3
|
+
* Matches Android's `BillDogConfig.apiBaseUrl` and iOS's `BillDogConfig.API_BASE_URL`.
|
|
4
|
+
*/
|
|
5
|
+
export declare const DEFAULT_API_BASE_URL = "https://api.billdog.io/v1";
|
|
6
|
+
/**
|
|
7
|
+
* BillDog Paywalls SDK configuration
|
|
8
|
+
*/
|
|
9
|
+
export interface BillDogConfig {
|
|
10
|
+
/** API key for authentication (must start with "bd_") */
|
|
11
|
+
apiKey?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for all API calls.
|
|
14
|
+
* Defaults to `https://api.billdog.io/v1` (the branded API host).
|
|
15
|
+
* Override only for testing or self-hosted deployments — the override must
|
|
16
|
+
* point at a host that behaves like the BillDog edge Worker.
|
|
17
|
+
*/
|
|
18
|
+
apiBaseUrl: string;
|
|
19
|
+
/** Enable advanced caching features (compression, multi-level cache) */
|
|
20
|
+
enableAdvancedCaching: boolean;
|
|
21
|
+
/** Maximum cache size in bytes (default: 50MB) */
|
|
22
|
+
maxCacheSize?: number;
|
|
23
|
+
/** Cache TTL in milliseconds (default: 7 days) */
|
|
24
|
+
cacheTTL?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Override device locale for all paywalls.
|
|
27
|
+
* Use ISO 639-1 language codes (e.g., "es", "fr", "de", "ja").
|
|
28
|
+
* Set to undefined to use device locale (default).
|
|
29
|
+
*/
|
|
30
|
+
localeOverride?: string;
|
|
31
|
+
/** SDK environment */
|
|
32
|
+
environment?: 'sandbox' | 'production';
|
|
33
|
+
/** Enable debug logging */
|
|
34
|
+
enableLogging?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* PUR-262: granular log level. When set, overrides `enableLogging`.
|
|
37
|
+
* Canonical 5-level set: `verbose, debug, info, warn, error`.
|
|
38
|
+
*/
|
|
39
|
+
logLevel?: import('./models/BillDogError').BillDogLogLevel;
|
|
40
|
+
/** Override analytics enabled state (master kill switch). undefined = use server config. */
|
|
41
|
+
analyticsEnabled?: boolean;
|
|
42
|
+
/** Override flush interval in seconds. Minimum: 10s. undefined = use server config. */
|
|
43
|
+
analyticsFlushInterval?: number;
|
|
44
|
+
/** Override batch size (events before auto-flush). Minimum: 5. undefined = use server config. */
|
|
45
|
+
analyticsBatchSize?: number;
|
|
46
|
+
/** Override max queue size. undefined = use server config. */
|
|
47
|
+
analyticsMaxQueueSize?: number;
|
|
48
|
+
/** Override session timeout in seconds. undefined = use server config. */
|
|
49
|
+
analyticsSessionTimeout?: number;
|
|
50
|
+
/** Override sampling rate (0.0–1.0). undefined = use server config. */
|
|
51
|
+
analyticsSamplingRate?: number;
|
|
52
|
+
/**
|
|
53
|
+
* App Store numeric ID (iOS) — used only for the Smart Review store-page
|
|
54
|
+
* fallback when the native `react-native-in-app-review` module isn't installed.
|
|
55
|
+
* e.g. '1234567890'. Without it (and without the native module) iOS review
|
|
56
|
+
* requests report unavailable instead of opening a broken URL.
|
|
57
|
+
*/
|
|
58
|
+
appStoreId?: string;
|
|
59
|
+
/**
|
|
60
|
+
* Google Play package name (Android) — used only for the Smart Review
|
|
61
|
+
* store-page fallback when `react-native-in-app-review` isn't installed.
|
|
62
|
+
* e.g. 'com.acme.app'.
|
|
63
|
+
*/
|
|
64
|
+
androidPackageName?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Global configuration singleton
|
|
68
|
+
*/
|
|
69
|
+
export declare const BillDogConfiguration: {
|
|
70
|
+
config: BillDogConfig;
|
|
71
|
+
/**
|
|
72
|
+
* Configure the SDK with custom settings.
|
|
73
|
+
* Should be called early in app initialization (e.g., App.tsx or index.js).
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```typescript
|
|
77
|
+
* // Minimal configuration
|
|
78
|
+
* BillDogConfiguration.configure({
|
|
79
|
+
* apiKey: 'bd_live_abc123',
|
|
80
|
+
* });
|
|
81
|
+
*
|
|
82
|
+
* // Full configuration
|
|
83
|
+
* BillDogConfiguration.configure({
|
|
84
|
+
* apiKey: 'bd_live_abc123',
|
|
85
|
+
* environment: 'production',
|
|
86
|
+
* localeOverride: 'es',
|
|
87
|
+
* });
|
|
88
|
+
*
|
|
89
|
+
* // Self-hosted / testing
|
|
90
|
+
* BillDogConfiguration.configure({
|
|
91
|
+
* apiKey: 'bd_test_abc123',
|
|
92
|
+
* apiBaseUrl: 'https://my-proxy.example.com',
|
|
93
|
+
* environment: 'sandbox',
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
configure(newConfig: Partial<BillDogConfig>): void;
|
|
98
|
+
/** Cached server-driven SDK config */
|
|
99
|
+
_serverConfig: Record<string, any> | null;
|
|
100
|
+
/**
|
|
101
|
+
* Fetch server-driven SDK configuration.
|
|
102
|
+
* Applies server config under client overrides (client > server > defaults).
|
|
103
|
+
* Called automatically during `configure()` — can also be called manually to refresh.
|
|
104
|
+
*/
|
|
105
|
+
fetchSdkConfig(): Promise<Record<string, any> | null>;
|
|
106
|
+
/**
|
|
107
|
+
* Get the resolved server SDK config (null if not yet fetched).
|
|
108
|
+
*/
|
|
109
|
+
getServerConfig(): Record<string, any> | null;
|
|
110
|
+
/**
|
|
111
|
+
* Get the resolved API base URL.
|
|
112
|
+
* Returns the configured `apiBaseUrl` (defaults to `https://api.billdog.io/v1`).
|
|
113
|
+
*/
|
|
114
|
+
getApiBaseUrl(): string;
|
|
115
|
+
/**
|
|
116
|
+
* Get the configured API key.
|
|
117
|
+
* @throws if API key has not been configured.
|
|
118
|
+
*/
|
|
119
|
+
getApiKey(): string;
|
|
120
|
+
/**
|
|
121
|
+
* Check if the SDK has been configured with an API key.
|
|
122
|
+
*/
|
|
123
|
+
isConfigured(): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Build a full endpoint URL from a function name.
|
|
126
|
+
* e.g., `resolveEndpoint('fetch-paywall')` → `https://api.billdog.io/v1/fetch-paywall`
|
|
127
|
+
*/
|
|
128
|
+
resolveEndpoint(functionName: string): string;
|
|
129
|
+
/**
|
|
130
|
+
* Set the locale override at runtime.
|
|
131
|
+
* This will affect all future paywall displays.
|
|
132
|
+
*
|
|
133
|
+
* @param locale - ISO 639-1 language code (e.g., "es", "fr", "de") or undefined to use device locale
|
|
134
|
+
*/
|
|
135
|
+
setLocaleOverride(locale: string | undefined): void;
|
|
136
|
+
/**
|
|
137
|
+
* Get the current locale override.
|
|
138
|
+
* @returns The current locale override, or undefined if using device locale
|
|
139
|
+
*/
|
|
140
|
+
getLocaleOverride(): string | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Reset to default configuration
|
|
143
|
+
*/
|
|
144
|
+
reset(): void;
|
|
145
|
+
};
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BillDogConfiguration = exports.DEFAULT_API_BASE_URL = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Default API base URL — routes through BillDog's Cloudflare proxy.
|
|
6
|
+
* Matches Android's `BillDogConfig.apiBaseUrl` and iOS's `BillDogConfig.API_BASE_URL`.
|
|
7
|
+
*/
|
|
8
|
+
exports.DEFAULT_API_BASE_URL = 'https://api.billdog.io/v1';
|
|
9
|
+
// Optional native module — present in a native build (Android/iOS), null in a
|
|
10
|
+
// JS-only Metro run / Expo Go. `configure()` propagates the apiKey to the native
|
|
11
|
+
// BillDog singleton so delegating calls (getCustomerInfo/register/purchase/…)
|
|
12
|
+
// actually reach the configured native SDK.
|
|
13
|
+
const _nativeBillDog = (() => {
|
|
14
|
+
var _a, _b, _c;
|
|
15
|
+
try {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
17
|
+
return (_c = (_b = (_a = require('react-native')) === null || _a === void 0 ? void 0 : _a.NativeModules) === null || _b === void 0 ? void 0 : _b.BillDog) !== null && _c !== void 0 ? _c : null;
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
})();
|
|
23
|
+
/**
|
|
24
|
+
* Global configuration singleton
|
|
25
|
+
*/
|
|
26
|
+
exports.BillDogConfiguration = {
|
|
27
|
+
config: {
|
|
28
|
+
apiKey: undefined,
|
|
29
|
+
apiBaseUrl: exports.DEFAULT_API_BASE_URL,
|
|
30
|
+
enableAdvancedCaching: true,
|
|
31
|
+
maxCacheSize: 50 * 1024 * 1024, // 50MB
|
|
32
|
+
cacheTTL: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
33
|
+
localeOverride: undefined,
|
|
34
|
+
environment: 'production',
|
|
35
|
+
enableLogging: false,
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Configure the SDK with custom settings.
|
|
39
|
+
* Should be called early in app initialization (e.g., App.tsx or index.js).
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* // Minimal configuration
|
|
44
|
+
* BillDogConfiguration.configure({
|
|
45
|
+
* apiKey: 'bd_live_abc123',
|
|
46
|
+
* });
|
|
47
|
+
*
|
|
48
|
+
* // Full configuration
|
|
49
|
+
* BillDogConfiguration.configure({
|
|
50
|
+
* apiKey: 'bd_live_abc123',
|
|
51
|
+
* environment: 'production',
|
|
52
|
+
* localeOverride: 'es',
|
|
53
|
+
* });
|
|
54
|
+
*
|
|
55
|
+
* // Self-hosted / testing
|
|
56
|
+
* BillDogConfiguration.configure({
|
|
57
|
+
* apiKey: 'bd_test_abc123',
|
|
58
|
+
* apiBaseUrl: 'https://my-proxy.example.com',
|
|
59
|
+
* environment: 'sandbox',
|
|
60
|
+
* });
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
configure(newConfig) {
|
|
64
|
+
this.config = { ...this.config, ...newConfig };
|
|
65
|
+
if (this.config.enableLogging) {
|
|
66
|
+
console.log('[BillDogConfiguration] Updated:', {
|
|
67
|
+
apiBaseUrl: this.config.apiBaseUrl,
|
|
68
|
+
hasApiKey: !!this.config.apiKey,
|
|
69
|
+
environment: this.config.environment,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Propagate to the native SDK so its singleton is configured (thin-bridge
|
|
73
|
+
// calls delegate to it). Fire-and-forget — best-effort, never blocks JS.
|
|
74
|
+
if (this.config.apiKey && (_nativeBillDog === null || _nativeBillDog === void 0 ? void 0 : _nativeBillDog.configure)) {
|
|
75
|
+
try {
|
|
76
|
+
const result = _nativeBillDog.configure(this.config.apiKey, {
|
|
77
|
+
enableLogging: !!this.config.enableLogging,
|
|
78
|
+
environment: this.config.environment,
|
|
79
|
+
localeOverride: this.config.localeOverride,
|
|
80
|
+
});
|
|
81
|
+
if (result && typeof result.catch === 'function')
|
|
82
|
+
result.catch(() => { });
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
/* native configure is best-effort */
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Fetch remote SDK config in background (non-blocking)
|
|
89
|
+
if (this.config.apiKey) {
|
|
90
|
+
this.fetchSdkConfig().catch(() => { });
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
/** Cached server-driven SDK config */
|
|
94
|
+
_serverConfig: null,
|
|
95
|
+
/**
|
|
96
|
+
* Fetch server-driven SDK configuration.
|
|
97
|
+
* Applies server config under client overrides (client > server > defaults).
|
|
98
|
+
* Called automatically during `configure()` — can also be called manually to refresh.
|
|
99
|
+
*/
|
|
100
|
+
async fetchSdkConfig() {
|
|
101
|
+
var _a, _b, _c, _d, _e, _f;
|
|
102
|
+
try {
|
|
103
|
+
const endpoint = this.resolveEndpoint('sdk-config');
|
|
104
|
+
const response = await fetch(endpoint, {
|
|
105
|
+
method: 'GET',
|
|
106
|
+
headers: {
|
|
107
|
+
'Content-Type': 'application/json',
|
|
108
|
+
'X-BillDog-API-Key': this.config.apiKey,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
if (!response.ok)
|
|
112
|
+
return null;
|
|
113
|
+
const json = await response.json();
|
|
114
|
+
const data = json === null || json === void 0 ? void 0 : json.data;
|
|
115
|
+
if (!data)
|
|
116
|
+
return null;
|
|
117
|
+
this._serverConfig = data;
|
|
118
|
+
// Apply server analytics config where client hasn't overridden
|
|
119
|
+
const analytics = data.analytics;
|
|
120
|
+
if (analytics) {
|
|
121
|
+
if (this.config.analyticsEnabled === undefined) {
|
|
122
|
+
this.config.analyticsEnabled = (_a = analytics.enabled) !== null && _a !== void 0 ? _a : true;
|
|
123
|
+
}
|
|
124
|
+
if (this.config.analyticsFlushInterval === undefined) {
|
|
125
|
+
const serverInterval = ((_b = analytics.flush_interval_seconds) !== null && _b !== void 0 ? _b : 30);
|
|
126
|
+
this.config.analyticsFlushInterval = Math.max(serverInterval, 10);
|
|
127
|
+
}
|
|
128
|
+
if (this.config.analyticsBatchSize === undefined) {
|
|
129
|
+
this.config.analyticsBatchSize = Math.max((_c = analytics.batch_size) !== null && _c !== void 0 ? _c : 20, 5);
|
|
130
|
+
}
|
|
131
|
+
if (this.config.analyticsMaxQueueSize === undefined) {
|
|
132
|
+
this.config.analyticsMaxQueueSize = Math.max((_d = analytics.max_queue_size) !== null && _d !== void 0 ? _d : 1000, 100);
|
|
133
|
+
}
|
|
134
|
+
if (this.config.analyticsSamplingRate === undefined) {
|
|
135
|
+
this.config.analyticsSamplingRate = Math.min(Math.max((_e = analytics.sampling_rate) !== null && _e !== void 0 ? _e : 1.0, 0), 1);
|
|
136
|
+
}
|
|
137
|
+
if (this.config.analyticsSessionTimeout === undefined) {
|
|
138
|
+
this.config.analyticsSessionTimeout = (_f = analytics.session_timeout_seconds) !== null && _f !== void 0 ? _f : 300;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (this.config.enableLogging) {
|
|
142
|
+
console.log('[BillDogConfiguration] Server SDK config applied:', {
|
|
143
|
+
analyticsEnabled: this.config.analyticsEnabled,
|
|
144
|
+
flushInterval: this.config.analyticsFlushInterval,
|
|
145
|
+
batchSize: this.config.analyticsBatchSize,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return data;
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
if (this.config.enableLogging) {
|
|
152
|
+
console.warn('[BillDogConfiguration] Failed to fetch SDK config:', e);
|
|
153
|
+
}
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Get the resolved server SDK config (null if not yet fetched).
|
|
159
|
+
*/
|
|
160
|
+
getServerConfig() {
|
|
161
|
+
return this._serverConfig;
|
|
162
|
+
},
|
|
163
|
+
/**
|
|
164
|
+
* Get the resolved API base URL.
|
|
165
|
+
* Returns the configured `apiBaseUrl` (defaults to `https://api.billdog.io/v1`).
|
|
166
|
+
*/
|
|
167
|
+
getApiBaseUrl() {
|
|
168
|
+
return this.config.apiBaseUrl || exports.DEFAULT_API_BASE_URL;
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Get the configured API key.
|
|
172
|
+
* @throws if API key has not been configured.
|
|
173
|
+
*/
|
|
174
|
+
getApiKey() {
|
|
175
|
+
if (!this.config.apiKey) {
|
|
176
|
+
throw new Error('[BillDogConfiguration] API key not configured. Call BillDogConfiguration.configure({ apiKey: "bd_..." }) first.');
|
|
177
|
+
}
|
|
178
|
+
return this.config.apiKey;
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
* Check if the SDK has been configured with an API key.
|
|
182
|
+
*/
|
|
183
|
+
isConfigured() {
|
|
184
|
+
return !!this.config.apiKey;
|
|
185
|
+
},
|
|
186
|
+
/**
|
|
187
|
+
* Build a full endpoint URL from a function name.
|
|
188
|
+
* e.g., `resolveEndpoint('fetch-paywall')` → `https://api.billdog.io/v1/fetch-paywall`
|
|
189
|
+
*/
|
|
190
|
+
resolveEndpoint(functionName) {
|
|
191
|
+
const base = this.getApiBaseUrl().replace(/\/$/, '');
|
|
192
|
+
return `${base}/${functionName}`;
|
|
193
|
+
},
|
|
194
|
+
/**
|
|
195
|
+
* Set the locale override at runtime.
|
|
196
|
+
* This will affect all future paywall displays.
|
|
197
|
+
*
|
|
198
|
+
* @param locale - ISO 639-1 language code (e.g., "es", "fr", "de") or undefined to use device locale
|
|
199
|
+
*/
|
|
200
|
+
setLocaleOverride(locale) {
|
|
201
|
+
this.config.localeOverride = locale;
|
|
202
|
+
if (this.config.enableLogging) {
|
|
203
|
+
console.log(`[BillDogConfiguration] Locale override set to: ${locale !== null && locale !== void 0 ? locale : 'device default'}`);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
/**
|
|
207
|
+
* Get the current locale override.
|
|
208
|
+
* @returns The current locale override, or undefined if using device locale
|
|
209
|
+
*/
|
|
210
|
+
getLocaleOverride() {
|
|
211
|
+
return this.config.localeOverride;
|
|
212
|
+
},
|
|
213
|
+
/**
|
|
214
|
+
* Reset to default configuration
|
|
215
|
+
*/
|
|
216
|
+
reset() {
|
|
217
|
+
this.config = {
|
|
218
|
+
apiKey: undefined,
|
|
219
|
+
apiBaseUrl: exports.DEFAULT_API_BASE_URL,
|
|
220
|
+
enableAdvancedCaching: true,
|
|
221
|
+
maxCacheSize: 50 * 1024 * 1024,
|
|
222
|
+
cacheTTL: 7 * 24 * 60 * 60 * 1000,
|
|
223
|
+
localeOverride: undefined,
|
|
224
|
+
environment: 'production',
|
|
225
|
+
enableLogging: false,
|
|
226
|
+
};
|
|
227
|
+
console.log('[BillDogConfiguration] Reset to defaults');
|
|
228
|
+
}
|
|
229
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Renderer - Maps PaywallComponent types to React Native components
|
|
3
|
+
* Enhanced with CSS-first rendering, gradient support, and theme-aware color resolution
|
|
4
|
+
* UPDATED: Comprehensive theme support and fixed stack alignment
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { PaywallComponent, PaywallConfiguration, ThemeConfig } from './types';
|
|
8
|
+
interface ComponentRendererProps {
|
|
9
|
+
component: PaywallComponent;
|
|
10
|
+
configuration: PaywallConfiguration;
|
|
11
|
+
theme?: ThemeConfig;
|
|
12
|
+
onButtonPress?: (componentId: string, action: string) => void;
|
|
13
|
+
stateManager?: any;
|
|
14
|
+
isPreviewMode?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare const ComponentRenderer: React.FC<ComponentRendererProps>;
|
|
17
|
+
export {};
|