@sellwild/react-native-sdk 1.3.7 → 1.4.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.
@@ -28,6 +28,6 @@ Pod::Spec.new do |s|
28
28
  # The host app must already pull in SellwildSDK (the iOS SDK pod). We
29
29
  # depend on it explicitly so `pod install` resolves both with one
30
30
  # declaration in the host Podfile.
31
- s.dependency 'SellwildSDK', '>= 1.3.5'
31
+ s.dependency 'SellwildSDK', '>= 1.4.0'
32
32
  s.dependency 'React-Core'
33
33
  end
@@ -76,7 +76,7 @@ dependencies {
76
76
  // The native SDK that owns SellwildAdView, SellwildPrebidMobile, etc.
77
77
  // Resolves to the published AAR off https://maven.sellwild.com/releases
78
78
  // for npm consumers, or to mavenLocal in the SDK monorepo dev workflow.
79
- implementation "com.sellwild:sdk:1.3.5"
79
+ implementation "com.sellwild:sdk:1.4.0"
80
80
  }
81
81
 
82
82
  // Force kotlin-stdlib down to the bridge's declared Kotlin version. The
@@ -8,6 +8,7 @@ import com.facebook.react.uimanager.ThemedReactContext
8
8
  import com.facebook.react.uimanager.annotations.ReactProp
9
9
  import com.facebook.react.uimanager.events.RCTEventEmitter
10
10
  import com.sellwild.sdk.AdSize
11
+ import com.sellwild.sdk.SellwildAdStack
11
12
  import com.sellwild.sdk.SellwildAdView
12
13
  import com.sellwild.sdk.SellwildConfig
13
14
  import org.json.JSONObject
