@bigcrunch/react-native-ads 0.4.0 → 0.6.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.
Files changed (58) hide show
  1. package/README.md +5 -5
  2. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchAds.kt +434 -0
  3. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchBannerView.kt +484 -0
  4. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchInterstitial.kt +403 -0
  5. package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchRewarded.kt +409 -0
  6. package/android/bigcrunch-ads/com/bigcrunch/ads/adapters/GoogleAdsAdapter.kt +592 -0
  7. package/android/bigcrunch-ads/com/bigcrunch/ads/core/AdOrchestrator.kt +623 -0
  8. package/android/bigcrunch-ads/com/bigcrunch/ads/core/AnalyticsClient.kt +719 -0
  9. package/android/bigcrunch-ads/com/bigcrunch/ads/core/BidRequestClient.kt +364 -0
  10. package/android/bigcrunch-ads/com/bigcrunch/ads/core/ConfigManager.kt +300 -0
  11. package/android/bigcrunch-ads/com/bigcrunch/ads/core/DeviceContext.kt +385 -0
  12. package/android/bigcrunch-ads/com/bigcrunch/ads/core/RewardedCallback.kt +42 -0
  13. package/android/bigcrunch-ads/com/bigcrunch/ads/core/SessionManager.kt +330 -0
  14. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/DeviceHelper.kt +60 -0
  15. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/HttpClient.kt +114 -0
  16. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Logger.kt +71 -0
  17. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/PrivacyStore.kt +125 -0
  18. package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Storage.kt +88 -0
  19. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/BannerAdListener.kt +55 -0
  20. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/InterstitialAdListener.kt +55 -0
  21. package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/RewardedAdListener.kt +58 -0
  22. package/android/bigcrunch-ads/com/bigcrunch/ads/models/AdEvent.kt +880 -0
  23. package/android/bigcrunch-ads/com/bigcrunch/ads/models/AppConfig.kt +87 -0
  24. package/android/bigcrunch-ads/com/bigcrunch/ads/models/DeviceData.kt +18 -0
  25. package/android/bigcrunch-ads/com/bigcrunch/ads/models/PlacementConfig.kt +70 -0
  26. package/android/bigcrunch-ads/com/bigcrunch/ads/models/SessionInfo.kt +21 -0
  27. package/android/build.gradle +22 -10
  28. package/android/settings.gradle +2 -6
  29. package/android/src/main/java/com/bigcrunch/ads/react/BigCrunchAdsModule.kt +8 -2
  30. package/ios/BigCrunchAds/Sources/Adapters/GoogleAdsAdapter.swift +512 -0
  31. package/ios/BigCrunchAds/Sources/BigCrunchAds.swift +387 -0
  32. package/ios/BigCrunchAds/Sources/BigCrunchBannerView.swift +448 -0
  33. package/ios/BigCrunchAds/Sources/BigCrunchInterstitial.swift +412 -0
  34. package/ios/BigCrunchAds/Sources/BigCrunchRewarded.swift +523 -0
  35. package/ios/BigCrunchAds/Sources/Core/AdOrchestrator.swift +514 -0
  36. package/ios/BigCrunchAds/Sources/Core/AnalyticsClient.swift +874 -0
  37. package/ios/BigCrunchAds/Sources/Core/BidRequestClient.swift +344 -0
  38. package/ios/BigCrunchAds/Sources/Core/ConfigManager.swift +305 -0
  39. package/ios/BigCrunchAds/Sources/Core/DeviceContext.swift +284 -0
  40. package/ios/BigCrunchAds/Sources/Core/SessionManager.swift +392 -0
  41. package/ios/BigCrunchAds/Sources/Internal/HTTPClient.swift +146 -0
  42. package/ios/BigCrunchAds/Sources/Internal/Logger.swift +62 -0
  43. package/ios/BigCrunchAds/Sources/Internal/PrivacyStore.swift +129 -0
  44. package/ios/BigCrunchAds/Sources/Internal/Storage.swift +73 -0
  45. package/ios/BigCrunchAds/Sources/Models/AdEvent.swift +784 -0
  46. package/ios/BigCrunchAds/Sources/Models/AppConfig.swift +97 -0
  47. package/ios/BigCrunchAds/Sources/Models/DeviceData.swift +68 -0
  48. package/ios/BigCrunchAds/Sources/Models/PlacementConfig.swift +137 -0
  49. package/ios/BigCrunchAds/Sources/Models/SessionInfo.swift +48 -0
  50. package/ios/BigCrunchAdsModule.swift +37 -9
  51. package/ios/BigCrunchBannerViewManager.swift +0 -1
  52. package/lib/index.d.ts +1 -1
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +3 -2
  55. package/package.json +7 -1
  56. package/react-native-bigcrunch-ads.podspec +0 -1
  57. package/scripts/inject-version.js +55 -0
  58. package/src/index.ts +3 -2
