@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,360 @@
1
+ "use strict";
2
+ /**
3
+ * WebViewPaywall — Optional WebView-based paywall component for the
4
+ * React Native SDK.
5
+ *
6
+ * The default React Native paywall path is native (`PaywallView` →
7
+ * `ComponentRenderer`). This component is the WebView alternative that
8
+ * loads the same unified renderer bundle iOS / Android / Flutter use,
9
+ * so paywalls visually match across all platforms at the cost of one
10
+ * extra `react-native-webview` dependency.
11
+ *
12
+ * Android parity reference:
13
+ * - `BillDogWebViewPaywall` (Android, billdog-paywalls-webview module)
14
+ * - Canonical message protocol:
15
+ * packages/paywall-renderer/src/native/messageProtocol.ts
16
+ * - postMessage events handled here mirror the protocol's
17
+ * OutboundMessageType union: purchase / restore / close / open_url /
18
+ * track / state_changed / error / ready.
19
+ *
20
+ * Architecture choice: URL-based loading (same as Flutter) rather than
21
+ * bundled HTML asset. The renderer is served by the `render-paywall`
22
+ * edge function at `https://api.billdog.io/v1/render-paywall?...`,
23
+ * and the paywall config is delivered to the renderer via the JS
24
+ * bridge function `window.loadPaywallData(...)` — same contract as
25
+ * the Flutter SDK uses (packages/flutter/lib/src/widgets/paywall_view.dart).
26
+ *
27
+ * Bundling the HTML as a static asset requires a metro.config.js change
28
+ * (`assetExts: ['html', ...]` + `metro-html-loader`). URL-based avoids
29
+ * that and is the simpler MVP. If first-paint latency becomes a problem,
30
+ * a future revision can switch to local-asset loading.
31
+ */
32
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
33
+ if (k2 === undefined) k2 = k;
34
+ var desc = Object.getOwnPropertyDescriptor(m, k);
35
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
36
+ desc = { enumerable: true, get: function() { return m[k]; } };
37
+ }
38
+ Object.defineProperty(o, k2, desc);
39
+ }) : (function(o, m, k, k2) {
40
+ if (k2 === undefined) k2 = k;
41
+ o[k2] = m[k];
42
+ }));
43
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
44
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
45
+ }) : function(o, v) {
46
+ o["default"] = v;
47
+ });
48
+ var __importStar = (this && this.__importStar) || (function () {
49
+ var ownKeys = function(o) {
50
+ ownKeys = Object.getOwnPropertyNames || function (o) {
51
+ var ar = [];
52
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
53
+ return ar;
54
+ };
55
+ return ownKeys(o);
56
+ };
57
+ return function (mod) {
58
+ if (mod && mod.__esModule) return mod;
59
+ var result = {};
60
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
61
+ __setModuleDefault(result, mod);
62
+ return result;
63
+ };
64
+ })();
65
+ Object.defineProperty(exports, "__esModule", { value: true });
66
+ exports.WebViewPaywall = void 0;
67
+ const react_1 = __importStar(require("react"));
68
+ const react_native_1 = require("react-native");
69
+ const BillDogConfiguration_1 = require("./BillDogConfiguration");
70
+ // Lazily resolve the `react-native-webview` module. Importing it at the top
71
+ // level runs its native-module lookup (`TurboModuleRegistry.getEnforcing(
72
+ // 'RNCWebViewModule')`) at SDK-load time, which THROWS an Invariant Violation
73
+ // and crashes the host app when the peer isn't fully linked (e.g. old-arch
74
+ // RN 0.73 quirk) — even for apps using only the NATIVE paywall path. Deferring
75
+ // the require to render time keeps `import '@billdog.io/react-native'` safe.
76
+ let _WebView;
77
+ function loadWebView() {
78
+ var _a;
79
+ if (_WebView === undefined) {
80
+ try {
81
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
82
+ _WebView = (_a = require('react-native-webview').default) !== null && _a !== void 0 ? _a : null;
83
+ }
84
+ catch {
85
+ _WebView = null;
86
+ }
87
+ }
88
+ return _WebView;
89
+ }
90
+ const LocalizationResolver_1 = require("./LocalizationResolver");
91
+ const BillDog_1 = require("./BillDog");
92
+ const WebViewPaywall = ({ paywallIdentifier, apiKey, customerId, modal = true, visible = true, locale, onReady, onPurchase, onRestore, onDismiss, onOpenUrl, onTrackEvent, onError, onExecuteAction, }) => {
93
+ const webViewRef = (0, react_1.useRef)(null);
94
+ const [isLoading, setIsLoading] = (0, react_1.useState)(true);
95
+ const [errorState, setErrorState] = (0, react_1.useState)(null);
96
+ // Resolve the effective locale once per render-input change. Precedence
97
+ // mirrors Android `WebViewPaywallActivity.effectiveLocale()`:
98
+ // explicit prop > runtime override > device locale > "en".
99
+ const effectiveLocale = react_1.default.useMemo(() => (locale === null || locale === void 0 ? void 0 : locale.trim()) || LocalizationResolver_1.LocalizationResolver.getEffectiveLocale(), [locale]);
100
+ // Build the renderer URL once per identifier/customer/locale change.
101
+ // `locale` is seeded as a query param so the renderer resolves the
102
+ // correct language on first paint (no flash of base-locale text) —
103
+ // the seed-before-load half of the Android bridge contract.
104
+ const rendererUrl = react_1.default.useMemo(() => {
105
+ const base = BillDogConfiguration_1.BillDogConfiguration.resolveEndpoint('render-paywall');
106
+ const params = new URLSearchParams({
107
+ paywall_identifier: paywallIdentifier,
108
+ api_key: apiKey,
109
+ });
110
+ if (customerId)
111
+ params.set('customer_id', customerId);
112
+ if (effectiveLocale)
113
+ params.set('locale', effectiveLocale);
114
+ return `${base}?${params.toString()}`;
115
+ }, [paywallIdentifier, apiKey, customerId, effectiveLocale]);
116
+ // Reset state when the identifier changes (consumer may swap paywalls).
117
+ (0, react_1.useEffect)(() => {
118
+ setIsLoading(true);
119
+ setErrorState(null);
120
+ }, [paywallIdentifier]);
121
+ /**
122
+ * Push `config:locale` into the renderer via a canonical `state_set`
123
+ * envelope. Mirrors Android `WebViewPaywallActivity.sendLocaleUpdate`
124
+ * (kt:1103-1120) — the renderer's inbound bridge (`window.billdog.receive`)
125
+ * routes `state_set` into `GlobalStateStore`, which `useLocalization`
126
+ * subscribes to. Tolerates both bridge globals (`window.billdog` and the
127
+ * older `window.paywallBridge`).
128
+ */
129
+ const sendLocaleUpdate = (0, react_1.useCallback)((loc) => {
130
+ if (!webViewRef.current || !loc)
131
+ return;
132
+ const envelope = JSON.stringify({
133
+ version: 1,
134
+ type: 'state_set',
135
+ payload: { key: 'config:locale', value: loc },
136
+ });
137
+ const js = `(function(){
138
+ try {
139
+ if (window.billdog && window.billdog.receive) {
140
+ window.billdog.receive(${JSON.stringify(envelope)});
141
+ } else if (window.paywallBridge && window.paywallBridge.setState) {
142
+ window.paywallBridge.setState('config:locale', ${JSON.stringify(loc)});
143
+ }
144
+ } catch (e) {}
145
+ })(); true;`;
146
+ webViewRef.current.injectJavaScript(js);
147
+ }, []);
148
+ const handleMessage = (0, react_1.useCallback)((event) => {
149
+ var _a, _b, _c, _d, _e, _f;
150
+ let message;
151
+ try {
152
+ message = JSON.parse(event.nativeEvent.data);
153
+ }
154
+ catch (parseErr) {
155
+ const err = parseErr instanceof Error ? parseErr : new Error(String(parseErr));
156
+ onError === null || onError === void 0 ? void 0 : onError(err);
157
+ return;
158
+ }
159
+ // Validate envelope. Older renderer builds (pre-protocol-unification)
160
+ // may post flat objects without the `protocol` field; tolerate both.
161
+ const type = (_a = message === null || message === void 0 ? void 0 : message.type) !== null && _a !== void 0 ? _a : '';
162
+ const payload = ((_b = message === null || message === void 0 ? void 0 : message.payload) !== null && _b !== void 0 ? _b : {});
163
+ switch (type) {
164
+ case 'ready':
165
+ setIsLoading(false);
166
+ // Runtime half of the locale bridge: push `config:locale` into
167
+ // the renderer's GlobalStateStore via a `state_set` envelope so
168
+ // the active locale is applied even if the renderer ignored the
169
+ // URL `locale` query param. Mirrors Android
170
+ // `WebViewPaywallActivity.sendLocaleUpdate` (kt:1103-1120).
171
+ sendLocaleUpdate(effectiveLocale);
172
+ onReady === null || onReady === void 0 ? void 0 : onReady();
173
+ break;
174
+ case 'purchase': {
175
+ const productIdentifier = (_d = (_c = payload.productIdentifier) !== null && _c !== void 0 ? _c : payload.product_id) !== null && _d !== void 0 ? _d : '';
176
+ if (productIdentifier)
177
+ onPurchase === null || onPurchase === void 0 ? void 0 : onPurchase(productIdentifier);
178
+ break;
179
+ }
180
+ case 'restore':
181
+ onRestore === null || onRestore === void 0 ? void 0 : onRestore();
182
+ break;
183
+ case 'close':
184
+ onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss();
185
+ break;
186
+ case 'open_url': {
187
+ const url = payload.url;
188
+ if (url)
189
+ onOpenUrl === null || onOpenUrl === void 0 ? void 0 : onOpenUrl(url);
190
+ break;
191
+ }
192
+ case 'track': {
193
+ const eventName = payload.eventName;
194
+ const properties = payload.properties;
195
+ if (eventName)
196
+ onTrackEvent === null || onTrackEvent === void 0 ? void 0 : onTrackEvent(eventName, properties);
197
+ break;
198
+ }
199
+ case 'error': {
200
+ const msg = (_f = (_e = payload.message) !== null && _e !== void 0 ? _e : payload.error) !== null && _f !== void 0 ? _f : 'Unknown renderer error';
201
+ const err = new Error(msg);
202
+ setErrorState(err);
203
+ onError === null || onError === void 0 ? void 0 : onError(err);
204
+ break;
205
+ }
206
+ case 'execute_action': {
207
+ const paywallId = payload.paywallId;
208
+ const componentId = payload.componentId;
209
+ const actionType = payload.actionType;
210
+ const idempotencyKey = payload.idempotencyKey;
211
+ if (componentId && actionType) {
212
+ const executePromise = onExecuteAction
213
+ ? onExecuteAction(paywallId !== null && paywallId !== void 0 ? paywallId : null, componentId, actionType, idempotencyKey !== null && idempotencyKey !== void 0 ? idempotencyKey : null)
214
+ : BillDog_1.BillDog.executeAction(paywallId !== null && paywallId !== void 0 ? paywallId : null, componentId, actionType, idempotencyKey !== null && idempotencyKey !== void 0 ? idempotencyKey : null);
215
+ executePromise
216
+ .then((result) => {
217
+ const resultObj = {
218
+ actionType,
219
+ componentId,
220
+ success: true,
221
+ data: result,
222
+ idempotencyKey: idempotencyKey !== null && idempotencyKey !== void 0 ? idempotencyKey : null,
223
+ };
224
+ if (webViewRef.current) {
225
+ const js = `window.dispatchEvent(new CustomEvent('billdog:execute_action_result', { detail: ${JSON.stringify(resultObj)} })); true;`;
226
+ webViewRef.current.injectJavaScript(js);
227
+ }
228
+ })
229
+ .catch((err) => {
230
+ const resultObj = {
231
+ actionType,
232
+ componentId,
233
+ success: false,
234
+ error: err.message || 'Action execution failed',
235
+ idempotencyKey: idempotencyKey !== null && idempotencyKey !== void 0 ? idempotencyKey : null,
236
+ };
237
+ if (webViewRef.current) {
238
+ const js = `window.dispatchEvent(new CustomEvent('billdog:execute_action_result', { detail: ${JSON.stringify(resultObj)} })); true;`;
239
+ webViewRef.current.injectJavaScript(js);
240
+ }
241
+ });
242
+ }
243
+ break;
244
+ }
245
+ case 'state_changed':
246
+ // No-op — exposed for state-driven flows; consumer can hook
247
+ // via a future onStateChange prop if needed.
248
+ break;
249
+ default:
250
+ // Unknown message types are logged for debugging but don't
251
+ // surface as errors — the protocol may add new types over time.
252
+ if (__DEV__) {
253
+ // eslint-disable-next-line no-console
254
+ console.log('[WebViewPaywall] unknown message type:', type, payload);
255
+ }
256
+ }
257
+ }, [
258
+ effectiveLocale,
259
+ sendLocaleUpdate,
260
+ onReady,
261
+ onPurchase,
262
+ onRestore,
263
+ onDismiss,
264
+ onOpenUrl,
265
+ onTrackEvent,
266
+ onError,
267
+ onExecuteAction,
268
+ ]);
269
+ /**
270
+ * Public method for the consumer to push updated state into the
271
+ * renderer (e.g. after entitlement change). Mirrors the
272
+ * `paywallBridge.setState(...)` global exposed by the renderer in
273
+ * native-SDK mode.
274
+ */
275
+ const injectState = (0, react_1.useCallback)((key, value) => {
276
+ if (!webViewRef.current)
277
+ return;
278
+ const js = `window.paywallBridge && window.paywallBridge.setState && window.paywallBridge.setState(${JSON.stringify(key)}, ${JSON.stringify(value)}); true;`;
279
+ webViewRef.current.injectJavaScript(js);
280
+ }, []);
281
+ // Surface the method via a forwardRef-style imperative handle could
282
+ // be added; for the MVP we keep the API prop-only.
283
+ void injectState;
284
+ const WebViewComponent = loadWebView();
285
+ const content = (<react_native_1.View style={styles.container}>
286
+ {isLoading && !errorState && (<react_native_1.View style={styles.loadingContainer}>
287
+ <react_native_1.ActivityIndicator size="large"/>
288
+ </react_native_1.View>)}
289
+ {errorState && (<react_native_1.View style={styles.errorContainer}>
290
+ <react_native_1.Text style={styles.errorText}>Failed to load paywall</react_native_1.Text>
291
+ <react_native_1.Text style={styles.errorDetails}>{errorState.message}</react_native_1.Text>
292
+ </react_native_1.View>)}
293
+ {!errorState && !WebViewComponent && (<react_native_1.View style={styles.errorContainer}>
294
+ <react_native_1.Text style={styles.errorText}>WebView unavailable</react_native_1.Text>
295
+ <react_native_1.Text style={styles.errorDetails}>
296
+ react-native-webview is not linked. Use the native paywall path or add the peer dependency.
297
+ </react_native_1.Text>
298
+ </react_native_1.View>)}
299
+ {!errorState && WebViewComponent && (<WebViewComponent ref={webViewRef} source={{ uri: rendererUrl }} onMessage={handleMessage} onError={(syntheticEvent) => {
300
+ var _a;
301
+ const { nativeEvent } = syntheticEvent;
302
+ const err = new Error((_a = nativeEvent.description) !== null && _a !== void 0 ? _a : 'WebView load error');
303
+ setErrorState(err);
304
+ onError === null || onError === void 0 ? void 0 : onError(err);
305
+ }} onHttpError={(syntheticEvent) => {
306
+ const { nativeEvent } = syntheticEvent;
307
+ const err = new Error(`WebView HTTP ${nativeEvent.statusCode}`);
308
+ setErrorState(err);
309
+ onError === null || onError === void 0 ? void 0 : onError(err);
310
+ }} style={styles.webView} javaScriptEnabled domStorageEnabled scrollEnabled showsVerticalScrollIndicator={false}
311
+ // The renderer manages its own viewport; don't intercept taps.
312
+ originWhitelist={['*']}/>)}
313
+ </react_native_1.View>);
314
+ if (modal) {
315
+ return (<react_native_1.Modal visible={visible} animationType="slide" onRequestClose={() => onDismiss === null || onDismiss === void 0 ? void 0 : onDismiss()}>
316
+ {content}
317
+ </react_native_1.Modal>);
318
+ }
319
+ return content;
320
+ };
321
+ exports.WebViewPaywall = WebViewPaywall;
322
+ const styles = react_native_1.StyleSheet.create({
323
+ container: {
324
+ flex: 1,
325
+ backgroundColor: '#fff',
326
+ },
327
+ webView: {
328
+ flex: 1,
329
+ backgroundColor: 'transparent',
330
+ },
331
+ loadingContainer: {
332
+ position: 'absolute',
333
+ top: 0,
334
+ left: 0,
335
+ right: 0,
336
+ bottom: 0,
337
+ justifyContent: 'center',
338
+ alignItems: 'center',
339
+ backgroundColor: 'rgba(255, 255, 255, 0.95)',
340
+ zIndex: 1,
341
+ },
342
+ errorContainer: {
343
+ flex: 1,
344
+ justifyContent: 'center',
345
+ alignItems: 'center',
346
+ padding: 24,
347
+ },
348
+ errorText: {
349
+ fontSize: 18,
350
+ fontWeight: 'bold',
351
+ marginBottom: 8,
352
+ color: '#333',
353
+ },
354
+ errorDetails: {
355
+ fontSize: 13,
356
+ color: '#666',
357
+ textAlign: 'center',
358
+ },
359
+ });
360
+ exports.default = exports.WebViewPaywall;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Shared Animation Preset Definitions
3
+ * Platform-agnostic animation configurations that can be executed on any SDK
4
+ */
5
+ export interface AnimationKeyframe {
6
+ offset: number;
7
+ opacity?: number;
8
+ scale?: number;
9
+ scaleX?: number;
10
+ scaleY?: number;
11
+ translateX?: number | string;
12
+ translateY?: number | string;
13
+ rotate?: number;
14
+ skewX?: number;
15
+ skewY?: number;
16
+ }
17
+ export interface AnimationPresetConfig {
18
+ name: string;
19
+ category: 'enter' | 'exit' | 'loop' | 'attention' | 'interaction';
20
+ keyframes: AnimationKeyframe[];
21
+ defaultDuration: number;
22
+ defaultDelay: number;
23
+ defaultEasing: EasingType;
24
+ defaultIterations: number;
25
+ defaultDirection: AnimationDirection;
26
+ description: string;
27
+ }
28
+ export type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring';
29
+ export type AnimationDirection = 'normal' | 'reverse' | 'alternate' | 'alternate-reverse';
30
+ /**
31
+ * Animation Presets - Shared across all SDKs
32
+ */
33
+ export declare const ANIMATION_PRESETS: Record<string, AnimationPresetConfig>;
34
+ /**
35
+ * Get preset by name
36
+ */
37
+ export declare function getAnimationPreset(name: string): AnimationPresetConfig | undefined;
38
+ /**
39
+ * Get all presets by category
40
+ */
41
+ export declare function getPresetsByCategory(category: AnimationPresetConfig['category']): AnimationPresetConfig[];
42
+ /**
43
+ * List all available preset names
44
+ */
45
+ export declare function getAvailablePresetNames(): string[];
46
+ /**
47
+ * Easing cubic-bezier mappings for CSS/platform conversion
48
+ */
49
+ export declare const EASING_CURVES: Record<EasingType, [number, number, number, number]>;