@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.
@@ -65,6 +65,18 @@
65
65
  <array><string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string></array>
66
66
  </dict>
67
67
  </array>
68
+ <!--
69
+ Required-reason APIs the SDK's own code references (statically linked into
70
+ the app, so only this manifest can answer for them). Audited against every
71
+ shipped binary by e2e/live/privacy-manifest-audit.mjs.
72
+ FileTimestamp C617.1: stat/fstat/lstat in the bundled SQLite, Rust std and
73
+ tokio, on files in the app container (the cache database); the funnel
74
+ image disk cache reads and sets modification dates under Caches/.
75
+ DiskSpace E174.1: statfs/fstatfs in the bundled SQLite, which reads the
76
+ volume of the database file when opening it to decide how to write to it
77
+ (read-only mount, msdos/exfat, network file systems). Nothing derived
78
+ leaves the device.
79
+ -->
68
80
  <key>NSPrivacyAccessedAPITypes</key>
69
81
  <array>
70
82
  <dict>
@@ -72,6 +84,11 @@
72
84
  <key>NSPrivacyAccessedAPITypeReasons</key>
73
85
  <array><string>C617.1</string></array>
74
86
  </dict>
87
+ <dict>
88
+ <key>NSPrivacyAccessedAPIType</key><string>NSPrivacyAccessedAPICategoryDiskSpace</string>
89
+ <key>NSPrivacyAccessedAPITypeReasons</key>
90
+ <array><string>E174.1</string></array>
91
+ </dict>
75
92
  </array>
76
93
  </dict>
77
94
  </plist>
@@ -289,6 +289,21 @@ public class RovenueModule: Module {
289
289
  throw RovenueCodedError(e)
290
290
  }
291
291
  }