@@ -0,0 +1,97 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Top-level application configuration returned from the BigCrunch backend
5
+ *
6
+ * This config contains all placement definitions and is fetched once at SDK initialization
7
+ * and cached for subsequent sessions.
8
+ */
9
+ public struct AppConfig: Codable {
10
+ public let propertyId: String
11
+ public let appName: String
12
+ public let gamNetworkCode: String
13
+ public let s2s: S2SConfig
14
+ public let bidders: [String: BidderEntry]?
15
+ public let amazonAps: GlobalAmazonConfig?
16
+ public let useTestAds: Bool
17
+ public let refresh: RefreshConfig?
18
+ public let placements: [PlacementConfig]
19
+
20
+ public init(
21
+ propertyId: String,
22
+ appName: String,
23
+ gamNetworkCode: String,
24
+ s2s: S2SConfig,
25
+ bidders: [String: BidderEntry]? = nil,
26
+ amazonAps: GlobalAmazonConfig?,
27
+ useTestAds: Bool = false,
28
+ refresh: RefreshConfig? = nil,
29
+ placements: [PlacementConfig]
30
+ ) {
31
+ self.propertyId = propertyId
32
+ self.appName = appName
33
+ self.gamNetworkCode = gamNetworkCode
34
+ self.s2s = s2s
35
+ self.bidders = bidders
36
+ self.amazonAps = amazonAps
37
+ self.useTestAds = useTestAds
38
+ self.refresh = refresh
39
+ self.placements = placements
40
+ }
41
+
42
+ }
43
+
44
+ /**
45
+ * S2S (server-to-server) auction configuration
46
+ *
47
+ * Controls the connection to the BigCrunch S2S endpoint for bid requests.
48
+ */
49
+ public struct S2SConfig: Codable {
50
+ public let enabled: Bool
51
+ public let serverUrl: String
52
+ public let timeoutMs: Int
53
+
54
+ public init(enabled: Bool = true, serverUrl: String, timeoutMs: Int) {
55
+ self.enabled = enabled
56
+ self.serverUrl = serverUrl
57
+ self.timeoutMs = timeoutMs
58
+ }
59
+
60
+ public init(from decoder: Decoder) throws {
61
+ let container = try decoder.container(keyedBy: CodingKeys.self)
62
+ enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled) ?? true
63
+ serverUrl = try container.decode(String.self, forKey: .serverUrl)
64
+ timeoutMs = try container.decode(Int.self, forKey: .timeoutMs)
65
+ }
66
+ }
67
+
68
+ /**
69
+ * Top-level bidder entry with shared params and per-placement params
70
+ *
71
+ * Each bidder has optional shared params (applied to all impressions) and
72
+ * a placements map (placementId → imp-level params for that bidder).
73
+ */
74
+ public struct BidderEntry: Codable {
75
+ public let params: [String: AnyCodable]?
76
+ public let placements: [String: [String: AnyCodable]]?
77
+
78
+ public init(params: [String: AnyCodable]?, placements: [String: [String: AnyCodable]]?) {
79
+ self.params = params
80
+ self.placements = placements
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Global Amazon APS configuration
86
+ */
87
+ public struct GlobalAmazonConfig: Codable {
88
+ public let enabled: Bool
89
+ public let pubId: String
90
+ public let timeout: Int
91
+
92
+ public init(enabled: Bool, pubId: String, timeout: Int) {
93
+ self.enabled = enabled
94
+ self.pubId = pubId
95
+ self.timeout = timeout
96
+ }
97
+ }
@@ -0,0 +1,68 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Device information for analytics and ad targeting
5
+ *
6
+ * Contains device hardware and software information used for analytics
7
+ * and can be exposed to React Native.
8
+ */
9
+ public struct DeviceData {
10
+ /// Persistent device identifier (same as userId from SessionManager)
11
+ public let deviceId: String
12
+
13
+ /// Device model identifier (e.g., "iPhone14,2")
14
+ public let deviceModel: String
15
+
16
+ /// Operating system version (e.g., "17.0")
17
+ public let osVersion: String
18
+
19
+ /// App version string (e.g., "1.2.3")
20
+ public let appVersion: String
21
+
22
+ /// Screen width in points
23
+ public let screenWidth: Int
24
+
25
+ /// Screen height in points
26
+ public let screenHeight: Int
27
+
28
+ /// User's language code (e.g., "en")
29
+ public let language: String
30
+
31
+ /// User's country code (e.g., "US")
32
+ public let country: String
33
+
34
+ /// Whether the device is a tablet
35
+ public let isTablet: Bool
36
+
37
+ /// Mobile carrier name (if available)
38
+ public let carrier: String?
39
+
40
+ /// Network connection type (e.g., "wifi", "cellular")
41
+ public let networkType: String?
42
+
43
+ public init(
44
+ deviceId: String,
45
+ deviceModel: String,
46
+ osVersion: String,
47
+ appVersion: String,
48
+ screenWidth: Int,
49
+ screenHeight: Int,
50
+ language: String,
51
+ country: String,
52
+ isTablet: Bool,
53
+ carrier: String? = nil,
54
+ networkType: String? = nil
55
+ ) {
56
+ self.deviceId = deviceId
57
+ self.deviceModel = deviceModel
58
+ self.osVersion = osVersion
59
+ self.appVersion = appVersion
60
+ self.screenWidth = screenWidth
61
+ self.screenHeight = screenHeight
62
+ self.language = language
63
+ self.country = country
64
+ self.isTablet = isTablet
65
+ self.carrier = carrier
66
+ self.networkType = networkType
67
+ }
68
+ }
@@ -0,0 +1,137 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Configuration for a single ad placement
5
+ *
6
+ * Contains all information needed to request and display an ad at a specific
7
+ * location in the app. Bidder configuration is no longer stored here — it lives
8
+ * in the top-level `AppConfig.bidders` dictionary.
9
+ */
10
+ public struct PlacementConfig: Codable {
11
+ public let placementId: String
12
+ public let format: String // "banner", "interstitial", "rewarded"
13
+ public let gamAdUnit: String
14
+ public let sizes: [AdSize]?
15
+ public let refresh: RefreshConfig?
16
+
17
+ public init(
18
+ placementId: String,
19
+ format: String,
20
+ gamAdUnit: String,
21
+ sizes: [AdSize]?,
22
+ refresh: RefreshConfig? = nil
23
+ ) {
24
+ self.placementId = placementId
25
+ self.format = format
26
+ self.gamAdUnit = gamAdUnit
27
+ self.sizes = sizes
28
+ self.refresh = refresh
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Type-erased Codable wrapper for arbitrary JSON values
34
+ *
35
+ * Supports String, Int, Double, Bool, nested objects, and arrays.
36
+ */
37
+ public struct AnyCodable: Codable, Equatable {
38
+ public let value: Any
39
+
40
+ public init(_ value: Any) {
41
+ self.value = value
42
+ }
43
+
44
+ public init(from decoder: Decoder) throws {
45
+ let container = try decoder.singleValueContainer()
46
+ if let intVal = try? container.decode(Int.self) {
47
+ value = intVal
48
+ } else if let doubleVal = try? container.decode(Double.self) {
49
+ value = doubleVal
50
+ } else if let boolVal = try? container.decode(Bool.self) {
51
+ value = boolVal
52
+ } else if let stringVal = try? container.decode(String.self) {
53
+ value = stringVal
54
+ } else if let arrayVal = try? container.decode([AnyCodable].self) {
55
+ value = arrayVal.map { $0.value }
56
+ } else if let dictVal = try? container.decode([String: AnyCodable].self) {
57
+ value = dictVal.mapValues { $0.value }
58
+ } else {
59
+ throw DecodingError.dataCorruptedError(in: container, debugDescription: "Unsupported JSON value")
60
+ }
61
+ }
62
+
63
+ public func encode(to encoder: Encoder) throws {
64
+ var container = encoder.singleValueContainer()
65
+ switch value {
66
+ case let intVal as Int:
67
+ try container.encode(intVal)
68
+ case let doubleVal as Double:
69
+ try container.encode(doubleVal)
70
+ case let boolVal as Bool:
71
+ try container.encode(boolVal)
72
+ case let stringVal as String:
73
+ try container.encode(stringVal)
74
+ case let arrayVal as [Any]:
75
+ try container.encode(arrayVal.map { AnyCodable($0) })
76
+ case let dictVal as [String: Any]:
77
+ try container.encode(dictVal.mapValues { AnyCodable($0) })
78
+ default:
79
+ throw EncodingError.invalidValue(value, EncodingError.Context(codingPath: encoder.codingPath, debugDescription: "Unsupported value type"))
80
+ }
81
+ }
82
+
83
+ public static func == (lhs: AnyCodable, rhs: AnyCodable) -> Bool {
84
+ switch (lhs.value, rhs.value) {
85
+ case let (l as Int, r as Int): return l == r
86
+ case let (l as Double, r as Double): return l == r
87
+ case let (l as Bool, r as Bool): return l == r
88
+ case let (l as String, r as String): return l == r
89
+ default: return false
90
+ }
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Ad size dimensions
96
+ *
97
+ * When `type` is "adaptive" or "smart", the SDK will use Google's adaptive
98
+ * banner API to calculate the optimal height for the given `width`.
99
+ * A `width` of 0 means "use screen width".
100
+ */
101
+ /// Typealias for disambiguation when module name collides with BigCrunchAds class name
102
+ public typealias BCAdSize = AdSize
103
+
104
+ public struct AdSize: Codable, Equatable {
105
+ public let width: Int
106
+ public let height: Int
107
+ public let type: String?
108
+
109
+ public var isAdaptive: Bool {
110
+ type == "adaptive" || type == "smart"
111
+ }
112
+
113
+ public init(width: Int, height: Int, type: String? = nil) {
114
+ self.width = width
115
+ self.height = height
116
+ self.type = type
117
+ }
118
+
119
+ public static func adaptive(width: Int = 0) -> AdSize {
120
+ AdSize(width: width, height: 0, type: "adaptive")
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Refresh configuration for banner ads
126
+ */
127
+ public struct RefreshConfig: Codable {
128
+ public let enabled: Bool
129
+ public let intervalMs: Int
130
+ public let maxRefreshes: Int
131
+
132
+ public init(enabled: Bool, intervalMs: Int, maxRefreshes: Int) {
133
+ self.enabled = enabled
134
+ self.intervalMs = intervalMs
135
+ self.maxRefreshes = maxRefreshes
136
+ }
137
+ }
@@ -0,0 +1,48 @@
1
+ import Foundation
2
+
3
+ /**
4
+ * Session information for analytics tracking
5
+ *
6
+ * Provides current session state including identifiers and tracking counts.
7
+ * This data is used for analytics and can be exposed to React Native.
8
+ */
9
+ public struct SessionInfo {
10
+ /// Unique identifier for the current session (changes each app launch)
11
+ public let sessionId: String
12
+
13
+ /// Persistent user identifier (stable across app launches)
14
+ public let userId: String
15
+
16
+ /// ISO 8601 timestamp when the session started
17
+ public let startTime: String
18
+
19
+ /// Number of screen views in this session
20
+ public let screenViewCount: Int
21
+
22
+ /// Number of ad requests made in this session
23
+ public let adRequestCount: Int
24
+
25
+ /// Number of ad impressions recorded in this session
26
+ public let adImpressionCount: Int
27
+
28
+ /// Total revenue in micros (1/1,000,000 of currency unit) for this session
29
+ public let totalRevenueMicros: Int64
30
+
31
+ public init(
32
+ sessionId: String,
33
+ userId: String,
34
+ startTime: String,
35
+ screenViewCount: Int,
36
+ adRequestCount: Int,
37
+ adImpressionCount: Int,
38
+ totalRevenueMicros: Int64
39
+ ) {
40
+ self.sessionId = sessionId
41
+ self.userId = userId
42
+ self.startTime = startTime
43
+ self.screenViewCount = screenViewCount
44
+ self.adRequestCount = adRequestCount
45
+ self.adImpressionCount = adImpressionCount
46
+ self.totalRevenueMicros = totalRevenueMicros
47
+ }
48
+ }
@@ -1,5 +1,4 @@
1
1
  import Foundation
2
- import BigCrunchAds
3
2
  #if canImport(React)
4
3
  import React
5
4
  #endif
@@ -121,6 +120,26 @@ class RewardedDelegate: NSObject, BigCrunchRewardedDelegate {
121
120
  }
122
121
  }
123
122
 
123
+ // MARK: - Initialization Callback Bridge
124
+
125
+ class InitCallbackBridge: NSObject, BigCrunchInitializationCallback {
126
+ private let onSuccess: () -> Void
127
+ private let onFailure: (String) -> Void
128
+
129
+ init(onSuccess: @escaping () -> Void, onFailure: @escaping (String) -> Void) {
130
+ self.onSuccess = onSuccess
131
+ self.onFailure = onFailure
132
+ }
133
+
134
+ func onInitialized() {
135
+ onSuccess()
136
+ }
137
+
138
+ func onInitializationFailed(error: String) {
139
+ onFailure(error)
140
+ }
141
+ }
142
+
124
143
  @objc(BigCrunchAdsModule)
125
144
  class BigCrunchAdsModule: RCTEventEmitter {
126
145
 
@@ -130,6 +149,7 @@ class BigCrunchAdsModule: RCTEventEmitter {
130
149
  var rewardedCache: [String: Any] = [:]
131
150
  private var interstitialDelegates: [String: InterstitialDelegate] = [:]
132
151
  var rewardedDelegates: [String: RewardedDelegate] = [:]
152
+ private var initCallbackBridge: InitCallbackBridge?
133
153
 
134
154
  override static func moduleName() -> String! {
135
155
  return "BigCrunchAdsModule"
@@ -209,17 +229,26 @@ class BigCrunchAdsModule: RCTEventEmitter {
209
229
  // Map environment strings to SDK enum - "sandbox" maps to .staging
210
230
  let env: BigCrunchEnv = environment == "sandbox" ? .staging : .prod
211
231
 
232
+ // Use callback to wait for config to load before resolving the promise
233
+ // This ensures placements are available when the app starts loading ads
234
+ let callbackBridge = InitCallbackBridge(
235
+ onSuccess: {
236
+ BigCrunchAdsModule.isSDKInitialized = true
237
+ resolver(nil)
238
+ },
239
+ onFailure: { error in
240
+ rejecter("INIT_ERROR", "Failed to load configuration: \(error)", nil)
241
+ }
242
+ )
243
+ // Store strong reference so it isn't deallocated before callback fires
244
+ self.initCallbackBridge = callbackBridge
245
+
212
246
  BigCrunchAds.initialize(
213
247
  propertyId: propertyId,
214
248
  env: env,
215
- useMockConfig: useMockConfig
249
+ useMockConfig: useMockConfig,
250
+ callback: callbackBridge
216
251
  )
217
-
218
- // Track that we've initialized
219
- BigCrunchAdsModule.isSDKInitialized = true
220
-
221
- // Note: debug mode is handled by SDK based on env (.staging enables verbose logging)
222
- resolver(nil)
223
252
  }
224
253
  }
225
254
 
@@ -255,7 +284,6 @@ class BigCrunchAdsModule: RCTEventEmitter {
255
284
  let configDict: [String: Any] = [
256
285
  "propertyId": config.propertyId,
257
286
  "appName": config.appName,
258
- "environment": config.environment,
259
287
  "gamNetworkCode": config.gamNetworkCode,
260
288
  "s2s": [
261
289
  "enabled": config.s2s.enabled,
@@ -1,7 +1,6 @@
1
1
  import Foundation
2
2
  import React
3
3
  import UIKit
4
- import BigCrunchAds
5
4
  import GoogleMobileAds
6
5
 
7
6
  @objc(BigCrunchBannerViewManager)
package/lib/index.d.ts CHANGED
@@ -13,7 +13,7 @@ import BigCrunchRewarded from './BigCrunchRewarded';
13
13
  export * from './types';
14
14
  export type { InitializationOptions, Environment, AdFormat, BannerSize, CustomSize, BigCrunchBannerViewProps, InterstitialAd, RewardedAd, AdEvent, AdEventListener, EventSubscription, AdError, AdRevenue, AppConfig, PlacementConfig, SessionInfo, DeviceContext, } from './types';
15
15
  export { AdErrorCode } from './types';
16
- export declare const SDK_VERSION = "0.1.0";
16
+ export declare const SDK_VERSION: string;
17
17
  /**
18
18
  * Default export for convenience
19
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAE,mBAAmB,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,cAAc,SAAS,CAAC;AAGxB,YAAY,EAEV,qBAAqB,EACrB,WAAW,EAGX,QAAQ,EACR,UAAU,EACV,UAAU,EAGV,wBAAwB,EACxB,cAAc,EACd,UAAU,EAGV,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,SAAS,EAGT,SAAS,EACT,eAAe,EAGf,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;GAEG;;;;;;;;AACH,wBAME"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,YAAY,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAE,mBAAmB,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnG,OAAO,EAAE,qBAAqB,EAAE,OAAO,IAAI,4BAA4B,EAAE,MAAM,yBAAyB,CAAC;AACzG,OAAO,EAAE,iBAAiB,EAAE,OAAO,IAAI,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAE1C,OAAO,qBAAqB,MAAM,yBAAyB,CAAC;AAC5D,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,cAAc,SAAS,CAAC;AAGxB,YAAY,EAEV,qBAAqB,EACrB,WAAW,EAGX,QAAQ,EACR,UAAU,EACV,UAAU,EAGV,wBAAwB,EACxB,cAAc,EACd,UAAU,EAGV,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,SAAS,EAGT,SAAS,EACT,eAAe,EAGf,WAAW,EACX,aAAa,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAItC,eAAO,MAAM,WAAW,EAAE,MAA2C,CAAC;AAEtE;;GAEG;;;;;;;;AACH,wBAME"}
package/lib/index.js CHANGED
@@ -18,8 +18,9 @@ import BigCrunchRewarded from './BigCrunchRewarded';
18
18
  export * from './types';
19
19
  // Export error codes enum
20
20
  export { AdErrorCode } from './types';
21
- // Version
22
- export const SDK_VERSION = '0.1.0';
21
+ // Version - read from package.json
22
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
23
+ export const SDK_VERSION = require('../package.json').version;
23
24
  /**
24
25
  * Default export for convenience
25
26
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigcrunch/react-native-ads",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "BigCrunch Mobile Ads SDK for React Native - Simplified in-app advertising with S2S demand and Google Ad Manager",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -24,6 +24,9 @@
24
24
  "ios/*.swift",
25
25
  "ios/*.m",
26
26
  "ios/*.h",
27
+ "ios/BigCrunchAds/**/*.swift",
28
+ "android/bigcrunch-ads/**/*.kt",
29
+ "scripts/inject-version.js",
27
30
  "react-native-bigcrunch-ads.podspec",
28
31
  "!**/__tests__",
29
32
  "!**/__fixtures__",
@@ -33,6 +36,9 @@
33
36
  "typescript": "tsc --noEmit",
34
37
  "build": "tsc",
35
38
  "prepare": "npm run build || echo 'Build skipped during install'",
39
+ "prepack": "mkdir -p ios/BigCrunchAds && cp -r ../ios/BigCrunchAds/Sources/ ios/BigCrunchAds/Sources/ && mkdir -p android/bigcrunch-ads && cp -r ../android/bigcrunch-ads/src/main/java/ android/bigcrunch-ads/ && node scripts/inject-version.js --prepack",
40
+ "postpack": "rm -rf ios/BigCrunchAds/Sources android/bigcrunch-ads/java",
41
+ "sync-version": "node scripts/inject-version.js --sync",
36
42
  "release": "release-it",
37
43
  "example": "yarn --cwd example",
38
44
  "clean": "del-cli lib"
@@ -19,7 +19,6 @@ Pod::Spec.new do |s|
19
19
  s.requires_arc = true
20
20
 
21
21
  s.dependency "React"
22
- s.dependency "BigCrunchAds", "~> 0.1.0" # Reference to main iOS SDK
23
22
  s.dependency "Google-Mobile-Ads-SDK", ">= 10.14.0"
24
23
 
25
24
  s.swift_version = "5.9"
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Injects the package.json version into native SDK DeviceContext files.
5
+ *
6
+ * Usage:
7
+ * node scripts/inject-version.js --prepack # Operates on copied files inside the package
8
+ * node scripts/inject-version.js --sync # Operates on canonical source files in the monorepo
9
+ */
10
+
11
+ const fs = require('fs');
12
+ const path = require('path');
13
+
14
+ const version = require('../package.json').version;
15
+ const mode = process.argv[2];
16
+
17
+ const TARGETS = {
18
+ '--prepack': [
19
+ 'ios/BigCrunchAds/Sources/Core/DeviceContext.swift',
20
+ 'android/bigcrunch-ads/com/bigcrunch/ads/core/DeviceContext.kt',
21
+ ],
22
+ '--sync': [
23
+ '../ios/BigCrunchAds/Sources/Core/DeviceContext.swift',
24
+ '../android/bigcrunch-ads/src/main/java/com/bigcrunch/ads/core/DeviceContext.kt',
25
+ ],
26
+ };
27
+
28
+ const files = TARGETS[mode];
29
+ if (!files) {
30
+ console.error('Usage: inject-version.js --prepack | --sync');
31
+ process.exit(1);
32
+ }
33
+
34
+ const SDK_VERSION_RE = /(SDK_VERSION\s*=\s*)(["']).*?\2/;
35
+
36
+ files.forEach((rel) => {
37
+ const filePath = path.resolve(__dirname, '..', rel);
38
+ if (!fs.existsSync(filePath)) {
39
+ console.warn(`Skipping (not found): ${rel}`);
40
+ return;
41
+ }
42
+ const content = fs.readFileSync(filePath, 'utf8');
43
+ const match = content.match(SDK_VERSION_RE);
44
+ if (!match) {
45
+ console.warn(`No SDK_VERSION match in: ${rel}`);
46
+ return;
47
+ }
48
+ const updated = content.replace(SDK_VERSION_RE, `$1"${version}"`);
49
+ if (content === updated) {
50
+ console.log(`Already v${version} in ${rel}`);
51
+ } else {
52
+ fs.writeFileSync(filePath, updated);
53
+ console.log(`Injected v${version} into ${rel}`);
54
+ }
55
+ });
package/src/index.ts CHANGED
@@ -56,8 +56,9 @@ export type {
56
56
  // Export error codes enum
57
57
  export { AdErrorCode } from './types';
58
58
 
59
- // Version
60
- export const SDK_VERSION = '0.1.0';
59
+ // Version - read from package.json
60
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
61
+ export const SDK_VERSION: string = require('../package.json').version;
61
62
 
62
63
  /**
63
64
  * Default export for convenience