@virex-tech/paywallo-sdk 1.1.0 → 1.1.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/android/src/main/java/com/paywallo/sdk/PaywalloWebView.kt +45 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloWebViewManager.kt +1 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +427 -140
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +498 -202
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloWebView.h +1 -0
- package/ios/PaywalloWebView.m +20 -0
- package/ios/PaywalloWebViewManager.m +1 -0
- package/ios/PaywalloWebViewModule.h +1 -0
- package/ios/PaywalloWebViewModule.m +8 -1
- package/package.json +1 -1
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
package com.paywallo.sdk
|
|
2
2
|
|
|
3
3
|
import android.annotation.SuppressLint
|
|
4
|
+
import android.annotation.TargetApi
|
|
5
|
+
import android.os.Build
|
|
4
6
|
import android.webkit.JavascriptInterface
|
|
5
7
|
import android.webkit.WebChromeClient
|
|
8
|
+
import android.webkit.WebResourceError
|
|
9
|
+
import android.webkit.WebResourceRequest
|
|
10
|
+
import android.webkit.WebResourceResponse
|
|
6
11
|
import android.webkit.WebSettings
|
|
7
12
|
import android.webkit.WebView
|
|
8
13
|
import android.webkit.WebViewClient
|
|
9
14
|
import com.facebook.react.bridge.Arguments
|
|
10
15
|
import com.facebook.react.bridge.ReactContext
|
|
11
16
|
import com.facebook.react.uimanager.events.RCTEventEmitter
|
|
17
|
+
import org.json.JSONObject
|
|
12
18
|
|
|
13
19
|
@SuppressLint("SetJavaScriptEnabled", "ViewConstructor")
|
|
14
20
|
class PaywalloWebView(context: ReactContext) : WebView(context) {
|
|
@@ -33,6 +39,45 @@ class PaywalloWebView(context: ReactContext) : WebView(context) {
|
|
|
33
39
|
super.onPageFinished(view, url)
|
|
34
40
|
dispatchEvent("onLoadEnd", null)
|
|
35
41
|
}
|
|
42
|
+
|
|
43
|
+
@TargetApi(Build.VERSION_CODES.M)
|
|
44
|
+
override fun onReceivedError(
|
|
45
|
+
view: WebView?,
|
|
46
|
+
request: WebResourceRequest?,
|
|
47
|
+
error: WebResourceError?
|
|
48
|
+
) {
|
|
49
|
+
super.onReceivedError(view, request, error)
|
|
50
|
+
if (request?.isForMainFrame == true) {
|
|
51
|
+
val payload = JSONObject().apply {
|
|
52
|
+
put("type", "error")
|
|
53
|
+
put("payload", JSONObject().apply {
|
|
54
|
+
put("code", error?.errorCode ?: -1)
|
|
55
|
+
put("description", error?.description?.toString() ?: "Unknown error")
|
|
56
|
+
put("url", request.url?.toString() ?: "")
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
dispatchEvent("onError", payload.toString())
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
override fun onReceivedHttpError(
|
|
64
|
+
view: WebView?,
|
|
65
|
+
request: WebResourceRequest?,
|
|
66
|
+
errorResponse: WebResourceResponse?
|
|
67
|
+
) {
|
|
68
|
+
super.onReceivedHttpError(view, request, errorResponse)
|
|
69
|
+
if (request?.isForMainFrame == true) {
|
|
70
|
+
val payload = JSONObject().apply {
|
|
71
|
+
put("type", "error")
|
|
72
|
+
put("payload", JSONObject().apply {
|
|
73
|
+
put("code", errorResponse?.statusCode ?: -1)
|
|
74
|
+
put("description", errorResponse?.reasonPhrase ?: "HTTP error")
|
|
75
|
+
put("url", request.url?.toString() ?: "")
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
dispatchEvent("onError", payload.toString())
|
|
79
|
+
}
|
|
80
|
+
}
|
|
36
81
|
}
|
|
37
82
|
|
|
38
83
|
webChromeClient = WebChromeClient()
|
|
@@ -34,6 +34,7 @@ class PaywalloWebViewManager(private val reactContext: ReactApplicationContext)
|
|
|
34
34
|
return MapBuilder.builder<String, Any>()
|
|
35
35
|
.put("onMessage", MapBuilder.of("registrationName", "onMessage"))
|
|
36
36
|
.put("onLoadEnd", MapBuilder.of("registrationName", "onLoadEnd"))
|
|
37
|
+
.put("onError", MapBuilder.of("registrationName", "onError"))
|
|
37
38
|
.build()
|
|
38
39
|
}
|
|
39
40
|
|
package/dist/index.d.mts
CHANGED
|
@@ -137,6 +137,7 @@ interface CampaignResult {
|
|
|
137
137
|
campaignId?: string;
|
|
138
138
|
variantKey?: string;
|
|
139
139
|
error?: Error;
|
|
140
|
+
skippedReason?: "subscriber";
|
|
140
141
|
}
|
|
141
142
|
interface CampaignPresentOptions {
|
|
142
143
|
placement: string;
|
|
@@ -485,7 +486,17 @@ declare class ApiClient {
|
|
|
485
486
|
getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
486
487
|
validatePurchase(platform: "ios" | "android", receipt: string, productId: string, transactionId: string, priceLocal: number, currency: string, country: string, distinctId?: string, paywallPlacement?: string, variantKey?: string): Promise<ValidatePurchaseResponse>;
|
|
487
488
|
getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
|
|
489
|
+
evaluateFlags(keys: string[], distinctId: string): Promise<Record<string, string | null>>;
|
|
488
490
|
getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
|
|
491
|
+
/**
|
|
492
|
+
* Reads a flag variant from cache layers only — no network call.
|
|
493
|
+
* Checks in-memory cache first, then SecureStorage.
|
|
494
|
+
* Returns null when both layers miss.
|
|
495
|
+
*/
|
|
496
|
+
getVariantFromCache(flagKey: string, distinctId: string): Promise<FlagVariant | null>;
|
|
497
|
+
private static readonly FLAG_MAX_AGE_MS;
|
|
498
|
+
private readFlagFromStorage;
|
|
499
|
+
private writeFlagToStorage;
|
|
489
500
|
/**
|
|
490
501
|
* POST with offline queue fallback. Enqueues when offline or on network failure.
|
|
491
502
|
* Throws only when offlineQueueEnabled is false and the request fails.
|
|
@@ -813,7 +824,9 @@ interface IPaywalloClient {
|
|
|
813
824
|
init(config: PaywalloInitConfig): Promise<void>;
|
|
814
825
|
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
815
826
|
track(eventName: string, options?: TrackEventOptions): Promise<void>;
|
|
827
|
+
getVariantCached(flagKey: string, defaultValue?: string): Promise<FlagVariant>;
|
|
816
828
|
getVariant(flagKey: string): Promise<FlagVariant>;
|
|
829
|
+
evaluateFlags(keys: string[]): Promise<Record<string, string | null>>;
|
|
817
830
|
getConditionalFlag(flagKey: string, context?: Partial<ConditionalFlagContext>): Promise<boolean>;
|
|
818
831
|
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
819
832
|
presentPaywall(placement: string): Promise<PaywallResult>;
|
package/dist/index.d.ts
CHANGED
|
@@ -137,6 +137,7 @@ interface CampaignResult {
|
|
|
137
137
|
campaignId?: string;
|
|
138
138
|
variantKey?: string;
|
|
139
139
|
error?: Error;
|
|
140
|
+
skippedReason?: "subscriber";
|
|
140
141
|
}
|
|
141
142
|
interface CampaignPresentOptions {
|
|
142
143
|
placement: string;
|
|
@@ -485,7 +486,17 @@ declare class ApiClient {
|
|
|
485
486
|
getCampaign(placement: string, distinctId: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
486
487
|
validatePurchase(platform: "ios" | "android", receipt: string, productId: string, transactionId: string, priceLocal: number, currency: string, country: string, distinctId?: string, paywallPlacement?: string, variantKey?: string): Promise<ValidatePurchaseResponse>;
|
|
487
488
|
getSubscriptionStatus(distinctId: string): Promise<SubscriptionStatusResponse$1>;
|
|
489
|
+
evaluateFlags(keys: string[], distinctId: string): Promise<Record<string, string | null>>;
|
|
488
490
|
getConditionalFlag(flagKey: string, context: ConditionalFlagContext): Promise<ConditionalFlagResult>;
|
|
491
|
+
/**
|
|
492
|
+
* Reads a flag variant from cache layers only — no network call.
|
|
493
|
+
* Checks in-memory cache first, then SecureStorage.
|
|
494
|
+
* Returns null when both layers miss.
|
|
495
|
+
*/
|
|
496
|
+
getVariantFromCache(flagKey: string, distinctId: string): Promise<FlagVariant | null>;
|
|
497
|
+
private static readonly FLAG_MAX_AGE_MS;
|
|
498
|
+
private readFlagFromStorage;
|
|
499
|
+
private writeFlagToStorage;
|
|
489
500
|
/**
|
|
490
501
|
* POST with offline queue fallback. Enqueues when offline or on network failure.
|
|
491
502
|
* Throws only when offlineQueueEnabled is false and the request fails.
|
|
@@ -813,7 +824,9 @@ interface IPaywalloClient {
|
|
|
813
824
|
init(config: PaywalloInitConfig): Promise<void>;
|
|
814
825
|
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
815
826
|
track(eventName: string, options?: TrackEventOptions): Promise<void>;
|
|
827
|
+
getVariantCached(flagKey: string, defaultValue?: string): Promise<FlagVariant>;
|
|
816
828
|
getVariant(flagKey: string): Promise<FlagVariant>;
|
|
829
|
+
evaluateFlags(keys: string[]): Promise<Record<string, string | null>>;
|
|
817
830
|
getConditionalFlag(flagKey: string, context?: Partial<ConditionalFlagContext>): Promise<boolean>;
|
|
818
831
|
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
819
832
|
presentPaywall(placement: string): Promise<PaywallResult>;
|