@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.
Files changed (309) hide show
  1. package/BillDogReactNative.podspec +30 -0
  2. package/LICENSE +21 -0
  3. package/README.md +330 -0
  4. package/android/build.gradle +99 -0
  5. package/android/src/main/AndroidManifest.xml +1 -0
  6. package/android/src/main/kotlin/io/billdog/reactnative/BillDogABTestModule.kt +317 -0
  7. package/android/src/main/kotlin/io/billdog/reactnative/BillDogAnalyticsModule.kt +389 -0
  8. package/android/src/main/kotlin/io/billdog/reactnative/BillDogModule.kt +817 -0
  9. package/android/src/main/kotlin/io/billdog/reactnative/BillDogPaywallViewManager.kt +383 -0
  10. package/android/src/main/kotlin/io/billdog/reactnative/BillDogSurveyModule.kt +427 -0
  11. package/android/src/main/kotlin/io/billdog/reactnative/BillDogVirtualCurrencyModule.kt +407 -0
  12. package/android/src/main/kotlin/io/billdog/virtualcurrency/BillDogVirtualCurrencyPackage.kt +44 -0
  13. package/dist/AdvancedPaywallCache.d.ts +70 -0
  14. package/dist/AdvancedPaywallCache.js +344 -0
  15. package/dist/BillDog.d.ts +255 -0
  16. package/dist/BillDog.js +918 -0
  17. package/dist/BillDogConfiguration.d.ts +145 -0
  18. package/dist/BillDogConfiguration.js +229 -0
  19. package/dist/ComponentRenderer.d.ts +17 -0
  20. package/dist/ComponentRenderer.js +886 -0
  21. package/dist/LayoutEngine.d.ts +101 -0
  22. package/dist/LayoutEngine.js +394 -0
  23. package/dist/LocalizationResolver.d.ts +99 -0
  24. package/dist/LocalizationResolver.js +266 -0
  25. package/dist/NativePaywallView.d.ts +36 -0
  26. package/dist/NativePaywallView.js +59 -0
  27. package/dist/PaywallCache.d.ts +74 -0
  28. package/dist/PaywallCache.js +293 -0
  29. package/dist/PaywallStateManager.d.ts +62 -0
  30. package/dist/PaywallStateManager.js +147 -0
  31. package/dist/PaywallView.d.ts +42 -0
  32. package/dist/PaywallView.js +275 -0
  33. package/dist/ProductVariableProvider.d.ts +60 -0
  34. package/dist/ProductVariableProvider.js +239 -0
  35. package/dist/VariableResolver.d.ts +120 -0
  36. package/dist/VariableResolver.js +379 -0
  37. package/dist/WebViewPaywall.d.ts +75 -0
  38. package/dist/WebViewPaywall.js +360 -0
  39. package/dist/animations/presets.d.ts +49 -0
  40. package/dist/animations/presets.js +367 -0
  41. package/dist/components/AccoladeCpsComponent.d.ts +13 -0
  42. package/dist/components/AccoladeCpsComponent.js +248 -0
  43. package/dist/components/AccordionComponent.d.ts +10 -0
  44. package/dist/components/AccordionComponent.js +187 -0
  45. package/dist/components/AnimatedWrapper.d.ts +35 -0
  46. package/dist/components/AnimatedWrapper.js +277 -0
  47. package/dist/components/CarouselComponent.d.ts +23 -0
  48. package/dist/components/CarouselComponent.js +484 -0
  49. package/dist/components/ChartCurveComponent.d.ts +13 -0
  50. package/dist/components/ChartCurveComponent.js +333 -0
  51. package/dist/components/CheckboxComponent.d.ts +9 -0
  52. package/dist/components/CheckboxComponent.js +172 -0
  53. package/dist/components/ConfettiComponent.d.ts +9 -0
  54. package/dist/components/ConfettiComponent.js +172 -0
  55. package/dist/components/CountdownComponent.d.ts +16 -0
  56. package/dist/components/CountdownComponent.js +414 -0
  57. package/dist/components/DelayedXComponent.d.ts +12 -0
  58. package/dist/components/DelayedXComponent.js +240 -0
  59. package/dist/components/DrawerModalComponent.d.ts +20 -0
  60. package/dist/components/DrawerModalComponent.js +286 -0
  61. package/dist/components/GradientView.d.ts +38 -0
  62. package/dist/components/GradientView.js +126 -0
  63. package/dist/components/HapticFeedbackComponent.d.ts +16 -0
  64. package/dist/components/HapticFeedbackComponent.js +64 -0
  65. package/dist/components/HorizontalProductsComponent.d.ts +17 -0
  66. package/dist/components/HorizontalProductsComponent.js +284 -0
  67. package/dist/components/MultiChoiceGridComponent.d.ts +13 -0
  68. package/dist/components/MultiChoiceGridComponent.js +234 -0
  69. package/dist/components/NPSScaleComponent.d.ts +16 -0
  70. package/dist/components/NPSScaleComponent.js +260 -0
  71. package/dist/components/NavigationComponent.d.ts +26 -0
  72. package/dist/components/NavigationComponent.js +302 -0
  73. package/dist/components/OAuthButtonComponent.d.ts +20 -0
  74. package/dist/components/OAuthButtonComponent.js +237 -0
  75. package/dist/components/ProgressLoaderComponent.d.ts +13 -0
  76. package/dist/components/ProgressLoaderComponent.js +308 -0
  77. package/dist/components/ProgressStepperComponent.d.ts +18 -0
  78. package/dist/components/ProgressStepperComponent.js +228 -0
  79. package/dist/components/SegmentedPickerComponent.d.ts +10 -0
  80. package/dist/components/SegmentedPickerComponent.js +221 -0
  81. package/dist/components/ShareButtonsComponent.d.ts +21 -0
  82. package/dist/components/ShareButtonsComponent.js +265 -0
  83. package/dist/components/ShareCodeComponent.d.ts +16 -0
  84. package/dist/components/ShareCodeComponent.js +274 -0
  85. package/dist/components/SingleChoiceGridComponent.d.ts +13 -0
  86. package/dist/components/SingleChoiceGridComponent.js +210 -0
  87. package/dist/components/SliderComponent.d.ts +9 -0
  88. package/dist/components/SliderComponent.js +263 -0
  89. package/dist/components/StarRatingInputComponent.d.ts +20 -0
  90. package/dist/components/StarRatingInputComponent.js +198 -0
  91. package/dist/components/StickerCompositeComponent.d.ts +13 -0
  92. package/dist/components/StickerCompositeComponent.js +136 -0
  93. package/dist/components/TabsComponent.d.ts +19 -0
  94. package/dist/components/TabsComponent.js +431 -0
  95. package/dist/components/TextInputComponent.d.ts +18 -0
  96. package/dist/components/TextInputComponent.js +227 -0
  97. package/dist/components/TimelineComponent.d.ts +19 -0
  98. package/dist/components/TimelineComponent.js +104 -0
  99. package/dist/components/ToggleComponent.d.ts +14 -0
  100. package/dist/components/ToggleComponent.js +132 -0
  101. package/dist/components/VerticalProductsComponent.d.ts +17 -0
  102. package/dist/components/VerticalProductsComponent.js +311 -0
  103. package/dist/dynamicValues.d.ts +36 -0
  104. package/dist/dynamicValues.js +142 -0
  105. package/dist/filters/dateFilters.d.ts +50 -0
  106. package/dist/filters/dateFilters.js +390 -0
  107. package/dist/filters/index.d.ts +18 -0
  108. package/dist/filters/index.js +253 -0
  109. package/dist/hooks/useOfferings.d.ts +76 -0
  110. package/dist/hooks/useOfferings.js +99 -0
  111. package/dist/hooks/usePaywall.d.ts +27 -0
  112. package/dist/hooks/usePaywall.js +114 -0
  113. package/dist/hooks/usePlacement.d.ts +34 -0
  114. package/dist/hooks/usePlacement.js +89 -0
  115. package/dist/hooks/useSubscription.d.ts +40 -0
  116. package/dist/hooks/useSubscription.js +97 -0
  117. package/dist/index.d.ts +98 -0
  118. package/dist/index.js +198 -0
  119. package/dist/models/BillDogError.d.ts +40 -0
  120. package/dist/models/BillDogError.js +11 -0
  121. package/dist/models/CacheFetchPolicy.d.ts +8 -0
  122. package/dist/models/CacheFetchPolicy.js +4 -0
  123. package/dist/models/CustomProduct.d.ts +32 -0
  124. package/dist/models/CustomProduct.js +15 -0
  125. package/dist/models/CustomerInfo.d.ts +17 -0
  126. package/dist/models/CustomerInfo.js +11 -0
  127. package/dist/models/Delegate.d.ts +20 -0
  128. package/dist/models/Delegate.js +11 -0
  129. package/dist/models/EntitlementInfo.d.ts +19 -0
  130. package/dist/models/EntitlementInfo.js +2 -0
  131. package/dist/models/Placement.d.ts +54 -0
  132. package/dist/models/Placement.js +15 -0
  133. package/dist/models/PurchaseParams.d.ts +39 -0
  134. package/dist/models/PurchaseParams.js +60 -0
  135. package/dist/models/PurchaseResult.d.ts +30 -0
  136. package/dist/models/PurchaseResult.js +15 -0
  137. package/dist/models/RestoreResult.d.ts +30 -0
  138. package/dist/models/RestoreResult.js +22 -0
  139. package/dist/models/RestoredItem.d.ts +26 -0
  140. package/dist/models/RestoredItem.js +13 -0
  141. package/dist/modules/ABTest.d.ts +65 -0
  142. package/dist/modules/ABTest.js +113 -0
  143. package/dist/modules/Analytics.d.ts +91 -0
  144. package/dist/modules/Analytics.js +182 -0
  145. package/dist/modules/Survey.d.ts +65 -0
  146. package/dist/modules/Survey.js +82 -0
  147. package/dist/modules/VirtualCurrency.d.ts +63 -0
  148. package/dist/modules/VirtualCurrency.js +147 -0
  149. package/dist/murmur.d.ts +23 -0
  150. package/dist/murmur.js +104 -0
  151. package/dist/notifications/LiveActivitiesManager.d.ts +47 -0
  152. package/dist/notifications/LiveActivitiesManager.js +106 -0
  153. package/dist/notifications/NotificationScheduler.d.ts +55 -0
  154. package/dist/notifications/NotificationScheduler.js +199 -0
  155. package/dist/notifications/PurchaseNotificationHandler.d.ts +24 -0
  156. package/dist/notifications/PurchaseNotificationHandler.js +55 -0
  157. package/dist/notifications/useDeviceToken.d.ts +36 -0
  158. package/dist/notifications/useDeviceToken.js +97 -0
  159. package/dist/notifications/useLiveActivity.d.ts +39 -0
  160. package/dist/notifications/useLiveActivity.js +104 -0
  161. package/dist/review/ReviewAnalytics.d.ts +34 -0
  162. package/dist/review/ReviewAnalytics.js +73 -0
  163. package/dist/review/ReviewManager.d.ts +83 -0
  164. package/dist/review/ReviewManager.js +339 -0
  165. package/dist/review/ReviewTimingManager.d.ts +82 -0
  166. package/dist/review/ReviewTimingManager.js +224 -0
  167. package/dist/survey-core/types.d.ts +215 -0
  168. package/dist/survey-core/types.js +8 -0
  169. package/dist/types.d.ts +438 -0
  170. package/dist/types.js +158 -0
  171. package/dist/utils/ApiClient.d.ts +65 -0
  172. package/dist/utils/ApiClient.js +132 -0
  173. package/dist/utils/CSSConverter.d.ts +49 -0
  174. package/dist/utils/CSSConverter.js +470 -0
  175. package/dist/utils/animations.d.ts +41 -0
  176. package/dist/utils/animations.js +194 -0
  177. package/dist/utils/calendarIntegration.d.ts +36 -0
  178. package/dist/utils/calendarIntegration.js +89 -0
  179. package/dist/utils/configurationResolver.d.ts +23 -0
  180. package/dist/utils/configurationResolver.js +78 -0
  181. package/dist/utils/deviceDetection.d.ts +38 -0
  182. package/dist/utils/deviceDetection.js +59 -0
  183. package/dist/utils/hapticFeedback.d.ts +17 -0
  184. package/dist/utils/hapticFeedback.js +53 -0
  185. package/dist/utils/iconMapper.d.ts +26 -0
  186. package/dist/utils/iconMapper.js +113 -0
  187. package/dist/utils/notificationPermissions.d.ts +13 -0
  188. package/dist/utils/notificationPermissions.js +51 -0
  189. package/dist/utils/priceFormatting.d.ts +19 -0
  190. package/dist/utils/priceFormatting.js +99 -0
  191. package/dist/utils/shareSheet.d.ts +17 -0
  192. package/dist/utils/shareSheet.js +42 -0
  193. package/dist/utils/subscriptionUpgrade.d.ts +84 -0
  194. package/dist/utils/subscriptionUpgrade.js +100 -0
  195. package/dist/valueUtils.d.ts +48 -0
  196. package/dist/valueUtils.js +129 -0
  197. package/dist/xFlowTags.d.ts +18 -0
  198. package/dist/xFlowTags.js +385 -0
  199. package/ios/BillDogABTest.m +50 -0
  200. package/ios/BillDogABTest.swift +188 -0
  201. package/ios/BillDogAnalytics.m +105 -0
  202. package/ios/BillDogAnalytics.swift +324 -0
  203. package/ios/BillDogBridge.m +222 -0
  204. package/ios/BillDogBridge.swift +715 -0
  205. package/ios/BillDogLiveActivities.m +41 -0
  206. package/ios/BillDogLiveActivities.swift +104 -0
  207. package/ios/BillDogPaywallViewManager.m +39 -0
  208. package/ios/BillDogPaywallViewManager.swift +361 -0
  209. package/ios/BillDogSurvey.m +34 -0
  210. package/ios/BillDogSurvey.swift +257 -0
  211. package/ios/BillDogVirtualCurrencyBridge.m +63 -0
  212. package/ios/BillDogVirtualCurrencyBridge.swift +511 -0
  213. package/junit.xml +25 -0
  214. package/package.json +61 -0
  215. package/react-native.config.js +13 -0
  216. package/src/AdvancedPaywallCache.ts +433 -0
  217. package/src/BillDog.ts +983 -0
  218. package/src/BillDogConfiguration.ts +318 -0
  219. package/src/ComponentRenderer.tsx +1325 -0
  220. package/src/LayoutEngine.ts +459 -0
  221. package/src/LocalizationResolver.ts +311 -0
  222. package/src/NativePaywallView.tsx +132 -0
  223. package/src/PaywallCache.ts +358 -0
  224. package/src/PaywallStateManager.ts +154 -0
  225. package/src/PaywallView.tsx +328 -0
  226. package/src/ProductVariableProvider.ts +282 -0
  227. package/src/VariableResolver.ts +516 -0
  228. package/src/WebViewPaywall.tsx +454 -0
  229. package/src/animations/presets.ts +421 -0
  230. package/src/components/AccoladeCpsComponent.tsx +259 -0
  231. package/src/components/AccordionComponent.tsx +213 -0
  232. package/src/components/AnimatedWrapper.tsx +316 -0
  233. package/src/components/CarouselComponent.tsx +615 -0
  234. package/src/components/ChartCurveComponent.tsx +452 -0
  235. package/src/components/CheckboxComponent.tsx +185 -0
  236. package/src/components/ConfettiComponent.tsx +178 -0
  237. package/src/components/CountdownComponent.tsx +454 -0
  238. package/src/components/DelayedXComponent.tsx +266 -0
  239. package/src/components/DrawerModalComponent.tsx +324 -0
  240. package/src/components/GradientView.tsx +129 -0
  241. package/src/components/HapticFeedbackComponent.tsx +39 -0
  242. package/src/components/HorizontalProductsComponent.tsx +329 -0
  243. package/src/components/MultiChoiceGridComponent.tsx +265 -0
  244. package/src/components/NPSScaleComponent.tsx +294 -0
  245. package/src/components/NavigationComponent.tsx +329 -0
  246. package/src/components/OAuthButtonComponent.tsx +266 -0
  247. package/src/components/ProgressLoaderComponent.tsx +366 -0
  248. package/src/components/ProgressStepperComponent.tsx +250 -0
  249. package/src/components/SegmentedPickerComponent.tsx +245 -0
  250. package/src/components/ShareButtonsComponent.tsx +299 -0
  251. package/src/components/ShareCodeComponent.tsx +303 -0
  252. package/src/components/SingleChoiceGridComponent.tsx +229 -0
  253. package/src/components/SliderComponent.tsx +280 -0
  254. package/src/components/StarRatingInputComponent.tsx +223 -0
  255. package/src/components/StickerCompositeComponent.tsx +168 -0
  256. package/src/components/TabsComponent.tsx +496 -0
  257. package/src/components/TextInputComponent.tsx +258 -0
  258. package/src/components/TimelineComponent.tsx +129 -0
  259. package/src/components/ToggleComponent.tsx +142 -0
  260. package/src/components/VerticalProductsComponent.tsx +357 -0
  261. package/src/dynamicValues.ts +180 -0
  262. package/src/filters/dateFilters.ts +411 -0
  263. package/src/filters/index.ts +281 -0
  264. package/src/hooks/useOfferings.ts +192 -0
  265. package/src/hooks/usePaywall.ts +154 -0
  266. package/src/hooks/usePlacement.ts +143 -0
  267. package/src/hooks/useSubscription.ts +154 -0
  268. package/src/index.ts +245 -0
  269. package/src/models/BillDogError.ts +24 -0
  270. package/src/models/CacheFetchPolicy.ts +13 -0
  271. package/src/models/CustomProduct.ts +33 -0
  272. package/src/models/CustomerInfo.ts +26 -0
  273. package/src/models/Delegate.ts +22 -0
  274. package/src/models/EntitlementInfo.ts +27 -0
  275. package/src/models/Placement.ts +50 -0
  276. package/src/models/PurchaseParams.ts +81 -0
  277. package/src/models/PurchaseResult.ts +32 -0
  278. package/src/models/RestoreResult.ts +27 -0
  279. package/src/models/RestoredItem.ts +25 -0
  280. package/src/modules/ABTest.ts +131 -0
  281. package/src/modules/Analytics.ts +227 -0
  282. package/src/modules/Survey.ts +126 -0
  283. package/src/modules/VirtualCurrency.ts +223 -0
  284. package/src/murmur.ts +102 -0
  285. package/src/notifications/LiveActivitiesManager.ts +140 -0
  286. package/src/notifications/NotificationScheduler.ts +292 -0
  287. package/src/notifications/PurchaseNotificationHandler.ts +67 -0
  288. package/src/notifications/useDeviceToken.ts +116 -0
  289. package/src/notifications/useLiveActivity.ts +125 -0
  290. package/src/review/ReviewAnalytics.ts +89 -0
  291. package/src/review/ReviewManager.ts +355 -0
  292. package/src/review/ReviewTimingManager.ts +265 -0
  293. package/src/survey-core/types.ts +244 -0
  294. package/src/types/ambient.d.ts +9 -0
  295. package/src/types.ts +680 -0
  296. package/src/utils/ApiClient.ts +163 -0
  297. package/src/utils/CSSConverter.ts +552 -0
  298. package/src/utils/animations.ts +232 -0
  299. package/src/utils/calendarIntegration.ts +113 -0
  300. package/src/utils/configurationResolver.ts +106 -0
  301. package/src/utils/deviceDetection.ts +83 -0
  302. package/src/utils/hapticFeedback.ts +55 -0
  303. package/src/utils/iconMapper.ts +102 -0
  304. package/src/utils/notificationPermissions.ts +48 -0
  305. package/src/utils/priceFormatting.ts +119 -0
  306. package/src/utils/shareSheet.ts +55 -0
  307. package/src/utils/subscriptionUpgrade.ts +183 -0
  308. package/src/valueUtils.ts +108 -0
  309. package/src/xFlowTags.ts +463 -0
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ /**
3
+ * Utilities for formatting prices and subscription periods
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.formatPrice = formatPrice;
7
+ exports.formatSubscriptionPeriod = formatSubscriptionPeriod;
8
+ exports.formatIntroPricing = formatIntroPricing;
9
+ exports.getPackageTypeDisplayName = getPackageTypeDisplayName;
10
+ /**
11
+ * Format a price with currency
12
+ */
13
+ function formatPrice(price, currency = 'USD', locale = 'en-US') {
14
+ try {
15
+ const formatter = new Intl.NumberFormat(locale, {
16
+ style: 'currency',
17
+ currency: currency,
18
+ });
19
+ return formatter.format(price);
20
+ }
21
+ catch (error) {
22
+ return `${price} ${currency}`;
23
+ }
24
+ }
25
+ /**
26
+ * Format a subscription period
27
+ */
28
+ function formatSubscriptionPeriod(duration, period, locale = 'en-US') {
29
+ const periodUnit = period.toLowerCase();
30
+ // Handle singular vs plural
31
+ if (duration === 1) {
32
+ switch (periodUnit) {
33
+ case 'day':
34
+ return 'daily';
35
+ case 'week':
36
+ return 'weekly';
37
+ case 'month':
38
+ return 'monthly';
39
+ case 'year':
40
+ return 'yearly';
41
+ default:
42
+ return `${duration} ${period}`;
43
+ }
44
+ }
45
+ // Plural
46
+ const pluralPeriod = (() => {
47
+ switch (periodUnit) {
48
+ case 'day':
49
+ return 'days';
50
+ case 'week':
51
+ return 'weeks';
52
+ case 'month':
53
+ return 'months';
54
+ case 'year':
55
+ return 'years';
56
+ default:
57
+ return `${period}s`;
58
+ }
59
+ })();
60
+ return `${duration} ${pluralPeriod}`;
61
+ }
62
+ /**
63
+ * Format intro pricing info
64
+ */
65
+ function formatIntroPricing(introPrice, introDuration, introPeriod, introCycles, currency = 'USD', locale = 'en-US') {
66
+ if (!introDuration || !introPeriod) {
67
+ return null;
68
+ }
69
+ const periodText = formatSubscriptionPeriod(introDuration, introPeriod, locale);
70
+ // Free trial
71
+ if (introPrice === 0) {
72
+ return `${periodText} free trial`;
73
+ }
74
+ // Intro price
75
+ if (introPrice != null) {
76
+ const priceText = formatPrice(introPrice, currency, locale);
77
+ if (introCycles) {
78
+ return `${priceText} for ${introCycles} ${periodText}`;
79
+ }
80
+ return `${priceText} for ${periodText}`;
81
+ }
82
+ return null;
83
+ }
84
+ /**
85
+ * Helper to get package type display name
86
+ */
87
+ function getPackageTypeDisplayName(packageType) {
88
+ const typeMap = {
89
+ monthly: 'Monthly',
90
+ annual: 'Annual',
91
+ six_month: '6 Months',
92
+ three_month: '3 Months',
93
+ two_month: '2 Months',
94
+ weekly: 'Weekly',
95
+ lifetime: 'Lifetime',
96
+ custom: 'Custom',
97
+ };
98
+ return typeMap[packageType] || packageType;
99
+ }
@@ -0,0 +1,17 @@
1
+ export interface ShareData {
2
+ title?: string;
3
+ message?: string;
4
+ url?: string;
5
+ }
6
+ export interface ShareResult {
7
+ success: boolean;
8
+ error?: string;
9
+ }
10
+ /**
11
+ * Share content using native share sheet
12
+ */
13
+ export declare function share(data: ShareData): Promise<ShareResult>;
14
+ /**
15
+ * Check if sharing is supported
16
+ */
17
+ export declare function isShareSupported(): boolean;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.share = share;
4
+ exports.isShareSupported = isShareSupported;
5
+ const react_native_1 = require("react-native");
6
+ /**
7
+ * Share content using native share sheet
8
+ */
9
+ async function share(data) {
10
+ try {
11
+ const shareOptions = {};
12
+ if (data.message) {
13
+ shareOptions.message = data.message;
14
+ }
15
+ if (data.url) {
16
+ shareOptions.url = data.url;
17
+ }
18
+ if (data.title) {
19
+ shareOptions.title = data.title;
20
+ }
21
+ const result = await react_native_1.Share.share(shareOptions);
22
+ if (result.action === react_native_1.Share.sharedAction) {
23
+ return { success: true };
24
+ }
25
+ else if (result.action === react_native_1.Share.dismissedAction) {
26
+ return { success: false, error: 'Share cancelled' };
27
+ }
28
+ return { success: true };
29
+ }
30
+ catch (error) {
31
+ return {
32
+ success: false,
33
+ error: error instanceof Error ? error.message : 'Share failed',
34
+ };
35
+ }
36
+ }
37
+ /**
38
+ * Check if sharing is supported
39
+ */
40
+ function isShareSupported() {
41
+ return true;
42
+ }
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Subscription Upgrade/Downgrade Utilities
3
+ *
4
+ * Provides methods for managing subscription plan changes
5
+ * via the upgrade-subscription edge function.
6
+ *
7
+ * URLs are resolved through ApiClient → BillDogConfiguration.apiBaseUrl (api.billdog.io).
8
+ */
9
+ /** Proration behavior options */
10
+ export type ProrationBehavior = 'create_prorations' | 'none' | 'always_invoice';
11
+ /** Billing cycle anchor options */
12
+ export type BillingCycleAnchor = 'now' | 'unchanged';
13
+ /** Options for configuring subscription upgrade/downgrade */
14
+ export interface SubscriptionUpgradeOptions {
15
+ /** Customer ID (optional if already identified) */
16
+ customerId?: string;
17
+ /** App user ID (alternative identifier) */
18
+ appUserId?: string;
19
+ /** Specific web purchase ID to upgrade */
20
+ webPurchaseId?: string;
21
+ /** How proration should be handled */
22
+ prorationBehavior?: ProrationBehavior;
23
+ /** When the new billing cycle should start */
24
+ billingCycleAnchor?: BillingCycleAnchor;
25
+ }
26
+ /** Preview of subscription change costs */
27
+ export interface ProrationPreview {
28
+ /** Current subscription price ID */
29
+ currentPriceId: string;
30
+ /** New price ID after upgrade/downgrade */
31
+ newPriceId: string;
32
+ /** Amount due immediately (in cents) */
33
+ immediateAmountCents: number;
34
+ /** Human-readable immediate amount */
35
+ formattedImmediateAmount: string;
36
+ /** Prorated credit amount (in cents) */
37
+ proratedCreditCents: number;
38
+ /** Prorated charge amount (in cents) */
39
+ proratedChargeCents: number;
40
+ /** Next billing date (ISO 8601 string) */
41
+ nextBillingDate: string | null;
42
+ /** Currency code */
43
+ currency: string;
44
+ /** Whether this is an upgrade or downgrade */
45
+ isUpgrade: boolean;
46
+ }
47
+ /** Result of a subscription upgrade/downgrade operation */
48
+ export interface SubscriptionUpgradeResult {
49
+ /** Whether the operation succeeded */
50
+ success: boolean;
51
+ /** Stripe subscription ID */
52
+ subscriptionId?: string;
53
+ /** Type of change: "upgrade" or "downgrade" */
54
+ upgradeType: string;
55
+ /** Previous price ID */
56
+ oldPriceId?: string;
57
+ /** New price ID */
58
+ newPriceId: string;
59
+ /** Current period start date (ISO 8601 string) */
60
+ currentPeriodStart?: string;
61
+ /** Current period end date (ISO 8601 string) */
62
+ currentPeriodEnd?: string;
63
+ /** Applied proration behavior */
64
+ prorationBehavior: string;
65
+ /** Error message if failed */
66
+ errorMessage?: string;
67
+ }
68
+ /**
69
+ * Preview a subscription upgrade/downgrade before executing.
70
+ * Shows prorated amounts and billing changes without making changes.
71
+ *
72
+ * @param newPriceId - The Stripe price ID to change to
73
+ * @param options - Upgrade options
74
+ * @param apiKey - @deprecated Resolved from BillDogConfiguration if omitted
75
+ */
76
+ export declare function previewSubscriptionUpgrade(apiKey: string | undefined, newPriceId: string, options?: SubscriptionUpgradeOptions): Promise<ProrationPreview>;
77
+ /**
78
+ * Upgrade a subscription to a higher-tier plan
79
+ */
80
+ export declare function upgradeSubscription(apiKey: string | undefined, newPriceId: string, options?: SubscriptionUpgradeOptions): Promise<SubscriptionUpgradeResult>;
81
+ /**
82
+ * Downgrade a subscription to a lower-tier plan
83
+ */
84
+ export declare function downgradeSubscription(apiKey: string | undefined, newPriceId: string, options?: SubscriptionUpgradeOptions): Promise<SubscriptionUpgradeResult>;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ /**
3
+ * Subscription Upgrade/Downgrade Utilities
4
+ *
5
+ * Provides methods for managing subscription plan changes
6
+ * via the upgrade-subscription edge function.
7
+ *
8
+ * URLs are resolved through ApiClient → BillDogConfiguration.apiBaseUrl (api.billdog.io).
9
+ */
10
+ Object.defineProperty(exports, "__esModule", { value: true });
11
+ exports.previewSubscriptionUpgrade = previewSubscriptionUpgrade;
12
+ exports.upgradeSubscription = upgradeSubscription;
13
+ exports.downgradeSubscription = downgradeSubscription;
14
+ const ApiClient_1 = require("./ApiClient");
15
+ // MARK: - API Functions
16
+ /**
17
+ * Preview a subscription upgrade/downgrade before executing.
18
+ * Shows prorated amounts and billing changes without making changes.
19
+ *
20
+ * @param newPriceId - The Stripe price ID to change to
21
+ * @param options - Upgrade options
22
+ * @param apiKey - @deprecated Resolved from BillDogConfiguration if omitted
23
+ */
24
+ async function previewSubscriptionUpgrade(apiKey, newPriceId, options) {
25
+ var _a, _b, _c;
26
+ const data = await ApiClient_1.ApiClient.post('upgrade-subscription', {
27
+ new_price_id: newPriceId,
28
+ preview: true,
29
+ customer_id: options === null || options === void 0 ? void 0 : options.customerId,
30
+ app_user_id: options === null || options === void 0 ? void 0 : options.appUserId,
31
+ web_purchase_id: options === null || options === void 0 ? void 0 : options.webPurchaseId,
32
+ proration_behavior: (_a = options === null || options === void 0 ? void 0 : options.prorationBehavior) !== null && _a !== void 0 ? _a : 'create_prorations',
33
+ billing_cycle_anchor: (_b = options === null || options === void 0 ? void 0 : options.billingCycleAnchor) !== null && _b !== void 0 ? _b : 'unchanged',
34
+ }, {
35
+ apiKey: apiKey || undefined,
36
+ });
37
+ const preview = data.preview;
38
+ return {
39
+ currentPriceId: preview.current_price_id || '',
40
+ newPriceId: preview.new_price_id || '',
41
+ immediateAmountCents: preview.immediate_amount_cents || 0,
42
+ formattedImmediateAmount: preview.formatted_immediate_amount || '$0.00',
43
+ proratedCreditCents: preview.prorated_credit_cents || 0,
44
+ proratedChargeCents: preview.prorated_charge_cents || 0,
45
+ nextBillingDate: preview.next_billing_date || null,
46
+ currency: preview.currency || 'usd',
47
+ isUpgrade: (_c = preview.is_upgrade) !== null && _c !== void 0 ? _c : true,
48
+ };
49
+ }
50
+ /**
51
+ * Upgrade a subscription to a higher-tier plan
52
+ */
53
+ async function upgradeSubscription(apiKey, newPriceId, options) {
54
+ return executeSubscriptionChange(apiKey, newPriceId, options);
55
+ }
56
+ /**
57
+ * Downgrade a subscription to a lower-tier plan
58
+ */
59
+ async function downgradeSubscription(apiKey, newPriceId, options) {
60
+ return executeSubscriptionChange(apiKey, newPriceId, options);
61
+ }
62
+ /**
63
+ * Internal function to execute subscription change
64
+ */
65
+ async function executeSubscriptionChange(apiKey, newPriceId, options) {
66
+ var _a, _b, _c, _d;
67
+ try {
68
+ const data = await ApiClient_1.ApiClient.post('upgrade-subscription', {
69
+ new_price_id: newPriceId,
70
+ preview: false,
71
+ customer_id: options === null || options === void 0 ? void 0 : options.customerId,
72
+ app_user_id: options === null || options === void 0 ? void 0 : options.appUserId,
73
+ web_purchase_id: options === null || options === void 0 ? void 0 : options.webPurchaseId,
74
+ proration_behavior: (_a = options === null || options === void 0 ? void 0 : options.prorationBehavior) !== null && _a !== void 0 ? _a : 'create_prorations',
75
+ billing_cycle_anchor: (_b = options === null || options === void 0 ? void 0 : options.billingCycleAnchor) !== null && _b !== void 0 ? _b : 'unchanged',
76
+ }, {
77
+ apiKey: apiKey || undefined,
78
+ });
79
+ return {
80
+ success: (_c = data.success) !== null && _c !== void 0 ? _c : false,
81
+ subscriptionId: data.subscription_id,
82
+ upgradeType: data.upgrade_type || 'upgrade',
83
+ oldPriceId: data.old_price_id,
84
+ newPriceId: data.new_price_id || newPriceId,
85
+ currentPeriodStart: data.current_period_start,
86
+ currentPeriodEnd: data.current_period_end,
87
+ prorationBehavior: data.proration_behavior || 'create_prorations',
88
+ errorMessage: data.error,
89
+ };
90
+ }
91
+ catch (err) {
92
+ return {
93
+ success: false,
94
+ upgradeType: 'unknown',
95
+ newPriceId: newPriceId,
96
+ prorationBehavior: (_d = options === null || options === void 0 ? void 0 : options.prorationBehavior) !== null && _d !== void 0 ? _d : 'create_prorations',
97
+ errorMessage: err.message || `Failed to change subscription`,
98
+ };
99
+ }
100
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * ValueUtils — Shared primitive utilities for BillDog React Native SDK
3
+ *
4
+ * Canonical source for type coercion, comparison, and nested path walking.
5
+ * Used by dynamicValues.ts, xFlowTags.ts, and other modules.
6
+ *
7
+ * stringify/toNumber implement the canonical xFlow grammar (§5 of
8
+ * src/schemas/xflow-grammar.md): null/undefined → "", non-numeric → 0.
9
+ */
10
+ /**
11
+ * Walk a dot-separated path on a nested object.
12
+ *
13
+ * Flat-key-first (grammar §4): a literal key matching the whole path wins
14
+ * over dotted traversal, so a variable stored under the literal key
15
+ * "user.name" resolves before descending into `user`.
16
+ */
17
+ export declare function getNestedValue(obj: any, path: string): any;
18
+ /**
19
+ * Numeric-first equality for dynamic value conditions, matching native `ValueUtils.isEqual` (iOS +
20
+ * Android) and the web/renderer copies. Both-null → true; if BOTH operands coerce to a number, compare
21
+ * numerically (so `10.0` equals `"10"`); otherwise string-compare. The string-only version this replaced
22
+ * diverged from the device the moment a fractional or typed value was involved.
23
+ */
24
+ /**
25
+ * STRUCTURAL equality — the counterpart to `isEqual`, mirroring the split native
26
+ * `ValueUtils` already makes (`isDeepEqual` vs `valuesEqual` on Android).
27
+ *
28
+ * Do NOT confuse the two. `isEqual` coerces (`1` equals `"1"`) because DV CONDITIONS
29
+ * must; state identity must not, or PaywallStateManager would swallow a genuine
30
+ * `1` → `"1"` transition that Android/iOS emit. This mirrors Android's
31
+ * `ValueUtils.isDeepEqual`: numbers compare numerically, arrays/objects compare
32
+ * structurally, everything else is strict.
33
+ */
34
+ export declare function isDeepEqual(a: any, b: any): boolean;
35
+ export declare function isEqual(a: any, b: any): boolean;
36
+ /**
37
+ * Check if a value is truthy (non-null, non-empty, non-zero).
38
+ */
39
+ export declare function isTruthy(value: any): boolean;
40
+ /** Canonical stringify — null/undefined → "" (grammar §5.1). */
41
+ export declare function stringify(value: any): string;
42
+ /** Canonical numeric coercion — non-numeric → 0, never NaN (grammar §5.2). */
43
+ export declare function toNumber(value: any): number;
44
+ /**
45
+ * Number-or-null, matching native `toDoubleOrNull`. Used by `isEqual` to decide whether to compare
46
+ * numerically. Booleans return null so `true` never numeric-equals `1` (they string-compare instead).
47
+ */
48
+ export declare function toNumberOrNull(value: any): number | null;
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+ /**
3
+ * ValueUtils — Shared primitive utilities for BillDog React Native SDK
4
+ *
5
+ * Canonical source for type coercion, comparison, and nested path walking.
6
+ * Used by dynamicValues.ts, xFlowTags.ts, and other modules.
7
+ *
8
+ * stringify/toNumber implement the canonical xFlow grammar (§5 of
9
+ * src/schemas/xflow-grammar.md): null/undefined → "", non-numeric → 0.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getNestedValue = getNestedValue;
13
+ exports.isDeepEqual = isDeepEqual;
14
+ exports.isEqual = isEqual;
15
+ exports.isTruthy = isTruthy;
16
+ exports.stringify = stringify;
17
+ exports.toNumber = toNumber;
18
+ exports.toNumberOrNull = toNumberOrNull;
19
+ /**
20
+ * Walk a dot-separated path on a nested object.
21
+ *
22
+ * Flat-key-first (grammar §4): a literal key matching the whole path wins
23
+ * over dotted traversal, so a variable stored under the literal key
24
+ * "user.name" resolves before descending into `user`.
25
+ */
26
+ function getNestedValue(obj, path) {
27
+ if (obj && typeof obj === 'object' && path in obj)
28
+ return obj[path];
29
+ return path.split('.').reduce((current, key) => current === null || current === void 0 ? void 0 : current[key], obj);
30
+ }
31
+ /**
32
+ * Numeric-first equality for dynamic value conditions, matching native `ValueUtils.isEqual` (iOS +
33
+ * Android) and the web/renderer copies. Both-null → true; if BOTH operands coerce to a number, compare
34
+ * numerically (so `10.0` equals `"10"`); otherwise string-compare. The string-only version this replaced
35
+ * diverged from the device the moment a fractional or typed value was involved.
36
+ */
37
+ /**
38
+ * STRUCTURAL equality — the counterpart to `isEqual`, mirroring the split native
39
+ * `ValueUtils` already makes (`isDeepEqual` vs `valuesEqual` on Android).
40
+ *
41
+ * Do NOT confuse the two. `isEqual` coerces (`1` equals `"1"`) because DV CONDITIONS
42
+ * must; state identity must not, or PaywallStateManager would swallow a genuine
43
+ * `1` → `"1"` transition that Android/iOS emit. This mirrors Android's
44
+ * `ValueUtils.isDeepEqual`: numbers compare numerically, arrays/objects compare
45
+ * structurally, everything else is strict.
46
+ */
47
+ function isDeepEqual(a, b) {
48
+ if (a === b)
49
+ return true;
50
+ if (a == null || b == null)
51
+ return false;
52
+ if (typeof a === 'number' && typeof b === 'number')
53
+ return a === b;
54
+ if (Array.isArray(a) && Array.isArray(b)) {
55
+ return a.length === b.length && a.every((v, i) => isDeepEqual(v, b[i]));
56
+ }
57
+ if (Array.isArray(a) !== Array.isArray(b))
58
+ return false;
59
+ if (typeof a === 'object' && typeof b === 'object') {
60
+ const ak = Object.keys(a);
61
+ const bk = Object.keys(b);
62
+ return ak.length === bk.length && ak.every((k) => isDeepEqual(a[k], b[k]));
63
+ }
64
+ return false;
65
+ }
66
+ function isEqual(a, b) {
67
+ if (a == null && b == null)
68
+ return true;
69
+ if (a == null || b == null)
70
+ return false;
71
+ const an = toNumberOrNull(a);
72
+ const bn = toNumberOrNull(b);
73
+ if (an !== null && bn !== null)
74
+ return an === bn;
75
+ return stringify(a) === stringify(b);
76
+ }
77
+ /**
78
+ * Check if a value is truthy (non-null, non-empty, non-zero).
79
+ */
80
+ function isTruthy(value) {
81
+ if (value === null || value === undefined)
82
+ return false;
83
+ if (value === false)
84
+ return false;
85
+ if (value === '' || value === 0)
86
+ return false;
87
+ return true;
88
+ }
89
+ /** Canonical stringify — null/undefined → "" (grammar §5.1). */
90
+ function stringify(value) {
91
+ var _a;
92
+ if (value === null || value === undefined)
93
+ return '';
94
+ if (typeof value === 'string')
95
+ return value;
96
+ if (typeof value === 'boolean')
97
+ return value ? 'true' : 'false';
98
+ if (typeof value === 'number')
99
+ return String(value);
100
+ try {
101
+ return (_a = JSON.stringify(value)) !== null && _a !== void 0 ? _a : '';
102
+ }
103
+ catch {
104
+ return String(value);
105
+ }
106
+ }
107
+ /** Canonical numeric coercion — non-numeric → 0, never NaN (grammar §5.2). */
108
+ function toNumber(value) {
109
+ if (typeof value === 'number')
110
+ return Number.isFinite(value) ? value : 0;
111
+ if (typeof value === 'string' && value.trim() !== '') {
112
+ const n = Number(value);
113
+ return Number.isFinite(n) ? n : 0;
114
+ }
115
+ return 0;
116
+ }
117
+ /**
118
+ * Number-or-null, matching native `toDoubleOrNull`. Used by `isEqual` to decide whether to compare
119
+ * numerically. Booleans return null so `true` never numeric-equals `1` (they string-compare instead).
120
+ */
121
+ function toNumberOrNull(value) {
122
+ if (typeof value === 'number')
123
+ return Number.isFinite(value) ? value : null;
124
+ if (typeof value === 'string' && value.trim() !== '') {
125
+ const n = Number(value);
126
+ return Number.isFinite(n) ? n : null;
127
+ }
128
+ return null;
129
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * xFlow Tag Preprocessor — React Native SDK.
3
+ *
4
+ * Faithful port of src/lib/filters/xFlowTags.ts (the web reference). Implements
5
+ * the canonical grammar at src/schemas/xflow-grammar.md. Runs as a first pass
6
+ * before {{ }} interpolation. The conformance corpus
7
+ * (tests/parity/xflow-corpus/) is the cross-platform contract — web, iOS,
8
+ * Android, and React Native parsers must produce identical output.
9
+ *
10
+ * Tags: {% assign %} (with filter chains), {% if/elsif/else/endif %},
11
+ * {% unless/endunless %}, {% case/when/else/endcase %}.
12
+ * Conditions: ==, !=, >, <, >=, <=, contains, and, or, unary !, postfix exists.
13
+ */
14
+ export interface XFlowTagResult {
15
+ text: string;
16
+ variables: Record<string, any>;
17
+ }
18
+ export declare function processXFlowTags(text: string, variables: Record<string, any>): XFlowTagResult;