@tryheliumai/paywall-sdk-react-native 0.2.22 → 3.0.3
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/PaywallSdkReactNative.podspec +2 -2
- package/ios/HeliumSwiftInterface.swift +90 -76
- package/ios/RCTHeliumBridge.m +1 -0
- package/lib/commonjs/handlers/revenuecat.js +1 -1
- package/lib/commonjs/handlers/revenuecat.js.map +1 -1
- package/lib/commonjs/index.js +0 -18
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-interface.js +81 -165
- package/lib/commonjs/native-interface.js.map +1 -1
- package/lib/commonjs/types.js +4 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/handlers/revenuecat.js +1 -1
- package/lib/module/handlers/revenuecat.js.map +1 -1
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-interface.js +81 -161
- package/lib/module/native-interface.js.map +1 -1
- package/lib/module/types.js +4 -0
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/handlers/revenuecat.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +2 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/native-interface.d.ts +2 -21
- package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +102 -3
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/handlers/revenuecat.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +2 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/native-interface.d.ts +2 -21
- package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +102 -3
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/handlers/revenuecat.ts +0 -1
- package/src/index.ts +9 -3
- package/src/native-interface.tsx +105 -172
- package/src/types.ts +142 -5
|
@@ -11,12 +11,12 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios => "
|
|
14
|
+
s.platforms = { :ios => "15.0" }
|
|
15
15
|
s.source = { :git => "https://github.com/cloudcaptainai/helium-react-native-sdk.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
|
-
s.dependency 'Helium', '
|
|
19
|
+
s.dependency 'Helium', '3.0.3'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -138,14 +138,24 @@ class BridgingPaywallDelegate: HeliumPaywallDelegate {
|
|
|
138
138
|
error: nil
|
|
139
139
|
))
|
|
140
140
|
}
|
|
141
|
-
|
|
142
|
-
func
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
141
|
+
|
|
142
|
+
func onPaywallEvent(_ event: any HeliumEvent) {
|
|
143
|
+
var eventDict = event.toDictionary()
|
|
144
|
+
// Add deprecated fields for backwards compatibility
|
|
145
|
+
if let paywallName = eventDict["paywallName"] {
|
|
146
|
+
eventDict["paywallTemplateName"] = paywallName
|
|
147
|
+
}
|
|
148
|
+
if let error = eventDict["error"] {
|
|
149
|
+
eventDict["errorDescription"] = error
|
|
150
|
+
}
|
|
151
|
+
if let productId = eventDict["productId"] {
|
|
152
|
+
eventDict["productKey"] = productId
|
|
153
|
+
}
|
|
154
|
+
bridge?.sendEvent(
|
|
155
|
+
withName: "helium_paywall_event",
|
|
156
|
+
body: eventDict
|
|
157
|
+
)
|
|
158
|
+
}
|
|
149
159
|
|
|
150
160
|
func getCustomVariableValues() -> [String: Any?] {
|
|
151
161
|
return [:];
|
|
@@ -169,7 +179,8 @@ class HeliumBridge: RCTEventEmitter {
|
|
|
169
179
|
"helium_make_purchase",
|
|
170
180
|
"helium_restore_purchases",
|
|
171
181
|
"helium_download_state_changed",
|
|
172
|
-
"helium_fallback_visibility"
|
|
182
|
+
"helium_fallback_visibility",
|
|
183
|
+
"paywallEventHandlers"
|
|
173
184
|
]
|
|
174
185
|
}
|
|
175
186
|
|
|
@@ -183,89 +194,67 @@ class HeliumBridge: RCTEventEmitter {
|
|
|
183
194
|
_ config: NSDictionary,
|
|
184
195
|
customVariableValues: NSDictionary
|
|
185
196
|
) {
|
|
186
|
-
guard let apiKey = config["apiKey"] as? String
|
|
187
|
-
let viewTag = config["fallbackPaywall"] as? NSNumber else {
|
|
197
|
+
guard let apiKey = config["apiKey"] as? String else {
|
|
188
198
|
return
|
|
189
199
|
}
|
|
190
200
|
|
|
191
|
-
let triggers = config["triggers"] as? [String]
|
|
192
201
|
let customUserId = config["customUserId"] as? String
|
|
193
202
|
let customAPIEndpoint = config["customAPIEndpoint"] as? String
|
|
194
203
|
let customUserTraits = config["customUserTraits"] as? [String: Any]
|
|
195
204
|
let revenueCatAppUserId = config["revenueCatAppUserId"] as? String
|
|
196
|
-
let fallbackPaywallPerTriggerTags = config["fallbackPaywallPerTrigger"] as? [String: NSNumber]
|
|
197
205
|
let fallbackBundleURLString = config["fallbackBundleUrlString"] as? String
|
|
198
206
|
let fallbackBundleString = config["fallbackBundleString"] as? String
|
|
199
207
|
|
|
208
|
+
let paywallLoadingConfig = config["paywallLoadingConfig"] as? [String: Any]
|
|
209
|
+
let useLoadingState = paywallLoadingConfig?["useLoadingState"] as? Bool ?? true
|
|
210
|
+
let loadingBudget = paywallLoadingConfig?["loadingBudget"] as? TimeInterval ?? 2.0
|
|
211
|
+
|
|
212
|
+
var perTriggerLoadingConfig: [String: TriggerLoadingConfig]? = nil
|
|
213
|
+
if let perTriggerDict = paywallLoadingConfig?["perTriggerLoadingConfig"] as? [String: [String: Any]] {
|
|
214
|
+
var triggerConfigs: [String: TriggerLoadingConfig] = [:]
|
|
215
|
+
for (trigger, config) in perTriggerDict {
|
|
216
|
+
triggerConfigs[trigger] = TriggerLoadingConfig(
|
|
217
|
+
useLoadingState: config["useLoadingState"] as? Bool,
|
|
218
|
+
loadingBudget: config["loadingBudget"] as? TimeInterval
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
perTriggerLoadingConfig = triggerConfigs
|
|
222
|
+
}
|
|
223
|
+
|
|
200
224
|
self.bridgingDelegate = BridgingPaywallDelegate(
|
|
201
225
|
bridge: self
|
|
202
226
|
)
|
|
203
227
|
|
|
204
|
-
//
|
|
205
|
-
|
|
206
|
-
let startTime = CFAbsoluteTimeGetCurrent()
|
|
207
|
-
|
|
208
|
-
guard let bridge = self.bridge,
|
|
209
|
-
let fallbackPaywall = bridge.uiManager.view(forReactTag: viewTag) else {
|
|
210
|
-
return
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
let wrappedView = UIViewWrapper(view: fallbackPaywall)
|
|
215
|
-
|
|
216
|
-
// Process fallbackPaywallPerTrigger if provided
|
|
217
|
-
var triggerViewsMap: [String: any View]? = nil
|
|
218
|
-
|
|
219
|
-
if let fallbackPaywallPerTriggerTags = fallbackPaywallPerTriggerTags {
|
|
220
|
-
triggerViewsMap = [:]
|
|
221
|
-
|
|
222
|
-
for (trigger, tag) in fallbackPaywallPerTriggerTags {
|
|
223
|
-
if let view = bridge.uiManager.view(forReactTag: tag) {
|
|
224
|
-
// Initially hide trigger-specific fallback views
|
|
225
|
-
triggerViewsMap?[trigger] = UIViewWrapper(view: view)
|
|
226
|
-
} else {
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Handle fallback bundle - either as URL string or JSON string
|
|
232
|
-
var fallbackBundleURL: URL? = nil
|
|
233
|
-
|
|
234
|
-
if let urlString = fallbackBundleURLString {
|
|
235
|
-
fallbackBundleURL = URL(string: urlString)
|
|
236
|
-
} else if let jsonString = fallbackBundleString {
|
|
237
|
-
// expo-file-system wasn't available, write the string to a temp file
|
|
238
|
-
let tempURL = FileManager.default.temporaryDirectory
|
|
239
|
-
.appendingPathComponent("helium-fallback.json")
|
|
228
|
+
// Handle fallback bundle - either as URL string or JSON string
|
|
229
|
+
var fallbackBundleURL: URL? = nil
|
|
240
230
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
231
|
+
if let urlString = fallbackBundleURLString {
|
|
232
|
+
fallbackBundleURL = URL(string: urlString)
|
|
233
|
+
} else if let jsonString = fallbackBundleString {
|
|
234
|
+
// expo-file-system wasn't available, write the string to a temp file
|
|
235
|
+
let tempURL = FileManager.default.temporaryDirectory
|
|
236
|
+
.appendingPathComponent("helium-fallback.json")
|
|
246
237
|
|
|
247
|
-
let
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
DispatchQueue.global().async {
|
|
251
|
-
let initStartTime = CFAbsoluteTimeGetCurrent()
|
|
252
|
-
|
|
253
|
-
Helium.shared.initialize(
|
|
254
|
-
apiKey: apiKey,
|
|
255
|
-
heliumPaywallDelegate: self.bridgingDelegate!,
|
|
256
|
-
fallbackPaywall: wrappedView,
|
|
257
|
-
triggers: triggers,
|
|
258
|
-
customUserId: customUserId,
|
|
259
|
-
customAPIEndpoint: customAPIEndpoint,
|
|
260
|
-
customUserTraits: HeliumUserTraits(customUserTraits ?? [:]),
|
|
261
|
-
revenueCatAppUserId: revenueCatAppUserId,
|
|
262
|
-
fallbackBundleURL: fallbackBundleURL,
|
|
263
|
-
fallbackPaywallPerTrigger: triggerViewsMap
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
let initTime = CFAbsoluteTimeGetCurrent() - initStartTime
|
|
238
|
+
if let data = jsonString.data(using: .utf8) {
|
|
239
|
+
try? data.write(to: tempURL)
|
|
240
|
+
fallbackBundleURL = tempURL
|
|
267
241
|
}
|
|
268
242
|
}
|
|
243
|
+
|
|
244
|
+
Helium.shared.initialize(
|
|
245
|
+
apiKey: apiKey,
|
|
246
|
+
heliumPaywallDelegate: self.bridgingDelegate!,
|
|
247
|
+
fallbackConfig: HeliumFallbackConfig.withMultipleFallbacks(
|
|
248
|
+
fallbackBundle: fallbackBundleURL,
|
|
249
|
+
useLoadingState: useLoadingState,
|
|
250
|
+
loadingBudget: loadingBudget,
|
|
251
|
+
perTriggerLoadingConfig: perTriggerLoadingConfig
|
|
252
|
+
),
|
|
253
|
+
customUserId: customUserId,
|
|
254
|
+
customAPIEndpoint: customAPIEndpoint,
|
|
255
|
+
customUserTraits: HeliumUserTraits(customUserTraits ?? [:]),
|
|
256
|
+
revenueCatAppUserId: revenueCatAppUserId
|
|
257
|
+
)
|
|
269
258
|
}
|
|
270
259
|
|
|
271
260
|
@objc
|
|
@@ -297,9 +286,27 @@ class HeliumBridge: RCTEventEmitter {
|
|
|
297
286
|
|
|
298
287
|
@objc
|
|
299
288
|
public func presentUpsell(
|
|
300
|
-
_ trigger: String
|
|
289
|
+
_ trigger: String,
|
|
290
|
+
customPaywallTraits: [String: Any]?
|
|
301
291
|
) {
|
|
302
|
-
Helium.shared.presentUpsell(
|
|
292
|
+
Helium.shared.presentUpsell(
|
|
293
|
+
trigger: trigger,
|
|
294
|
+
eventHandlers: PaywallEventHandlers.withHandlers(
|
|
295
|
+
onOpen: { [weak self] event in
|
|
296
|
+
self?.sendEvent(withName: "paywallEventHandlers", body: event.toDictionary())
|
|
297
|
+
},
|
|
298
|
+
onClose: { [weak self] event in
|
|
299
|
+
self?.sendEvent(withName: "paywallEventHandlers", body: event.toDictionary())
|
|
300
|
+
},
|
|
301
|
+
onDismissed: { [weak self] event in
|
|
302
|
+
self?.sendEvent(withName: "paywallEventHandlers", body: event.toDictionary())
|
|
303
|
+
},
|
|
304
|
+
onPurchaseSucceeded: { [weak self] event in
|
|
305
|
+
self?.sendEvent(withName: "paywallEventHandlers", body: event.toDictionary())
|
|
306
|
+
}
|
|
307
|
+
),
|
|
308
|
+
customPaywallTraits: customPaywallTraits
|
|
309
|
+
);
|
|
303
310
|
}
|
|
304
311
|
|
|
305
312
|
@objc
|
|
@@ -363,10 +370,17 @@ class HeliumBridge: RCTEventEmitter {
|
|
|
363
370
|
let canPresent: Bool
|
|
364
371
|
let reason: String
|
|
365
372
|
|
|
373
|
+
let useLoading = Helium.shared.loadingStateEnabledFor(trigger: trigger)
|
|
374
|
+
let downloadInProgress = Helium.shared.getDownloadStatus() == .inProgress
|
|
375
|
+
|
|
366
376
|
if paywallsLoaded && hasTrigger {
|
|
367
377
|
// Normal case - paywall is ready
|
|
368
378
|
canPresent = true
|
|
369
379
|
reason = "ready"
|
|
380
|
+
} else if downloadInProgress && useLoading {
|
|
381
|
+
// Loading case - paywall still downloading
|
|
382
|
+
canPresent = true
|
|
383
|
+
reason = "loading"
|
|
370
384
|
} else if HeliumFallbackViewManager.shared.getFallbackInfo(trigger: trigger) != nil {
|
|
371
385
|
// Fallback is available (via downloaded bundle)
|
|
372
386
|
canPresent = true
|
package/ios/RCTHeliumBridge.m
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNativePurchases","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createRevenueCatPurchaseConfig","config","rcHandler","RevenueCatHeliumHandler","apiKey","makePurchase","bind","restorePurchases","productIdToPackageMapping","isMappingInitialized","initializationPromise","rcProductToPackageMapping","constructor","Purchases","configure","initializePackageMapping","offerings","getOfferings","allOfferings","all","offering","values","availablePackages","forEach","pkg","product","identifier","error","ensureMappingInitialized","productId","rcProduct","rcProducts","getProducts","length","undefined","customerInfo","purchasePackage","purchaseStoreProduct","status","isActive","isProductActive","purchasesError","code","PURCHASES_ERROR_CODE","PAYMENT_PENDING_ERROR","Promise","resolve","updateListener","updatedCustomerInfo","clearTimeout","timeoutId","removeCustomerInfoUpdateListener","setTimeout","addCustomerInfoUpdateListener","PURCHASE_CANCELLED_ERROR","message","entitlements","active","some","entitlement","productIdentifier","activeSubscriptions","includes","allPurchasedProductIdentifiers","keys","exports"],"sourceRoot":"../../../src","sources":["handlers/revenuecat.ts"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGgC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAUhC;AACO,SAASW,8BAA8BA,CAACC,MAE9C,EAAwB;EACrB,MAAMC,SAAS,GAAG,IAAIC,uBAAuB,CAACF,MAAM,EAAEG,MAAM,CAAC;EAC7D,OAAO;IACLA,MAAM,EAAEH,MAAM,EAAEG,MAAM;IACtBC,YAAY,EAAEH,SAAS,CAACG,YAAY,CAACC,IAAI,CAACJ,SAAS,CAAC;IACpDK,gBAAgB,EAAEL,SAAS,CAACK,gBAAgB,CAACD,IAAI,CAACJ,SAAS;EAC7D,CAAC;AACL;AAEO,MAAMC,uBAAuB,CAAC;EACzBK,yBAAyB,GAAqC,CAAC,CAAC;EAChEC,oBAAoB,GAAY,KAAK;EACrCC,qBAAqB,GAAyB,IAAI;EAElDC,yBAAyB,GAA0C,CAAC,CAAC;EAE7EC,WAAWA,CAACR,MAAe,EAAE;IACzB,IAAIA,MAAM,EAAE;MACRS,6BAAS,CAACC,SAAS,CAAC;QAAEV;MAAO,CAAC,CAAC;IACnC
|
|
1
|
+
{"version":3,"names":["_reactNativePurchases","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","createRevenueCatPurchaseConfig","config","rcHandler","RevenueCatHeliumHandler","apiKey","makePurchase","bind","restorePurchases","productIdToPackageMapping","isMappingInitialized","initializationPromise","rcProductToPackageMapping","constructor","Purchases","configure","initializePackageMapping","offerings","getOfferings","allOfferings","all","offering","values","availablePackages","forEach","pkg","product","identifier","error","ensureMappingInitialized","productId","rcProduct","rcProducts","getProducts","length","undefined","customerInfo","purchasePackage","purchaseStoreProduct","status","isActive","isProductActive","purchasesError","code","PURCHASES_ERROR_CODE","PAYMENT_PENDING_ERROR","Promise","resolve","updateListener","updatedCustomerInfo","clearTimeout","timeoutId","removeCustomerInfoUpdateListener","setTimeout","addCustomerInfoUpdateListener","PURCHASE_CANCELLED_ERROR","message","entitlements","active","some","entitlement","productIdentifier","activeSubscriptions","includes","allPurchasedProductIdentifiers","keys","exports"],"sourceRoot":"../../../src","sources":["handlers/revenuecat.ts"],"mappings":";;;;;;;AAAA,IAAAA,qBAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGgC,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN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
|
|
9
9
|
return _nativeInterface.HELIUM_CTA_NAMES;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "HeliumProvider", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _nativeInterface.HeliumProvider;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
12
|
Object.defineProperty(exports, "NativeHeliumUpsellView", {
|
|
19
13
|
enumerable: true,
|
|
20
14
|
get: function () {
|
|
21
15
|
return _nativeInterface.NativeHeliumUpsellView;
|
|
22
16
|
}
|
|
23
17
|
});
|
|
24
|
-
Object.defineProperty(exports, "UpsellView", {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () {
|
|
27
|
-
return _nativeInterface.UpsellView;
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
18
|
Object.defineProperty(exports, "createCustomPurchaseConfig", {
|
|
31
19
|
enumerable: true,
|
|
32
20
|
get: function () {
|
|
@@ -69,12 +57,6 @@ Object.defineProperty(exports, "presentUpsell", {
|
|
|
69
57
|
return _nativeInterface.presentUpsell;
|
|
70
58
|
}
|
|
71
59
|
});
|
|
72
|
-
Object.defineProperty(exports, "useHelium", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
get: function () {
|
|
75
|
-
return _nativeInterface.useHelium;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
60
|
var _types = require("./types.js");
|
|
79
61
|
var _nativeInterface = require("./native-interface.js");
|
|
80
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_types","require","_nativeInterface"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_types","require","_nativeInterface"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -3,125 +3,31 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.presentUpsell = exports.initialize = exports.hideUpsell = exports.hideAllUpsells = exports.handleDeepLink = exports.getPaywallInfo = exports.getDownloadStatus = exports.NativeHeliumUpsellView = exports.HELIUM_CTA_NAMES = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
8
|
const {
|
|
13
9
|
HeliumBridge
|
|
14
10
|
} = _reactNative.NativeModules;
|
|
15
11
|
const heliumEventEmitter = new _reactNative.NativeEventEmitter(HeliumBridge);
|
|
16
12
|
|
|
17
13
|
// Register the native component once at module level
|
|
18
|
-
// This ensures it's only registered once, even during hot reloading
|
|
19
14
|
const NativeHeliumUpsellView = exports.NativeHeliumUpsellView = (0, _reactNative.requireNativeComponent)('HeliumUpsellView');
|
|
20
|
-
|
|
15
|
+
|
|
21
16
|
// Add a flag to track if initialization has occurred
|
|
22
17
|
let isInitialized = false;
|
|
23
|
-
// Add a promise to track when the provider is mounted
|
|
24
|
-
let providerMountedPromise;
|
|
25
|
-
let resolveProviderMounted;
|
|
26
|
-
|
|
27
|
-
// Initialize the promise
|
|
28
|
-
providerMountedPromise = new Promise(resolve => {
|
|
29
|
-
resolveProviderMounted = resolve;
|
|
30
|
-
// If provider is already mounted, resolve immediately
|
|
31
|
-
if (isProviderMounted) {
|
|
32
|
-
resolve();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
18
|
// Add module-level download status tracking
|
|
37
19
|
let globalDownloadStatus = 'notStarted';
|
|
38
20
|
const getDownloadStatus = () => globalDownloadStatus;
|
|
39
|
-
|
|
40
|
-
// Create a context for the download status
|
|
41
21
|
exports.getDownloadStatus = getDownloadStatus;
|
|
42
|
-
const HeliumContext = /*#__PURE__*/(0, _react.createContext)(undefined);
|
|
43
|
-
|
|
44
|
-
// Update the setter ref to also update global status
|
|
45
|
-
let setDownloadStatusRef = null;
|
|
46
22
|
const updateDownloadStatus = status => {
|
|
47
23
|
globalDownloadStatus = status;
|
|
48
|
-
setDownloadStatusRef?.(status);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// Hook to use the Helium context
|
|
52
|
-
const useHelium = () => {
|
|
53
|
-
const context = (0, _react.useContext)(HeliumContext);
|
|
54
|
-
if (!context) {
|
|
55
|
-
throw new Error('useHelium must be used within a HeliumProvider');
|
|
56
|
-
}
|
|
57
|
-
return context;
|
|
58
24
|
};
|
|
59
|
-
exports.useHelium = useHelium;
|
|
60
|
-
// Create a ref to store the fallback view reference
|
|
61
|
-
const fallbackRef = /*#__PURE__*/(0, _react.createRef)();
|
|
62
|
-
// Store a reference to the fallback view component
|
|
63
|
-
let FallbackViewComponent = null;
|
|
64
|
-
|
|
65
|
-
// Provider component to be rendered at the app root
|
|
66
|
-
const HeliumProvider = ({
|
|
67
|
-
children,
|
|
68
|
-
fallbackView
|
|
69
|
-
}) => {
|
|
70
|
-
// TODO - deprecate fallbackView (and maybe HeliumProvider too?)
|
|
71
|
-
if (fallbackView) {
|
|
72
|
-
console.warn('HeliumProvider: fallbackView is deprecated. Use onFallback passed to presentUpsell instead.');
|
|
73
|
-
}
|
|
74
|
-
const FallbackView = () => null;
|
|
75
|
-
// Add state for download status
|
|
76
|
-
const [downloadStatus, setDownloadStatus] = (0, _react.useState)('notStarted');
|
|
77
|
-
|
|
78
|
-
// Store the setter in the ref so it can be accessed outside of components
|
|
79
|
-
(0, _react.useEffect)(() => {
|
|
80
|
-
setDownloadStatusRef = setDownloadStatus;
|
|
81
|
-
// Store the fallback view component for later use
|
|
82
|
-
FallbackViewComponent = FallbackView;
|
|
83
|
-
}, [setDownloadStatus, FallbackView]);
|
|
84
|
-
(0, _react.useEffect)(() => {
|
|
85
|
-
isProviderMounted = true;
|
|
86
|
-
// Resolve the promise when the provider is mounted
|
|
87
|
-
resolveProviderMounted();
|
|
88
|
-
return () => {
|
|
89
|
-
isProviderMounted = false;
|
|
90
|
-
setDownloadStatusRef = null;
|
|
91
|
-
};
|
|
92
|
-
}, []);
|
|
93
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(HeliumContext.Provider, {
|
|
94
|
-
value: {
|
|
95
|
-
downloadStatus,
|
|
96
|
-
setDownloadStatus
|
|
97
|
-
},
|
|
98
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
99
|
-
ref: fallbackRef,
|
|
100
|
-
collapsable: false,
|
|
101
|
-
style: {
|
|
102
|
-
display: 'none'
|
|
103
|
-
},
|
|
104
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FallbackView, {})
|
|
105
|
-
}), children]
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Update initialize to accept full config
|
|
110
|
-
exports.HeliumProvider = HeliumProvider;
|
|
111
25
|
const initialize = async config => {
|
|
112
26
|
// Early return if already initialized
|
|
113
27
|
if (isInitialized) {
|
|
28
|
+
console.log('[Helium] Already initialized, skipping...');
|
|
114
29
|
return;
|
|
115
30
|
}
|
|
116
|
-
|
|
117
|
-
// Wait for the provider to be mounted if it's not already
|
|
118
|
-
if (!isProviderMounted) {
|
|
119
|
-
await providerMountedPromise;
|
|
120
|
-
}
|
|
121
|
-
const viewTag = (0, _reactNative.findNodeHandle)(fallbackRef.current);
|
|
122
|
-
if (!viewTag) {
|
|
123
|
-
throw new Error('Failed to get fallback view reference. Make sure HeliumProvider is mounted with a fallback view.');
|
|
124
|
-
}
|
|
125
31
|
const purchaseHandler = {
|
|
126
32
|
makePurchase: config.purchaseConfig.makePurchase,
|
|
127
33
|
restorePurchases: config.purchaseConfig.restorePurchases
|
|
@@ -130,6 +36,12 @@ const initialize = async config => {
|
|
|
130
36
|
// Update download status to inProgress
|
|
131
37
|
updateDownloadStatus('inProgress');
|
|
132
38
|
|
|
39
|
+
// Ensure these don't get added more than once
|
|
40
|
+
heliumEventEmitter.removeAllListeners('helium_paywall_event');
|
|
41
|
+
heliumEventEmitter.removeAllListeners('paywallEventHandlers');
|
|
42
|
+
heliumEventEmitter.removeAllListeners('helium_make_purchase');
|
|
43
|
+
heliumEventEmitter.removeAllListeners('helium_restore_purchases');
|
|
44
|
+
|
|
133
45
|
// Set up event listeners
|
|
134
46
|
heliumEventEmitter.addListener('helium_paywall_event', event => {
|
|
135
47
|
// Handle download status events
|
|
@@ -138,29 +50,16 @@ const initialize = async config => {
|
|
|
138
50
|
} else if (event.type === 'paywallsDownloadError') {
|
|
139
51
|
updateDownloadStatus('failed');
|
|
140
52
|
}
|
|
141
|
-
// Handle fallback view visibility
|
|
142
|
-
else if (event.type === 'paywallOpen' && event.paywallTemplateName === 'Fallback') {
|
|
143
|
-
if (fallbackRef.current) {
|
|
144
|
-
fallbackRef.current.setNativeProps({
|
|
145
|
-
style: {
|
|
146
|
-
display: 'flex'
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
} else if (event.type === 'paywallClose' && event.paywallTemplateName === 'Fallback') {
|
|
151
|
-
if (fallbackRef.current) {
|
|
152
|
-
fallbackRef.current.setNativeProps({
|
|
153
|
-
style: {
|
|
154
|
-
display: 'none'
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
53
|
|
|
160
54
|
// Forward all events to the callback provided in config
|
|
161
55
|
config.onHeliumPaywallEvent(event);
|
|
162
56
|
});
|
|
163
57
|
|
|
58
|
+
// Set up paywall event handlers listener
|
|
59
|
+
heliumEventEmitter.addListener('paywallEventHandlers', event => {
|
|
60
|
+
callPaywallEventHandlers(event);
|
|
61
|
+
});
|
|
62
|
+
|
|
164
63
|
// Set up purchase event listener using the determined handler
|
|
165
64
|
heliumEventEmitter.addListener('helium_make_purchase', async event => {
|
|
166
65
|
const result = await purchaseHandler.makePurchase(event.productId);
|
|
@@ -197,25 +96,26 @@ const initialize = async config => {
|
|
|
197
96
|
}
|
|
198
97
|
HeliumBridge.initialize({
|
|
199
98
|
apiKey: config.apiKey,
|
|
200
|
-
fallbackPaywall: viewTag,
|
|
201
|
-
triggers: config.triggers || [],
|
|
202
99
|
customUserId: config.customUserId || null,
|
|
203
100
|
customAPIEndpoint: config.customAPIEndpoint || null,
|
|
204
101
|
customUserTraits: config.customUserTraits == null ? {} : config.customUserTraits,
|
|
205
102
|
revenueCatAppUserId: config.revenueCatAppUserId,
|
|
206
103
|
fallbackBundleUrlString: fallbackBundleUrlString,
|
|
207
|
-
fallbackBundleString: fallbackBundleString
|
|
104
|
+
fallbackBundleString: fallbackBundleString,
|
|
105
|
+
paywallLoadingConfig: config.paywallLoadingConfig
|
|
208
106
|
}, {});
|
|
209
107
|
|
|
210
108
|
// Mark as initialized after successful initialization
|
|
211
109
|
isInitialized = true;
|
|
212
110
|
};
|
|
213
|
-
|
|
214
|
-
// Update the other methods to be synchronous
|
|
215
111
|
exports.initialize = initialize;
|
|
112
|
+
let paywallEventHandlers;
|
|
113
|
+
let presentOnFallback;
|
|
216
114
|
const presentUpsell = ({
|
|
217
115
|
triggerName,
|
|
218
|
-
onFallback
|
|
116
|
+
onFallback,
|
|
117
|
+
eventHandlers,
|
|
118
|
+
customPaywallTraits
|
|
219
119
|
}) => {
|
|
220
120
|
HeliumBridge.canPresentUpsell(triggerName, (canPresent, reason) => {
|
|
221
121
|
if (!canPresent) {
|
|
@@ -225,15 +125,72 @@ const presentUpsell = ({
|
|
|
225
125
|
return;
|
|
226
126
|
}
|
|
227
127
|
try {
|
|
228
|
-
|
|
128
|
+
paywallEventHandlers = eventHandlers;
|
|
129
|
+
presentOnFallback = onFallback;
|
|
130
|
+
HeliumBridge.presentUpsell(triggerName, customPaywallTraits || null);
|
|
229
131
|
} catch (error) {
|
|
230
132
|
console.log('[Helium] Present error', error);
|
|
133
|
+
paywallEventHandlers = undefined;
|
|
134
|
+
presentOnFallback = undefined;
|
|
231
135
|
onFallback?.();
|
|
232
136
|
HeliumBridge.fallbackOpenOrCloseEvent(triggerName, true, 'presented');
|
|
233
137
|
}
|
|
234
138
|
});
|
|
235
139
|
};
|
|
236
140
|
exports.presentUpsell = presentUpsell;
|
|
141
|
+
function callPaywallEventHandlers(event) {
|
|
142
|
+
if (paywallEventHandlers) {
|
|
143
|
+
switch (event.type) {
|
|
144
|
+
case 'paywallOpen':
|
|
145
|
+
paywallEventHandlers?.onOpen?.({
|
|
146
|
+
type: 'paywallOpen',
|
|
147
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
148
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
149
|
+
isSecondTry: event.isSecondTry ?? false,
|
|
150
|
+
viewType: 'presented'
|
|
151
|
+
});
|
|
152
|
+
break;
|
|
153
|
+
case 'paywallClose':
|
|
154
|
+
paywallEventHandlers?.onClose?.({
|
|
155
|
+
type: 'paywallClose',
|
|
156
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
157
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
158
|
+
isSecondTry: event.isSecondTry ?? false
|
|
159
|
+
});
|
|
160
|
+
if (!event.isSecondTry) {
|
|
161
|
+
paywallEventHandlers = undefined;
|
|
162
|
+
}
|
|
163
|
+
presentOnFallback = undefined;
|
|
164
|
+
break;
|
|
165
|
+
case 'paywallDismissed':
|
|
166
|
+
paywallEventHandlers?.onDismissed?.({
|
|
167
|
+
type: 'paywallDismissed',
|
|
168
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
169
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
170
|
+
isSecondTry: event.isSecondTry ?? false
|
|
171
|
+
});
|
|
172
|
+
break;
|
|
173
|
+
case 'purchaseSucceeded':
|
|
174
|
+
paywallEventHandlers?.onPurchaseSucceeded?.({
|
|
175
|
+
type: 'purchaseSucceeded',
|
|
176
|
+
productId: event.productId ?? 'unknown',
|
|
177
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
178
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
179
|
+
isSecondTry: event.isSecondTry ?? false
|
|
180
|
+
});
|
|
181
|
+
break;
|
|
182
|
+
case 'paywallSkipped':
|
|
183
|
+
paywallEventHandlers = undefined;
|
|
184
|
+
presentOnFallback = undefined;
|
|
185
|
+
break;
|
|
186
|
+
case 'paywallOpenFailed':
|
|
187
|
+
paywallEventHandlers = undefined;
|
|
188
|
+
presentOnFallback?.();
|
|
189
|
+
presentOnFallback = undefined;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
237
194
|
const hideUpsell = () => {
|
|
238
195
|
HeliumBridge.hideUpsell();
|
|
239
196
|
};
|
|
@@ -265,53 +222,12 @@ const handleDeepLink = async url => {
|
|
|
265
222
|
console.log('[Helium] Handled deep link:', handled);
|
|
266
223
|
resolve(handled);
|
|
267
224
|
});
|
|
225
|
+
} else {
|
|
226
|
+
resolve(false);
|
|
268
227
|
}
|
|
269
228
|
});
|
|
270
229
|
};
|
|
271
|
-
|
|
272
|
-
// Update the UpsellView component to handle the style prop
|
|
273
230
|
exports.handleDeepLink = handleDeepLink;
|
|
274
|
-
const UpsellView = ({
|
|
275
|
-
trigger,
|
|
276
|
-
fallbackViewProps,
|
|
277
|
-
fallbackViewWrapperStyles
|
|
278
|
-
}) => {
|
|
279
|
-
const {
|
|
280
|
-
downloadStatus
|
|
281
|
-
} = useHelium();
|
|
282
|
-
const showFallback = downloadStatus === 'notStarted' || downloadStatus === 'inProgress' || downloadStatus === 'failed';
|
|
283
|
-
(0, _react.useEffect)(() => {
|
|
284
|
-
if (showFallback && FallbackViewComponent) {
|
|
285
|
-
HeliumBridge.fallbackOpenOrCloseEvent(trigger, true, 'embedded');
|
|
286
|
-
}
|
|
287
|
-
return () => {
|
|
288
|
-
if (showFallback && FallbackViewComponent) {
|
|
289
|
-
HeliumBridge.fallbackOpenOrCloseEvent(trigger, false, 'embedded');
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
}, [showFallback, trigger]);
|
|
293
|
-
|
|
294
|
-
// If download status is notStarted or inProgress, we haven't fully initialized yet
|
|
295
|
-
// In this case, we should render the fallback view
|
|
296
|
-
if (showFallback) {
|
|
297
|
-
// If we have a fallback view component, render it
|
|
298
|
-
if (FallbackViewComponent) {
|
|
299
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
|
|
300
|
-
style: fallbackViewWrapperStyles,
|
|
301
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FallbackViewComponent, {
|
|
302
|
-
...fallbackViewProps
|
|
303
|
-
})
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
// Use NativeHeliumUpsellView directly
|
|
310
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeHeliumUpsellView, {
|
|
311
|
-
trigger: trigger
|
|
312
|
-
});
|
|
313
|
-
};
|
|
314
|
-
exports.UpsellView = UpsellView;
|
|
315
231
|
const HELIUM_CTA_NAMES = exports.HELIUM_CTA_NAMES = {
|
|
316
232
|
SCHEDULE_CALL: 'schedule_call',
|
|
317
233
|
SUBSCRIBE_BUTTON: 'subscribe_button'
|