292
+ AsyncFunction("preloadPlacement") { (placementId: String, locale: String?) in
293
+ guard #available(iOS 15.0, macOS 12.0, *) else { return }
294
+ await Rovenue.shared.preloadPlacement(placementId, locale: locale)
295
+ }
296
+ AsyncFunction("presentFunnel") { (presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]) -> [String: Any?] in
297
+ guard #available(iOS 15.0, *) else {
298
+ return ["result": "unavailable", "purchased": false, "reason": FunnelPresentResult.noPresenter]
299
+ }
300
+ return await self.presentFunnel(
301
+ presentationId: presentationId, placement: placement, locale: locale,
302
+ styleJson: styleJson, callbacks: callbacks)
303
+ }
304
+ AsyncFunction("resolveFunnelPurchaseRequest") { (requestId: String, purchased: Bool) in
305
+ await FunnelPurchaseRequests.shared.resolve(requestId, purchased: purchased)
306
+ }
292
307
  AsyncFunction("purchase") { (productId: String, productType: String, promotionalOfferId: String?, basePlanId: String?, offerId: String?) -> [String: Any?] in
293
308
  // basePlanId/offerId select a Play subscription offer on Android; ignored on iOS.
294
309
  guard #available(iOS 15.0, macOS 12.0, *) else {
@@ -437,7 +452,7 @@ public class RovenueModule: Module {
437
452
  }
438
453
 
439
454
  // ---------------- Events ----------------
440
- Events("onChange", "onLog", "onFunnelClaimResolved")
455
+ Events("onChange", "onLog", "onFunnelClaimResolved", "onFunnelPresentEvent")
441
456
 
442
457
  OnStartObserving {
443
458
  self.changesTask = Task { [weak self] in
@@ -747,3 +762,94 @@ public class RovenueModule: Module {
747
762
  }
748
763
  }
749
764
  }
765
+
766
+ // MARK: - presentFunnel (spec 2026-11-03-funnel-presentation §2a)
767
+
768
+ /// Purchase / restore requests a presented funnel is waiting on, answered
769
+ /// from JS by `resolveFunnelPurchaseRequest`. Main-actor isolated: no lock.
770
+ @MainActor
771
+ final class FunnelPurchaseRequests {
772
+ static let shared = FunnelPurchaseRequests()
773
+ private var pending: [String: CheckedContinuation<Bool, Never>] = [:]
774
+ private var serial = 0
775
+
776
+ /// Emits a request through `send` and waits for JS's answer.
777
+ func ask(_ send: (String) -> Void) async -> Bool {
778
+ serial += 1
779
+ let requestId = "r\(serial)"
780
+ return await withCheckedContinuation { continuation in
781
+ pending[requestId] = continuation
782
+ send(requestId)
783
+ }
784
+ }
785
+
786
+ func resolve(_ requestId: String, purchased: Bool) {
787
+ pending.removeValue(forKey: requestId)?.resume(returning: purchased)
788
+ }
789
+ }
790
+
791
+ extension RovenueModule {
792
+ @available(iOS 15.0, *)
793
+ @MainActor
794
+ func presentFunnel(
795
+ presentationId: String, placement: String, locale: String?, styleJson: String?, callbacks: [String: Bool]
796
+ ) async -> [String: Any?] {
797
+ let emit: ([String: Any?]) -> Void = { [weak self] body in
798
+ var payload = body
799
+ payload["presentationId"] = presentationId
800
+ self?.sendEvent("onFunnelPresentEvent", payload as [String: Any])
801
+ }
802
+ var handlers = FunnelPresentHandlers()
803
+ if callbacks["onPurchase"] == true {
804
+ handlers.onPurchase = { packageId in
805
+ await FunnelPurchaseRequests.shared.ask { id in
806
+ emit(["type": "purchaseRequest", "requestId": id, "packageId": packageId])
807
+ }
808
+ }
809
+ }
810
+ if callbacks["onRestore"] == true {
811
+ handlers.onRestore = {
812
+ await FunnelPurchaseRequests.shared.ask { id in emit(["type": "restoreRequest", "requestId": id]) }
813
+ }
814
+ }
815
+ handlers.onPurchaseError = { error in emit(["type": "purchaseError", "error": Self.errorDTO(error)]) }
816
+ if callbacks["onUrl"] == true {
817
+ handlers.onUrl = { url in emit(["type": "url", "url": url]) }
818
+ }
819
+ if callbacks["onCustomAction"] == true {
820
+ handlers.onCustomAction = { id, params in emit(["type": "customAction", "actionId": id, "paramsJson": params]) }
821
+ }
822
+ let result = await Rovenue.shared.presentFunnel(
823
+ placement: placement, locale: locale, style: Self.presentationOverride(styleJson), handlers: handlers)
824
+ return [
825
+ "result": result.result.rawValue,
826
+ "purchased": result.purchased,
827
+ "customerInfo": result.customerInfo.map(Self.dtoFromPurchaseResult),
828
+ "lastError": result.lastError.map(Self.errorDTO),
829
+ "reason": result.reason,
830
+ ]
831
+ }
832
+
833
+ static func errorDTO(_ error: RovenueError) -> [String: Any?] {
834
+ [
835
+ "kind": String(describing: error.kind),
836
+ "message": error.message,
837
+ "serverCode": error.serverCode,
838
+ "httpStatus": error.httpStatus,
839
+ "retryable": error.isRetryable,
840
+ ]
841
+ }
842
+
843
+ /// The JS `style` object (a partial presentation, JSON).
844
+ static func presentationOverride(_ json: String?) -> FunnelPresentationOverride? {
845
+ guard let json, let data = json.data(using: .utf8),
846
+ let object = (try? JSONSerialization.jsonObject(with: data)) as? [String: Any]
847
+ else { return nil }
848
+ return FunnelPresentationOverride(
849
+ style: (object["style"] as? String).flatMap(FunnelPresentationStyle.init(rawValue:)),
850
+ enter: (object["enter"] as? String).flatMap(FunnelPresentationEnter.init(rawValue:)),
851
+ detents: (object["detents"] as? [String])?.compactMap(FunnelSheetDetent.init(rawValue:)),
852
+ dismissible: object["dismissible"] as? Bool,
853
+ closeOnPurchase: object["closeOnPurchase"] as? Bool)
854
+ }
855
+ }
@@ -2,6 +2,16 @@ require 'json'
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
4
 
5
+ # The Swift façade ships through SwiftPM only — the public mirror below, at
6
+ # the release tag equal to this package's version. There is no `Rovenue` pod:
7
+ # CocoaPods Trunk went read-only, so nothing here may resolve through it.
8
+ rovenue_swift_package_url = 'https://github.com/broverse/rovenue-ios'
9
+ rovenue_swift_product = 'Rovenue'
10
+ # Podfile.properties.json key the Expo config plugin's monorepo mode
11
+ # (`rovenueSwiftPath`) writes: a local SwiftPM package path, relative to the
12
+ # app's ios/ directory, used instead of the mirror.
13
+ rovenue_swift_path_property = 'rovenue.swiftPackagePath'
14
+
5
15
  Pod::Spec.new do |s|
6
16
  s.name = 'RovenueSdkRn'
7
17
  s.version = package['version']
@@ -20,13 +30,26 @@ Pod::Spec.new do |s|
20
30
  # Expo Modules runtime — provided by the consuming app via autolinking
21
31
  s.dependency 'ExpoModulesCore'
22
32
 
23
- # Swift façade. Pinned exactly: the bridge is compiled against this façade's
24
- # generated types.
33
+ # Swift façade, as a Swift package attached to this pod's target by React
34
+ # Native's own `spm_dependency` (react-native/scripts/react_native_pods.rb,
35
+ # which every RN >= 0.75 Podfile requires before it evaluates any podspec).
36
+ # `react_native_post_install` wires the package into the Pods project, so
37
+ # the app's Podfile needs no line for it.
25
38
  #
26
- # No xcconfig import-path overrides here. The `Rovenue` pod vendors
27
- # RovenueFFI.xcframework, which carries uniffi's module map inside each
28
- # slice, so the transitive `RovenueFFI` Clang module resolves without any
29
- # target needing a path into this monorepo. That path is precisely what made
30
- # this pod impossible to consume from npm.
31
- s.dependency 'Rovenue', package['version']
39
+ # Pinned exactly: the bridge is compiled against this façade's generated
40
+ # types, and the two release in lockstep.
41
+ unless defined?(spm_dependency)
42
+ raise "RovenueSdkRn: React Native's `spm_dependency` is not loaded. The Podfile " \
43
+ "must require react-native/scripts/react_native_pods (React Native >= 0.75)."
44
+ end
45
+
46
+ installation_root = Pod::Config.instance.installation_root.to_s
47
+ properties_file = File.join(installation_root, 'Podfile.properties.json')
48
+ properties = File.exist?(properties_file) ? JSON.parse(File.read(properties_file)) : {}
49
+ local_package = properties[rovenue_swift_path_property]
50
+
51
+ spm_dependency(s,
52
+ url: local_package ? File.expand_path(local_package, installation_root) : rovenue_swift_package_url,
53
+ requirement: { kind: 'exactVersion', version: package['version'] },
54
+ products: [rovenue_swift_product])
32
55
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rovenue/react-native-sdk",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Rovenue React Native SDK — subscriptions, entitlements, virtual currencies and funnels for Expo / React Native apps.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://rovenue.io",
@@ -2,9 +2,10 @@
2
2
  // @rovenue/react-native-sdk — Expo config plugin entry.
3
3
  //
4
4
  // Used by consumers via `"plugins": ["@rovenue/react-native-sdk"]` in
5
- // their app.json. At prebuild time we patch the consumer's iOS Podfile
6
- // and Android settings.gradle/app build.gradle to wire the M3 Swift +
7
- // M4 Kotlin façades.
5
+ // their app.json. On iOS the bridge pod pulls the Swift façade itself (a
6
+ // SwiftPM dependency declared in ios/RovenueSdkRn.podspec), so the app's
7
+ // Podfile is left alone; on Android we patch settings.gradle/app
8
+ // build.gradle to wire the Kotlin façade.
8
9
  Object.defineProperty(exports, "__esModule", { value: true });
9
10
  const withRovenueIos_1 = require("./withRovenueIos");
10
11
  const withRovenueAndroid_1 = require("./withRovenueAndroid");
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  // The version of THIS package, read from its own package.json at prebuild time.
3
3
  //
4
- // Both platforms pin the native façade to it exactly: the iOS Podfile gets
5
- // `pod 'Rovenue', '<v>'` and the Android app gets `io.rovenue:sdk:<v>`. All
6
- // five façades release in lockstep at one version (version.test.ts), so the
7
- // RN package's own version IS the native SDK version to resolve.
4
+ // Both platforms pin the native façade to it exactly: the Android app gets
5
+ // `io.rovenue:sdk:<v>`, and on iOS RovenueSdkRn.podspec reads the same
6
+ // package.json to pin the `Rovenue` Swift package. All five façades release
7
+ // in lockstep at one version (version.test.ts), so the RN package's own
8
+ // version IS the native SDK version to resolve.
8
9
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
10
  if (k2 === undefined) k2 = k;
10
11
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -1,19 +1,22 @@
1
1
  "use strict";
2
- // withRovenueIos — Expo config plugin mod that injects the Rovenue pod
3
- // into the consumer's Podfile.
2
+ // withRovenueIos — the iOS half of the Expo config plugin.
4
3
  //
5
- // Default (no opts): pod 'Rovenue', '<exact version>' — pulls from CocoaPods Trunk
6
- // rovenueSwiftPath set: pod 'Rovenue', :path => '...' — monorepo `:path =>` link
4
+ // The Swift façade ships through SwiftPM only (the public mirror
5
+ // github.com/broverse/rovenue-ios). `ios/RovenueSdkRn.podspec` attaches it
6
+ // to the bridge pod with React Native's own `spm_dependency`, at this
7
+ // package's exact version, so by default this mod has nothing to ADD to the
8
+ // consumer's native project.
7
9
  //
8
- // Monorepo consumers (e.g. examples/sample-rn-expo) MUST pass
9
- // `rovenueSwiftPath` because the Rovenue pod has not been pushed to
10
- // Trunk yet (M7.1 only prepares the infra). External consumers pass
11
- // nothing and pick up the default once the first Trunk push lands.
10
+ // It does two things:
12
11
  //
13
- // The version is pinned exactly rather than with a `~>` range: the bridge
14
- // pod and the `Rovenue` façade it links against are released in lockstep,
15
- // so a mismatch must fail at dependency resolution, not silently link
16
- // against a newer/older façade.
12
+ // 1. Removes the `pod 'Rovenue', ...` line earlier versions of this plugin
13
+ // injected. `expo prebuild` without `--clean` re-runs mods over the
14
+ // existing Podfile, so an app upgrading in place would otherwise keep
15
+ // asking CocoaPods for a pod that is no longer published — and link a
16
+ // second copy of the façade next to the SwiftPM one.
17
+ // 2. Monorepo mode (`rovenueSwiftPath`): records a local SwiftPM package
18
+ // path in `ios/Podfile.properties.json`, which the podspec reads in
19
+ // place of the mirror URL.
17
20
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
21
  if (k2 === undefined) k2 = k;
19
22
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -48,37 +51,44 @@ var __importStar = (this && this.__importStar) || (function () {
48
51
  };
49
52
  })();