@@ -52,6 +53,9 @@ class SellwildBannerViewManager : SimpleViewManager<SellwildAdView>() {
52
53
  var config: ReadableMap? = null,
53
54
  var size: String? = null,
54
55
  var zoneId: String? = null,
56
+ // Resolved ad stack ('both' | 'gamOnly' | 'prebidOnly'), computed in JS
57
+ // and applied as the native override.
58
+ var adStack: String? = null,
55
59
  // Guards against running fresh auctions on every JS re-render. We
56
60
  // only call setup() + load() once per identity tuple. Refresh of
57
61
  // the rendered ad is driven by the SDK's internal timer.
@@ -102,6 +106,11 @@ class SellwildBannerViewManager : SimpleViewManager<SellwildAdView>() {
102
106
  pendingFor(view).zoneId = value
103
107
  }
104
108
 
109
+ @ReactProp(name = "adStack")
110
+ fun setAdStack(view: SellwildAdView, value: String?) {
111
+ pendingFor(view).adStack = value
112
+ }
113
+
105
114
  override fun onAfterUpdateTransaction(view: SellwildAdView) {
106
115
  super.onAfterUpdateTransaction(view)
107
116
 
@@ -113,11 +122,14 @@ class SellwildBannerViewManager : SimpleViewManager<SellwildAdView>() {
113
122
  val adSize = adSizeFromLabel(sizeLabel) ?: return
114
123
 
115
124
  // Skip if the props identity hasn't changed since last apply.
116
- val key = "$sizeLabel|$zoneId|${configMap.hashCode()}"
125
+ val key = "$sizeLabel|$zoneId|${p.adStack}|${configMap.hashCode()}"
117
126
  if (p.lastAppliedKey == key) return
118
127
  p.lastAppliedKey = key
119
128
 
120
129
  val config = configFromMap(configMap)
130
+ // JS resolves the stack from config and passes it as the override so
131
+ // RN is deterministic; native still reads the raw `remote` for the rest.
132
+ view.adStackOverride = p.adStack?.let { SellwildAdStack.parse(it) }
121
133
  view.setup(config, adSize, zoneId)
122
134
  view.load()
123
135
  }
@@ -14,6 +14,7 @@
14
14
  RCT_EXPORT_VIEW_PROPERTY(config, NSDictionary)
15
15
  RCT_EXPORT_VIEW_PROPERTY(size, NSString)
16
16
  RCT_EXPORT_VIEW_PROPERTY(zoneId, NSString)
17
+ RCT_EXPORT_VIEW_PROPERTY(adStack, NSString)
17
18
 
18
19
  // Direct events emitted to JS callbacks.
19
20
  RCT_EXPORT_VIEW_PROPERTY(onAdLoaded, RCTDirectEventBlock)
@@ -39,6 +39,9 @@ final class SellwildBannerHostView: UIView, SellwildAdViewDelegate {
39
39
  @objc var config: NSDictionary? { didSet { needsApply = true } }
40
40
  @objc var size: NSString? { didSet { needsApply = true } }
41
41
  @objc var zoneId: NSString? { didSet { needsApply = true } }
42
+ /// Resolved ad stack ('both' | 'gamOnly' | 'prebidOnly'), computed in JS.
43
+ /// Applied as the native override so RN is driven deterministically by JS.
44
+ @objc var adStack: NSString? { didSet { needsApply = true } }
42
45
 
43
46
  // MARK: RN events
44
47
 
@@ -79,7 +82,8 @@ final class SellwildBannerHostView: UIView, SellwildAdViewDelegate {
79
82
  // Skip if the props identity hasn't changed since last apply —
80
83
  // refresh of the rendered ad is driven by the SDK's internal
81
84
  // timer, not by JS re-renders.
82
- let key = "\(sizeStr)|\(zid)|\(cfgMap.hash)"
85
+ let stackStr = (adStack as String?) ?? ""
86
+ let key = "\(sizeStr)|\(zid)|\(stackStr)|\(cfgMap.hash)"
83
87
  if lastAppliedKey == key { return }
84
88
  lastAppliedKey = key
85
89
 
@@ -90,6 +94,7 @@ final class SellwildBannerHostView: UIView, SellwildAdViewDelegate {
90
94
  adView?.removeFromSuperview()
91
95
 
92
96
  let view = SellwildAdView(config: sellwildConfig, adSize: adSize, zoneId: zid)
97
+ view.adStackOverride = (adStack as String?).flatMap { SellwildAdStack.parse($0) }
93
98
  view.delegate = self
94
99
  view.translatesAutoresizingMaskIntoConstraints = false
95
100
  addSubview(view)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sellwild/react-native-sdk",
3
- "version": "1.3.7",
3
+ "version": "1.4.0",
4
4
  "description": "Sellwild mobile advertising SDK for React Native",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Platform, requireNativeComponent, UIManager, ViewStyle, View, Text, StyleSheet, NativeSyntheticEvent } from 'react-native'
3
- import type { SellwildConfig, AdSize } from '@sellwild/sdk-core'
3
+ import { resolveAdStack, type SellwildConfig, type AdSize } from '@sellwild/sdk-core'
4
4
 
5
5
  // Standard IAB mobile ad sizes — used to lock the host View dimensions.
6
6
  // The actual ad size is also propagated to native as the `size` prop label.
@@ -29,6 +29,13 @@ interface NativeBannerProps {
29
29
  config: object
30
30
  size: string
31
31
  zoneId: string
32
+ /**
33
+ * Resolved ad stack ('both' | 'gamOnly' | 'prebidOnly'). Computed in JS from
34
+ * the config so RN is deterministic; native treats it as the highest-priority
35
+ * override. The raw `remote` payload still flows through `config` for
36
+ * everything else (bidders, GAM tag, etc.).
37
+ */
38
+ adStack: string
32
39
  style?: ViewStyle
33
40
  onAdLoaded?: (e: NativeSyntheticEvent<{}>) => void
34
41
  onAdImpression?: (e: NativeSyntheticEvent<{ zoneId: string }>) => void
@@ -110,6 +117,7 @@ export function SellwildBanner({
110
117
  config={nativeConfig}
111
118
  size={size}
112
119
  zoneId={String(zoneId)}
120
+ adStack={resolveAdStack(config, zoneId)}
113
121
  onAdLoaded={() => {
114
122
  // No-op event hook today; surfaced for future fill metrics.
115
123
  }}