@rovenue/react-native-sdk 0.23.0 → 0.24.0
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/THIRD_PARTY_NOTICES +1 -1
- package/android/src/main/java/dev/rovenue/sdkrn/RovenueModule.kt +95 -1
- package/dist/chunk-ETC46J2X.js +7 -0
- package/dist/{chunk-JTXT7GEG.js.map → chunk-ETC46J2X.js.map} +1 -1
- package/dist/index.cjs +76 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +104 -6
- package/dist/index.d.ts +104 -6
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/PrivacyInfo.xcprivacy +17 -0
- package/ios/RovenueModule.swift +107 -1
- package/ios/RovenueSdkRn.podspec +31 -8
- package/package.json +1 -1
- package/plugin/build/index.js +4 -3
- package/plugin/build/packageVersion.js +5 -4
- package/plugin/build/withRovenueIos.js +41 -31
- package/dist/chunk-JTXT7GEG.js +0 -7
package/THIRD_PARTY_NOTICES
CHANGED
|
@@ -36,7 +36,7 @@ Glyph data reaches devices (the stamped document, the offline fallback file, and
|
|
|
36
36
|
| Artifact | Where the file ships |
|
|
37
37
|
|---|---|
|
|
38
38
|
| `@rovenue/react-native-sdk`, `@rovenue/web-sdk` (npm) | package root, listed in `files` |
|
|
39
|
-
| `Rovenue` (
|
|
39
|
+
| `Rovenue` (SwiftPM) | package root, copied into the SwiftPM distribution by `generate-swift-dist.sh` |
|
|
40
40
|
| `io.rovenue:sdk` (AAR, Maven) | `META-INF/rovenue/THIRD_PARTY_NOTICES` inside the AAR's `classes.jar` |
|
|
41
41
|
| `rovenue_flutter`, `rovenue_flutter_android`, `rovenue_flutter_ios` (pub) | package root |
|
|
42
42
|
| `librovenue`, `rovenue-funnel-core` (crates.io) | crate root, listed in `include` |
|
|
@@ -13,6 +13,12 @@
|
|
|
13
13
|
|
|
14
14
|
package dev.rovenue.sdkrn
|
|
15
15
|
|
|
16
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelPresentHandlers
|
|
17
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelPresentResult
|
|
18
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelPresentationEnter
|
|
19
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelPresentationOverride
|
|
20
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelPresentationStyle
|
|
21
|
+
import dev.rovenue.sdk.funnelui.presentation.FunnelSheetDetent
|
|
16
22
|
import android.content.Context
|
|
17
23
|
import android.content.pm.PackageManager
|
|
18
24
|
import android.os.Build
|
|
@@ -248,6 +254,21 @@ class RovenueModule : Module() {
|
|
|
248
254
|
throw codedError(e)
|
|
249
255
|
}
|
|
250
256
|
}
|
|
257
|
+
AsyncFunction("preloadPlacement") Coroutine { placementId: String, locale: String? ->
|
|
258
|
+
Rovenue.shared.preloadPlacement(placementId, locale)
|
|
259
|
+
}
|
|
260
|
+
AsyncFunction("presentFunnel") Coroutine { presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: Map<String, Boolean> ->
|
|
261
|
+
val activity = appContext.currentActivity
|
|
262
|
+
if (activity == null) {
|
|
263
|
+
mapOf("result" to "unavailable", "purchased" to false, "reason" to FunnelPresentResult.NO_PRESENTER)
|
|
264
|
+
} else {
|
|
265
|
+
presentFunnelFrom(activity, presentationId, placement, locale, styleJson, callbacks)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
AsyncFunction("resolveFunnelPurchaseRequest") { requestId: String, purchased: Boolean ->
|
|
269
|
+
funnelPurchaseRequests.remove(requestId)?.complete(purchased)
|
|
270
|
+
Unit
|
|
271
|
+
}
|
|
251
272
|
AsyncFunction("purchase") Coroutine { productId: String, productType: String, promotionalOfferId: String?, basePlanId: String?, offerId: String? ->
|
|
252
273
|
// promotionalOfferId is iOS-only (ignored here). basePlanId/offerId select a Play subscription offer.
|
|
253
274
|
// Play Billing needs the foreground Activity to launch the flow.
|
|
@@ -369,7 +390,7 @@ class RovenueModule : Module() {
|
|
|
369
390
|
}
|
|
370
391
|
|
|
371
392
|
// ---------------- Events ----------------
|
|
372
|
-
Events("onChange", "onLog", "onFunnelClaimResolved")
|
|
393
|
+
Events("onChange", "onLog", "onFunnelClaimResolved", "onFunnelPresentEvent")
|
|
373
394
|
|
|
374
395
|
OnStartObserving {
|
|
375
396
|
changesJob = scope.launch {
|
|
@@ -403,6 +424,79 @@ class RovenueModule : Module() {
|
|
|
403
424
|
}
|
|
404
425
|
}
|
|
405
426
|
|
|
427
|
+
// ---- presentFunnel (spec 2026-11-03-funnel-presentation §2a)
|
|
428
|
+
|
|
429
|
+
/** Purchase / restore requests a presented funnel waits on, answered by `resolveFunnelPurchaseRequest`. */
|
|
430
|
+
private val funnelPurchaseRequests = java.util.concurrent.ConcurrentHashMap<String, kotlinx.coroutines.CompletableDeferred<Boolean>>()
|
|
431
|
+
private val funnelRequestSerial = java.util.concurrent.atomic.AtomicLong()
|
|
432
|
+
|
|
433
|
+
private suspend fun askJs(event: Map<String, Any?>): Boolean {
|
|
434
|
+
val requestId = "r${funnelRequestSerial.incrementAndGet()}"
|
|
435
|
+
val answer = kotlinx.coroutines.CompletableDeferred<Boolean>()
|
|
436
|
+
funnelPurchaseRequests[requestId] = answer
|
|
437
|
+
sendEvent("onFunnelPresentEvent", event + ("requestId" to requestId))
|
|
438
|
+
return answer.await()
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
private suspend fun presentFunnelFrom(
|
|
442
|
+
activity: android.app.Activity,
|
|
443
|
+
presentationId: String,
|
|
444
|
+
placement: String,
|
|
445
|
+
locale: String?,
|
|
446
|
+
styleJson: String?,
|
|
447
|
+
callbacks: Map<String, Boolean>,
|
|
448
|
+
): Map<String, Any?> {
|
|
449
|
+
val emit: (Map<String, Any?>) -> Unit = { sendEvent("onFunnelPresentEvent", it + ("presentationId" to presentationId)) }
|
|
450
|
+
val handlers = FunnelPresentHandlers(
|
|
451
|
+
onPurchase = if (callbacks["onPurchase"] == true) {
|
|
452
|
+
{ packageId -> askJs(mapOf("presentationId" to presentationId, "type" to "purchaseRequest", "packageId" to packageId)) }
|
|
453
|
+
} else null,
|
|
454
|
+
onRestore = if (callbacks["onRestore"] == true) {
|
|
455
|
+
{ askJs(mapOf("presentationId" to presentationId, "type" to "restoreRequest")) }
|
|
456
|
+
} else null,
|
|
457
|
+
onPurchaseError = { error -> emit(mapOf("type" to "purchaseError", "error" to errorDto(error))) },
|
|
458
|
+
onUrl = if (callbacks["onUrl"] == true) { url -> emit(mapOf("type" to "url", "url" to url)) } else null,
|
|
459
|
+
onCustomAction = if (callbacks["onCustomAction"] == true) {
|
|
460
|
+
{ id, params -> emit(mapOf("type" to "customAction", "actionId" to id, "paramsJson" to params)) }
|
|
461
|
+
} else null,
|
|
462
|
+
)
|
|
463
|
+
val result = kotlinx.coroutines.withContext(kotlinx.coroutines.Dispatchers.Main) {
|
|
464
|
+
Rovenue.shared.presentFunnel(activity, placement, locale, presentationOverride(styleJson), handlers)
|
|
465
|
+
}
|
|
466
|
+
return mapOf(
|
|
467
|
+
"result" to result.result.wire,
|
|
468
|
+
"purchased" to result.purchased,
|
|
469
|
+
"customerInfo" to result.customerInfo?.let(::dtoFromPurchaseResult),
|
|
470
|
+
"lastError" to result.lastError?.let(::errorDto),
|
|
471
|
+
"reason" to result.reason,
|
|
472
|
+
)
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
private fun errorDto(error: dev.rovenue.sdk.RovenueException): Map<String, Any?> = mapOf(
|
|
476
|
+
"kind" to error.kind.name,
|
|
477
|
+
"message" to error.message,
|
|
478
|
+
"serverCode" to error.serverCode,
|
|
479
|
+
"httpStatus" to error.httpStatus,
|
|
480
|
+
"retryable" to error.isRetryable,
|
|
481
|
+
).filterValues { it != null }
|
|
482
|
+
|
|
483
|
+
/** The JS `style` object (a partial presentation, JSON). */
|
|
484
|
+
private fun presentationOverride(json: String?): FunnelPresentationOverride? {
|
|
485
|
+
val o = json?.let { runCatching { org.json.JSONObject(it) }.getOrNull() } ?: return null
|
|
486
|
+
fun str(key: String) = if (o.has(key) && !o.isNull(key)) o.getString(key) else null
|
|
487
|
+
fun bool(key: String) = if (o.has(key) && !o.isNull(key)) o.getBoolean(key) else null
|
|
488
|
+
val detents = o.optJSONArray("detents")?.let { array ->
|
|
489
|
+
(0 until array.length()).mapNotNull { i -> FunnelSheetDetent.entries.firstOrNull { it.name.equals(array.getString(i), ignoreCase = true) } }
|
|
490
|
+
}
|
|
491
|
+
return FunnelPresentationOverride(
|
|
492
|
+
style = str("style")?.let { wire -> FunnelPresentationStyle.entries.firstOrNull { it.name.replace("_", "").equals(wire, ignoreCase = true) } },
|
|
493
|
+
enter = str("enter")?.let { wire -> FunnelPresentationEnter.entries.firstOrNull { it.name.equals(wire, ignoreCase = true) } },
|
|
494
|
+
detents = detents,
|
|
495
|
+
dismissible = bool("dismissible"),
|
|
496
|
+
closeOnPurchase = bool("closeOnPurchase"),
|
|
497
|
+
)
|
|
498
|
+
}
|
|
499
|
+
|
|
406
500
|
private fun dtoFromExperimentAssignment(a: ExperimentAssignment): Map<String, Any?> = mapOf(
|
|
407
501
|
"experimentId" to a.experimentId,
|
|
408
502
|
"key" to a.key,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/** This package's version, as published — the same string `package.json` carries. */\nexport const SDK_VERSION = \"0.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/** This package's version, as published — the same string `package.json` carries. */\nexport const SDK_VERSION = \"0.24.0\";\n"],"mappings":";AACO,IAAM,cAAc;","names":[]}
|
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,7 @@ __export(index_exports, {
|
|
|
28
28
|
SDK_VERSION: () => SDK_VERSION,
|
|
29
29
|
extractFunnelToken: () => extractFunnelToken,
|
|
30
30
|
mapNativeError: () => mapNativeError,
|
|
31
|
+
presentFunnel: () => presentFunnel,
|
|
31
32
|
serializeEnvelope: () => serializeEnvelope,
|
|
32
33
|
stripUndefined: () => stripUndefined,
|
|
33
34
|
useCurrentUser: () => useCurrentUser,
|
|
@@ -42,7 +43,7 @@ __export(index_exports, {
|
|
|
42
43
|
module.exports = __toCommonJS(index_exports);
|
|
43
44
|
|
|
44
45
|
// src/version.ts
|
|
45
|
-
var SDK_VERSION = "0.
|
|
46
|
+
var SDK_VERSION = "0.24.0";
|
|
46
47
|
|
|
47
48
|
// src/events.ts
|
|
48
49
|
var EVENT_WIRE_VERSION = 1;
|
|
@@ -709,10 +710,81 @@ async function call6(fn) {
|
|
|
709
710
|
throw fromNativeError(e);
|
|
710
711
|
}
|
|
711
712
|
}
|
|
713
|
+
async function preloadPlacement(placementId, locale) {
|
|
714
|
+
try {
|
|
715
|
+
await getNative().preloadPlacement(placementId, locale ?? null);
|
|
716
|
+
} catch {
|
|
717
|
+
}
|
|
718
|
+
}
|
|
712
719
|
async function setFallbackPlacements(json) {
|
|
713
720
|
return call6(() => getNative().setFallbackPlacements(json));
|
|
714
721
|
}
|
|
715
722
|
|
|
723
|
+
// src/api/present-funnel.ts
|
|
724
|
+
var FUNNEL_PRESENT_EVENT = "onFunnelPresentEvent";
|
|
725
|
+
var presentationSerial = 0;
|
|
726
|
+
function toError(dto) {
|
|
727
|
+
const mapped = fromNativeError(Object.assign(new Error(dto.message), { code: dto.kind }));
|
|
728
|
+
if (mapped instanceof RovenueError) {
|
|
729
|
+
return new RovenueError(mapped.kind, dto.message, {
|
|
730
|
+
serverCode: dto.serverCode ?? void 0,
|
|
731
|
+
httpStatus: dto.httpStatus ?? void 0,
|
|
732
|
+
retryable: dto.retryable
|
|
733
|
+
});
|
|
734
|
+
}
|
|
735
|
+
return new RovenueError("Internal", dto.message);
|
|
736
|
+
}
|
|
737
|
+
async function presentFunnel(options) {
|
|
738
|
+
const native = getNative();
|
|
739
|
+
presentationSerial += 1;
|
|
740
|
+
const presentationId = `p${Date.now().toString(36)}${presentationSerial}`;
|
|
741
|
+
const subscription3 = getEmitter().addListener(FUNNEL_PRESENT_EVENT, (event) => {
|
|
742
|
+
if (event.presentationId !== presentationId) return;
|
|
743
|
+
switch (event.type) {
|
|
744
|
+
case "purchaseRequest":
|
|
745
|
+
case "restoreRequest": {
|
|
746
|
+
const run = event.type === "purchaseRequest" ? options.onPurchase?.(event.packageId) : options.onRestore?.();
|
|
747
|
+
Promise.resolve(run).then((answer) => native.resolveFunnelPurchaseRequest(event.requestId, Boolean(answer?.purchased))).catch(() => native.resolveFunnelPurchaseRequest(event.requestId, false));
|
|
748
|
+
break;
|
|
749
|
+
}
|
|
750
|
+
case "purchaseError":
|
|
751
|
+
options.onPurchaseError?.(toError(event.error));
|
|
752
|
+
break;
|
|
753
|
+
case "url":
|
|
754
|
+
options.onUrl?.(event.url);
|
|
755
|
+
break;
|
|
756
|
+
case "customAction":
|
|
757
|
+
options.onCustomAction?.({ actionId: event.actionId, paramsJson: event.paramsJson });
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
try {
|
|
762
|
+
const dto = await native.presentFunnel(
|
|
763
|
+
presentationId,
|
|
764
|
+
options.placement,
|
|
765
|
+
options.locale ?? null,
|
|
766
|
+
options.style ? JSON.stringify(options.style) : null,
|
|
767
|
+
{
|
|
768
|
+
onPurchase: Boolean(options.onPurchase),
|
|
769
|
+
onRestore: Boolean(options.onRestore),
|
|
770
|
+
onUrl: Boolean(options.onUrl),
|
|
771
|
+
onCustomAction: Boolean(options.onCustomAction)
|
|
772
|
+
}
|
|
773
|
+
);
|
|
774
|
+
return {
|
|
775
|
+
result: dto.result,
|
|
776
|
+
purchased: dto.purchased,
|
|
777
|
+
...dto.customerInfo ? { customerInfo: dto.customerInfo } : {},
|
|
778
|
+
...dto.lastError ? { lastError: toError(dto.lastError) } : {},
|
|
779
|
+
...dto.reason ? { reason: dto.reason } : {}
|
|
780
|
+
};
|
|
781
|
+
} catch (e) {
|
|
782
|
+
throw fromNativeError(e);
|
|
783
|
+
} finally {
|
|
784
|
+
subscription3.remove();
|
|
785
|
+
}
|
|
786
|
+
}
|
|
787
|
+
|
|
716
788
|
// src/api/events.ts
|
|
717
789
|
function isoNow2() {
|
|
718
790
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1011,6 +1083,8 @@ var Rovenue = {
|
|
|
1011
1083
|
purchase,
|
|
1012
1084
|
restorePurchases,
|
|
1013
1085
|
setFallbackPlacements,
|
|
1086
|
+
preloadPlacement,
|
|
1087
|
+
presentFunnel,
|
|
1014
1088
|
track,
|
|
1015
1089
|
refreshRemoteConfig,
|
|
1016
1090
|
getRemoteConfig,
|
|
@@ -1064,6 +1138,7 @@ var Rovenue = {
|
|
|
1064
1138
|
SDK_VERSION,
|
|
1065
1139
|
extractFunnelToken,
|
|
1066
1140
|
mapNativeError,
|
|
1141
|
+
presentFunnel,
|
|
1067
1142
|
serializeEnvelope,
|
|
1068
1143
|
stripUndefined,
|
|
1069
1144
|
useCurrentUser,
|