50
53
  Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.withRovenueIos = void 0;
52
- exports.rovenuePodLine = rovenuePodLine;
54
+ exports.withRovenueIos = exports.ROVENUE_SWIFT_PATH_PROPERTY = void 0;
55
+ exports.withoutLegacyRovenuePod = withoutLegacyRovenuePod;
53
56
  const config_plugins_1 = require("@expo/config-plugins");
54
57
  const fs = __importStar(require("node:fs"));
55
58
  const path = __importStar(require("node:path"));
56
- const packageVersion_1 = require("./packageVersion");
57
59
  /**
58
- * The Podfile line injected into the consumer's target.
59
- *
60
- * External consumers get an exact version pin: the bridge pod and the
61
- * `Rovenue` façade are released together, and a bridge built against a
62
- * different façade version fails at link time rather than at resolve time.
63
- * Monorepo consumers pass a path and bypass Trunk entirely.
60
+ * `ios/Podfile.properties.json` key read by `RovenueSdkRn.podspec`. Its value
61
+ * is a local SwiftPM package path, relative to the generated `ios/` directory.
64
62
  */
65
- function rovenuePodLine(rovenueSwiftPath, version) {
66
- return rovenueSwiftPath
67
- ? ` pod 'Rovenue', :path => '${rovenueSwiftPath}'`
68
- : ` pod 'Rovenue', '${version}'`;
63
+ exports.ROVENUE_SWIFT_PATH_PROPERTY = "rovenue.swiftPackagePath";
64
+ /** Every `pod 'Rovenue'` line a previous version of this plugin wrote. */
65
+ const LEGACY_ROVENUE_POD_LINE = /^[ \t]*pod ['"]Rovenue['"].*\r?\n?/gm;
66
+ /**
67
+ * The consumer's Podfile with any `pod 'Rovenue'` line removed. Returns the
68
+ * input unchanged when there is none.
69
+ */
70
+ function withoutLegacyRovenuePod(podfile) {
71
+ return podfile.replace(LEGACY_ROVENUE_POD_LINE, "");
69
72
  }
70
73
  const withRovenueIos = (config, opts) => {
71
- return (0, config_plugins_1.withDangerousMod)(config, ["ios", async (cfg) => {
74
+ config = (0, config_plugins_1.withDangerousMod)(config, ["ios", async (cfg) => {
72
75
  const podfile = path.join(cfg.modRequest.platformProjectRoot, "Podfile");
73
76
  if (!fs.existsSync(podfile))
74
77
  return cfg;
75
78
  const contents = fs.readFileSync(podfile, "utf8");
76
- if (contents.includes("pod 'Rovenue'"))
77
- return cfg;
78
- const podLine = rovenuePodLine(opts?.rovenueSwiftPath, (0, packageVersion_1.readOwnPackageVersion)());
79
- const patched = contents.replace(/(target\s+['"][^'"]+['"]\s+do)/, `$1\n${podLine}`);
80
- fs.writeFileSync(podfile, patched);
79
+ const cleaned = withoutLegacyRovenuePod(contents);
80
+ if (cleaned !== contents)
81
+ fs.writeFileSync(podfile, cleaned);
81
82
  return cfg;
82
83
  }]);
84
+ return (0, config_plugins_1.withPodfileProperties)(config, (cfg) => {
85
+ if (opts?.rovenueSwiftPath) {
86
+ cfg.modResults[exports.ROVENUE_SWIFT_PATH_PROPERTY] = opts.rovenueSwiftPath;
87
+ }
88
+ else {
89
+ delete cfg.modResults[exports.ROVENUE_SWIFT_PATH_PROPERTY];
90
+ }
91
+ return cfg;
92
+ });
83
93
  };
84
94
  exports.withRovenueIos = withRovenueIos;
@@ -1,7 +0,0 @@
1
- // src/version.ts
2
- var SDK_VERSION = "0.22.0";
3
-
4
- export {
5
- SDK_VERSION
6
- };
7
- //# sourceMappingURL=chunk-JTXT7GEG.js.map