@bigcrunch/react-native-ads 0.4.0 → 0.5.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/README.md +5 -5
- package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchAds.kt +434 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchBannerView.kt +484 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchInterstitial.kt +403 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/BigCrunchRewarded.kt +409 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/adapters/GoogleAdsAdapter.kt +592 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/AdOrchestrator.kt +623 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/AnalyticsClient.kt +719 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/BidRequestClient.kt +364 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/ConfigManager.kt +301 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/DeviceContext.kt +385 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/RewardedCallback.kt +42 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/core/SessionManager.kt +330 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/internal/DeviceHelper.kt +60 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/internal/HttpClient.kt +114 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Logger.kt +71 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/internal/PrivacyStore.kt +125 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/internal/Storage.kt +88 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/BannerAdListener.kt +55 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/InterstitialAdListener.kt +55 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/listeners/RewardedAdListener.kt +58 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/models/AdEvent.kt +880 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/models/AppConfig.kt +90 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/models/DeviceData.kt +18 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/models/PlacementConfig.kt +70 -0
- package/android/bigcrunch-ads/com/bigcrunch/ads/models/SessionInfo.kt +21 -0
- package/android/build.gradle +22 -10
- package/android/settings.gradle +2 -6
- package/ios/BigCrunchAds/Sources/Adapters/GoogleAdsAdapter.swift +512 -0
- package/ios/BigCrunchAds/Sources/BigCrunchAds.swift +387 -0
- package/ios/BigCrunchAds/Sources/BigCrunchBannerView.swift +448 -0
- package/ios/BigCrunchAds/Sources/BigCrunchInterstitial.swift +412 -0
- package/ios/BigCrunchAds/Sources/BigCrunchRewarded.swift +523 -0
- package/ios/BigCrunchAds/Sources/Core/AdOrchestrator.swift +514 -0
- package/ios/BigCrunchAds/Sources/Core/AnalyticsClient.swift +874 -0
- package/ios/BigCrunchAds/Sources/Core/BidRequestClient.swift +344 -0
- package/ios/BigCrunchAds/Sources/Core/ConfigManager.swift +306 -0
- package/ios/BigCrunchAds/Sources/Core/DeviceContext.swift +284 -0
- package/ios/BigCrunchAds/Sources/Core/SessionManager.swift +392 -0
- package/ios/BigCrunchAds/Sources/Internal/HTTPClient.swift +146 -0
- package/ios/BigCrunchAds/Sources/Internal/Logger.swift +62 -0
- package/ios/BigCrunchAds/Sources/Internal/PrivacyStore.swift +129 -0
- package/ios/BigCrunchAds/Sources/Internal/Storage.swift +73 -0
- package/ios/BigCrunchAds/Sources/Models/AdEvent.swift +784 -0
- package/ios/BigCrunchAds/Sources/Models/AppConfig.swift +100 -0
- package/ios/BigCrunchAds/Sources/Models/DeviceData.swift +68 -0
- package/ios/BigCrunchAds/Sources/Models/PlacementConfig.swift +137 -0
- package/ios/BigCrunchAds/Sources/Models/SessionInfo.swift +48 -0
- package/ios/BigCrunchAdsModule.swift +0 -1
- package/ios/BigCrunchBannerViewManager.swift +0 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -2
- package/package.json +8 -2
- package/react-native-bigcrunch-ads.podspec +0 -1
- package/scripts/inject-version.js +55 -0
- package/src/index.ts +3 -2
|
@@ -0,0 +1,100 @@
|
|
|
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 environment: String
|
|
13
|
+
public let gamNetworkCode: String
|
|
14
|
+
public let s2s: S2SConfig
|
|
15
|
+
public let bidders: [String: BidderEntry]?
|
|
16
|
+
public let amazonAps: GlobalAmazonConfig?
|
|
17
|
+
public let useTestAds: Bool
|
|
18
|
+
public let refresh: RefreshConfig?
|
|
19
|
+
public let placements: [PlacementConfig]
|
|
20
|
+
|
|
21
|
+
public init(
|
|
22
|
+
propertyId: String,
|
|
23
|
+
appName: String,
|
|
24
|
+
environment: String,
|
|
25
|
+
gamNetworkCode: String,
|
|
26
|
+
s2s: S2SConfig,
|
|
27
|
+
bidders: [String: BidderEntry]? = nil,
|
|
28
|
+
amazonAps: GlobalAmazonConfig?,
|
|
29
|
+
useTestAds: Bool = false,
|
|
30
|
+
refresh: RefreshConfig? = nil,
|
|
31
|
+
placements: [PlacementConfig]
|
|
32
|
+
) {
|
|
33
|
+
self.propertyId = propertyId
|
|
34
|
+
self.appName = appName
|
|
35
|
+
self.environment = environment
|
|
36
|
+
self.gamNetworkCode = gamNetworkCode
|
|
37
|
+
self.s2s = s2s
|
|
38
|
+
self.bidders = bidders
|
|
39
|
+
self.amazonAps = amazonAps
|
|
40
|
+
self.useTestAds = useTestAds
|
|
41
|
+
self.refresh = refresh
|
|
42
|
+
self.placements = placements
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* S2S (server-to-server) auction configuration
|
|
49
|
+
*
|
|
50
|
+
* Controls the connection to the BigCrunch S2S endpoint for bid requests.
|
|
51
|
+
*/
|
|
52
|
+
public struct S2SConfig: Codable {
|
|
53
|
+
public let enabled: Bool
|
|
54
|
+
public let serverUrl: String
|
|
55
|
+
public let timeoutMs: Int
|
|
56
|
+
|
|
57
|
+
public init(enabled: Bool = true, serverUrl: String, timeoutMs: Int) {
|
|
58
|
+
self.enabled = enabled
|
|
59
|
+
self.serverUrl = serverUrl
|
|
60
|
+
self.timeoutMs = timeoutMs
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public init(from decoder: Decoder) throws {
|
|
64
|
+
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
65
|
+
enabled = try container.decodeIfPresent(Bool.self, forKey: .enabled) ?? true
|
|
66
|
+
serverUrl = try container.decode(String.self, forKey: .serverUrl)
|
|
67
|
+
timeoutMs = try container.decode(Int.self, forKey: .timeoutMs)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Top-level bidder entry with shared params and per-placement params
|
|
73
|
+
*
|
|
74
|
+
* Each bidder has optional shared params (applied to all impressions) and
|
|
75
|
+
* a placements map (placementId → imp-level params for that bidder).
|
|
76
|
+
*/
|
|
77
|
+
public struct BidderEntry: Codable {
|
|
78
|
+
public let params: [String: AnyCodable]?
|
|
79
|
+
public let placements: [String: [String: AnyCodable]]?
|
|
80
|
+
|
|
81
|
+
public init(params: [String: AnyCodable]?, placements: [String: [String: AnyCodable]]?) {
|
|
82
|
+
self.params = params
|
|
83
|
+
self.placements = placements
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Global Amazon APS configuration
|
|
89
|
+
*/
|
|
90
|
+
public struct GlobalAmazonConfig: Codable {
|
|
91
|
+
public let enabled: Bool
|
|
92
|
+
public let pubId: String
|
|
93
|
+
public let timeout: Int
|
|
94
|
+
|
|
95
|
+
public init(enabled: Bool, pubId: String, timeout: Int) {
|
|
96
|
+
self.enabled = enabled
|
|
97
|
+
self.pubId = pubId
|
|
98
|
+
self.timeout = timeout
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -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
|
+
}
|
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
|
|
16
|
+
export declare const SDK_VERSION: string;
|
|
17
17
|
/**
|
|
18
18
|
* Default export for convenience
|
|
19
19
|
*/
|
package/lib/index.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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.
|
|
3
|
+
"version": "0.5.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"
|
|
@@ -86,4 +92,4 @@
|
|
|
86
92
|
"optional": false
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
|
-
}
|
|
95
|
+
}
|
|
@@ -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
|
-
|
|
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
|