@thealteroffice/react-native-adgeist 0.0.19 → 0.0.20
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/Adgeist.podspec +1 -1
- package/ios/Adgeist.mm +132 -22
- package/ios/AdgeistImpl.swift +174 -34
- package/package.json +1 -1
- package/plugin/build/android/withRNAdgeistMainApplication.d.ts +3 -0
- package/plugin/build/android/withRNAdgeistMainApplication.js +65 -0
- package/plugin/build/index.d.ts +3 -0
- package/plugin/build/index.js +25 -0
- package/plugin/build/ios/withRNAdgeistAppDelegate.d.ts +4 -0
- package/plugin/build/ios/withRNAdgeistAppDelegate.js +66 -0
package/Adgeist.podspec
CHANGED
|
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
|
|
|
16
16
|
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
17
17
|
s.private_header_files = "ios/**/*.h"
|
|
18
18
|
|
|
19
|
-
s.dependency "AdgeistKit", '= 0.0.
|
|
19
|
+
s.dependency "AdgeistKit", '= 0.0.9'
|
|
20
20
|
|
|
21
21
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
22
22
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/ios/Adgeist.mm
CHANGED
|
@@ -47,28 +47,6 @@ RCT_EXPORT_METHOD(fetchCreative:(NSString *)apiKey
|
|
|
47
47
|
rejecter:reject];
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
RCT_EXPORT_METHOD(sendCreativeAnalytic:(NSString *)campaignId
|
|
51
|
-
adSpaceId:(NSString *)adSpaceId
|
|
52
|
-
publisherId:(NSString *)publisherId
|
|
53
|
-
eventType:(NSString *)eventType
|
|
54
|
-
origin:(NSString *)origin
|
|
55
|
-
apiKey:(NSString *)apiKey
|
|
56
|
-
bidId:(NSString *)bidId
|
|
57
|
-
isTestEnvironment:(BOOL)isTestEnvironment
|
|
58
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
59
|
-
reject:(RCTPromiseRejectBlock)reject)
|
|
60
|
-
{
|
|
61
|
-
[adgeist sendCreativeAnalyticWithCampaignId:campaignId
|
|
62
|
-
adSpaceId:adSpaceId
|
|
63
|
-
publisherId:publisherId
|
|
64
|
-
eventType:eventType
|
|
65
|
-
origin:origin
|
|
66
|
-
apiKey:apiKey
|
|
67
|
-
bidId:bidId
|
|
68
|
-
isTestEnvironment:isTestEnvironment
|
|
69
|
-
resolver:resolve
|
|
70
|
-
rejecter:reject];
|
|
71
|
-
}
|
|
72
50
|
|
|
73
51
|
RCT_EXPORT_METHOD(setUserDetails:(NSObject *)userDetails) {
|
|
74
52
|
[adgeist setUserDetails:userDetails];
|
|
@@ -88,6 +66,138 @@ RCT_EXPORT_METHOD(logEvent:(NSDictionary *)eventDict) {
|
|
|
88
66
|
[adgeist logEventWithEventDict:eventDict];
|
|
89
67
|
}
|
|
90
68
|
|
|
69
|
+
RCT_EXPORT_METHOD(trackImpression:(NSString *)campaignId
|
|
70
|
+
adSpaceId:(NSString *)adSpaceId
|
|
71
|
+
publisherId:(NSString *)publisherId
|
|
72
|
+
apiKey:(NSString *)apiKey
|
|
73
|
+
bidId:(NSString *)bidId
|
|
74
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
75
|
+
renderTime:(double)renderTime
|
|
76
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
77
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
78
|
+
{
|
|
79
|
+
[adgeist trackImpressionWithCampaignId:campaignId
|
|
80
|
+
adSpaceId:adSpaceId
|
|
81
|
+
publisherId:publisherId
|
|
82
|
+
apiKey:apiKey
|
|
83
|
+
bidId:bidId
|
|
84
|
+
isTestEnvironment:isTestEnvironment
|
|
85
|
+
renderTime:renderTime
|
|
86
|
+
resolver:resolve
|
|
87
|
+
rejecter:reject];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
RCT_EXPORT_METHOD(trackView:(NSString *)campaignId
|
|
91
|
+
adSpaceId:(NSString *)adSpaceId
|
|
92
|
+
publisherId:(NSString *)publisherId
|
|
93
|
+
apiKey:(NSString *)apiKey
|
|
94
|
+
bidId:(NSString *)bidId
|
|
95
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
96
|
+
viewTime:(double)viewTime
|
|
97
|
+
visibilityRatio:(double)visibilityRatio
|
|
98
|
+
scrollDepth:(double)scrollDepth
|
|
99
|
+
timeToVisible:(double)timeToVisible
|
|
100
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
101
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
102
|
+
{
|
|
103
|
+
[adgeist trackViewWithCampaignId:campaignId
|
|
104
|
+
adSpaceId:adSpaceId
|
|
105
|
+
publisherId:publisherId
|
|
106
|
+
apiKey:apiKey
|
|
107
|
+
bidId:bidId
|
|
108
|
+
isTestEnvironment:isTestEnvironment
|
|
109
|
+
viewTime:viewTime
|
|
110
|
+
visibilityRatio:visibilityRatio
|
|
111
|
+
scrollDepth:scrollDepth
|
|
112
|
+
timeToVisible:timeToVisible
|
|
113
|
+
resolver:resolve
|
|
114
|
+
rejecter:reject];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
RCT_EXPORT_METHOD(trackTotalView:(NSString *)campaignId
|
|
118
|
+
adSpaceId:(NSString *)adSpaceId
|
|
119
|
+
publisherId:(NSString *)publisherId
|
|
120
|
+
apiKey:(NSString *)apiKey
|
|
121
|
+
bidId:(NSString *)bidId
|
|
122
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
123
|
+
totalViewTime:(double)totalViewTime
|
|
124
|
+
visibilityRatio:(double)visibilityRatio
|
|
125
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
126
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
127
|
+
{
|
|
128
|
+
[adgeist trackTotalViewWithCampaignId:campaignId
|
|
129
|
+
adSpaceId:adSpaceId
|
|
130
|
+
publisherId:publisherId
|
|
131
|
+
apiKey:apiKey
|
|
132
|
+
bidId:bidId
|
|
133
|
+
isTestEnvironment:isTestEnvironment
|
|
134
|
+
totalViewTime:totalViewTime
|
|
135
|
+
visibilityRatio:visibilityRatio
|
|
136
|
+
resolver:resolve
|
|
137
|
+
rejecter:reject];
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
RCT_EXPORT_METHOD(trackClick:(NSString *)campaignId
|
|
141
|
+
adSpaceId:(NSString *)adSpaceId
|
|
142
|
+
publisherId:(NSString *)publisherId
|
|
143
|
+
apiKey:(NSString *)apiKey
|
|
144
|
+
bidId:(NSString *)bidId
|
|
145
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
146
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
147
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
148
|
+
{
|
|
149
|
+
[adgeist trackClickWithCampaignId:campaignId
|
|
150
|
+
adSpaceId:adSpaceId
|
|
151
|
+
publisherId:publisherId
|
|
152
|
+
apiKey:apiKey
|
|
153
|
+
bidId:bidId
|
|
154
|
+
isTestEnvironment:isTestEnvironment
|
|
155
|
+
resolver:resolve
|
|
156
|
+
rejecter:reject];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
RCT_EXPORT_METHOD(trackVideoPlayback:(NSString *)campaignId
|
|
160
|
+
adSpaceId:(NSString *)adSpaceId
|
|
161
|
+
publisherId:(NSString *)publisherId
|
|
162
|
+
apiKey:(NSString *)apiKey
|
|
163
|
+
bidId:(NSString *)bidId
|
|
164
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
165
|
+
totalPlaybackTime:(double)totalPlaybackTime
|
|
166
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
167
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
168
|
+
{
|
|
169
|
+
[adgeist trackVideoPlaybackWithCampaignId:campaignId
|
|
170
|
+
adSpaceId:adSpaceId
|
|
171
|
+
publisherId:publisherId
|
|
172
|
+
apiKey:apiKey
|
|
173
|
+
bidId:bidId
|
|
174
|
+
isTestEnvironment:isTestEnvironment
|
|
175
|
+
totalPlaybackTime:totalPlaybackTime
|
|
176
|
+
resolver:resolve
|
|
177
|
+
rejecter:reject];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
RCT_EXPORT_METHOD(trackVideoQuartile:(NSString *)campaignId
|
|
181
|
+
adSpaceId:(NSString *)adSpaceId
|
|
182
|
+
publisherId:(NSString *)publisherId
|
|
183
|
+
apiKey:(NSString *)apiKey
|
|
184
|
+
bidId:(NSString *)bidId
|
|
185
|
+
isTestEnvironment:(BOOL)isTestEnvironment
|
|
186
|
+
quartile:(NSString *)quartile
|
|
187
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
188
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
189
|
+
{
|
|
190
|
+
[adgeist trackVideoQuartileWithCampaignId:campaignId
|
|
191
|
+
adSpaceId:adSpaceId
|
|
192
|
+
publisherId:publisherId
|
|
193
|
+
apiKey:apiKey
|
|
194
|
+
bidId:bidId
|
|
195
|
+
isTestEnvironment:isTestEnvironment
|
|
196
|
+
quartile:quartile
|
|
197
|
+
resolver:resolve
|
|
198
|
+
rejecter:reject];
|
|
199
|
+
}
|
|
200
|
+
|
|
91
201
|
// TurboModule support for the new architecture
|
|
92
202
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
93
203
|
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
package/ios/AdgeistImpl.swift
CHANGED
|
@@ -61,40 +61,6 @@ import React
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
@objc public func sendCreativeAnalytic(
|
|
65
|
-
campaignId: String,
|
|
66
|
-
adSpaceId: String,
|
|
67
|
-
publisherId: String,
|
|
68
|
-
eventType: String,
|
|
69
|
-
origin: String,
|
|
70
|
-
apiKey: String,
|
|
71
|
-
bidId: String,
|
|
72
|
-
isTestEnvironment: Bool,
|
|
73
|
-
resolver: @escaping RCTPromiseResolveBlock,
|
|
74
|
-
rejecter: @escaping RCTPromiseRejectBlock
|
|
75
|
-
) {
|
|
76
|
-
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
77
|
-
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
78
|
-
return
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
postCreativeAnalytic.sendTrackingData(
|
|
82
|
-
campaignId: campaignId,
|
|
83
|
-
adSpaceId: adSpaceId,
|
|
84
|
-
publisherId: publisherId,
|
|
85
|
-
eventType: eventType,
|
|
86
|
-
origin: origin,
|
|
87
|
-
apiKey: apiKey,
|
|
88
|
-
bidId: bidId,
|
|
89
|
-
isTestEnvironment: isTestEnvironment
|
|
90
|
-
) { response in
|
|
91
|
-
if let response = response {
|
|
92
|
-
resolver(response)
|
|
93
|
-
} else {
|
|
94
|
-
rejecter("NO_AD", "Couldn't find the campaign to update analytics", nil)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
64
|
|
|
99
65
|
@objc public func setUserDetails(_ userDetailsDict: [String: Any]) {
|
|
100
66
|
let filtered = userDetailsDict.compactMapValues { value -> Any? in
|
|
@@ -143,6 +109,180 @@ import React
|
|
|
143
109
|
adgeistInstance?.logEvent(event)
|
|
144
110
|
}
|
|
145
111
|
|
|
112
|
+
@objc public func trackImpression(
|
|
113
|
+
campaignId: String,
|
|
114
|
+
adSpaceId: String,
|
|
115
|
+
publisherId: String,
|
|
116
|
+
apiKey: String,
|
|
117
|
+
bidId: String,
|
|
118
|
+
isTestEnvironment: Bool,
|
|
119
|
+
renderTime: Double,
|
|
120
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
121
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
122
|
+
) {
|
|
123
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
124
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
postCreativeAnalytic.trackImpression(
|
|
129
|
+
campaignId: campaignId,
|
|
130
|
+
adSpaceId: adSpaceId,
|
|
131
|
+
publisherId: publisherId,
|
|
132
|
+
apiKey: apiKey,
|
|
133
|
+
bidId: bidId,
|
|
134
|
+
isTestEnvironment: isTestEnvironment,
|
|
135
|
+
renderTime: Float(renderTime)
|
|
136
|
+
)
|
|
137
|
+
resolver("Impression event sent")
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@objc public func trackView(
|
|
141
|
+
campaignId: String,
|
|
142
|
+
adSpaceId: String,
|
|
143
|
+
publisherId: String,
|
|
144
|
+
apiKey: String,
|
|
145
|
+
bidId: String,
|
|
146
|
+
isTestEnvironment: Bool,
|
|
147
|
+
viewTime: Double,
|
|
148
|
+
visibilityRatio: Double,
|
|
149
|
+
scrollDepth: Double,
|
|
150
|
+
timeToVisible: Double,
|
|
151
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
152
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
153
|
+
) {
|
|
154
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
155
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
156
|
+
return
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
postCreativeAnalytic.trackView(
|
|
160
|
+
campaignId: campaignId,
|
|
161
|
+
adSpaceId: adSpaceId,
|
|
162
|
+
publisherId: publisherId,
|
|
163
|
+
apiKey: apiKey,
|
|
164
|
+
bidId: bidId,
|
|
165
|
+
isTestEnvironment: isTestEnvironment,
|
|
166
|
+
viewTime: Float(viewTime),
|
|
167
|
+
visibilityRatio: Float(visibilityRatio),
|
|
168
|
+
scrollDepth: Float(scrollDepth),
|
|
169
|
+
timeToVisible: Float(timeToVisible)
|
|
170
|
+
)
|
|
171
|
+
resolver("View event sent")
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
@objc public func trackTotalView(
|
|
175
|
+
campaignId: String,
|
|
176
|
+
adSpaceId: String,
|
|
177
|
+
publisherId: String,
|
|
178
|
+
apiKey: String,
|
|
179
|
+
bidId: String,
|
|
180
|
+
isTestEnvironment: Bool,
|
|
181
|
+
totalViewTime: Double,
|
|
182
|
+
visibilityRatio: Double,
|
|
183
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
184
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
185
|
+
) {
|
|
186
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
187
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
188
|
+
return
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
postCreativeAnalytic.trackTotalView(
|
|
192
|
+
campaignId: campaignId,
|
|
193
|
+
adSpaceId: adSpaceId,
|
|
194
|
+
publisherId: publisherId,
|
|
195
|
+
apiKey: apiKey,
|
|
196
|
+
bidId: bidId,
|
|
197
|
+
isTestEnvironment: isTestEnvironment,
|
|
198
|
+
totalViewTime: Float(totalViewTime),
|
|
199
|
+
visibilityRatio: Float(visibilityRatio)
|
|
200
|
+
)
|
|
201
|
+
resolver("Total view event sent")
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
@objc public func trackClick(
|
|
205
|
+
campaignId: String,
|
|
206
|
+
adSpaceId: String,
|
|
207
|
+
publisherId: String,
|
|
208
|
+
apiKey: String,
|
|
209
|
+
bidId: String,
|
|
210
|
+
isTestEnvironment: Bool,
|
|
211
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
212
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
213
|
+
) {
|
|
214
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
215
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
postCreativeAnalytic.trackClick(
|
|
220
|
+
campaignId: campaignId,
|
|
221
|
+
adSpaceId: adSpaceId,
|
|
222
|
+
publisherId: publisherId,
|
|
223
|
+
apiKey: apiKey,
|
|
224
|
+
bidId: bidId,
|
|
225
|
+
isTestEnvironment: isTestEnvironment
|
|
226
|
+
)
|
|
227
|
+
resolver("Click event sent")
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@objc public func trackVideoPlayback(
|
|
231
|
+
campaignId: String,
|
|
232
|
+
adSpaceId: String,
|
|
233
|
+
publisherId: String,
|
|
234
|
+
apiKey: String,
|
|
235
|
+
bidId: String,
|
|
236
|
+
isTestEnvironment: Bool,
|
|
237
|
+
totalPlaybackTime: Double,
|
|
238
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
239
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
240
|
+
) {
|
|
241
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
242
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
postCreativeAnalytic.trackVideoPlayback(
|
|
247
|
+
campaignId: campaignId,
|
|
248
|
+
adSpaceId: adSpaceId,
|
|
249
|
+
publisherId: publisherId,
|
|
250
|
+
apiKey: apiKey,
|
|
251
|
+
bidId: bidId,
|
|
252
|
+
isTestEnvironment: isTestEnvironment,
|
|
253
|
+
totalPlaybackTime: Float(totalPlaybackTime)
|
|
254
|
+
)
|
|
255
|
+
resolver("Video playback event sent")
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
@objc public func trackVideoQuartile(
|
|
259
|
+
campaignId: String,
|
|
260
|
+
adSpaceId: String,
|
|
261
|
+
publisherId: String,
|
|
262
|
+
apiKey: String,
|
|
263
|
+
bidId: String,
|
|
264
|
+
isTestEnvironment: Bool,
|
|
265
|
+
quartile: String,
|
|
266
|
+
resolver: @escaping RCTPromiseResolveBlock,
|
|
267
|
+
rejecter: @escaping RCTPromiseRejectBlock
|
|
268
|
+
) {
|
|
269
|
+
guard let postCreativeAnalytic = postCreativeAnalytic else {
|
|
270
|
+
rejecter("SDK_NOT_INITIALIZED", "SDK not initialized. Call initializeSdk() first.", nil)
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
postCreativeAnalytic.trackVideoQuartile(
|
|
275
|
+
campaignId: campaignId,
|
|
276
|
+
adSpaceId: adSpaceId,
|
|
277
|
+
publisherId: publisherId,
|
|
278
|
+
apiKey: apiKey,
|
|
279
|
+
bidId: bidId,
|
|
280
|
+
isTestEnvironment: isTestEnvironment,
|
|
281
|
+
quartile: quartile
|
|
282
|
+
)
|
|
283
|
+
resolver("Video quartile event sent")
|
|
284
|
+
}
|
|
285
|
+
|
|
146
286
|
@objc public static func requiresMainQueueSetup() -> Bool {
|
|
147
287
|
return true
|
|
148
288
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thealteroffice/react-native-adgeist",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.20",
|
|
4
4
|
"description": "Publishers can integrate our SDK to connect their ad spaces to the AdGeist marketplace.",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withRNAdgeistMainApplication = void 0;
|
|
4
|
+
exports.ktFileUpdater = ktFileUpdater;
|
|
5
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
6
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
7
|
+
const withRNAdgeistMainApplication = (config) => {
|
|
8
|
+
return (0, config_plugins_1.withAppBuildGradle)((0, config_plugins_1.withMainApplication)(config, readMainApplicationFileAndUpdateContents), readBuildGradleFileAndUpdateContents);
|
|
9
|
+
};
|
|
10
|
+
exports.withRNAdgeistMainApplication = withRNAdgeistMainApplication;
|
|
11
|
+
// 1. MainActivity Modifications
|
|
12
|
+
async function readMainApplicationFileAndUpdateContents(config) {
|
|
13
|
+
const { modResults: mainApplicationFile } = config;
|
|
14
|
+
const worker = getCompatibleFileUpdater(mainApplicationFile.language);
|
|
15
|
+
mainApplicationFile.contents = worker(mainApplicationFile.contents);
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
function readBuildGradleFileAndUpdateContents(config) {
|
|
19
|
+
const { modResults } = config;
|
|
20
|
+
if (!modResults.contents.includes('implementation "ai.adgeist:adgeistkit:')) {
|
|
21
|
+
modResults.contents = modResults.contents.replace(/dependencies\s*{/, `dependencies {
|
|
22
|
+
implementation "ai.adgeist:adgeistkit:0.0.1" // AdgeistKit Dependency`);
|
|
23
|
+
}
|
|
24
|
+
return config;
|
|
25
|
+
}
|
|
26
|
+
function getCompatibleFileUpdater(language) {
|
|
27
|
+
switch (language) {
|
|
28
|
+
case 'kt':
|
|
29
|
+
return ktFileUpdater;
|
|
30
|
+
default:
|
|
31
|
+
throw new Error(`Cannot add React Native Orientation Director code to MainActivity of language "${language}"`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function ktFileUpdater(originalContents) {
|
|
35
|
+
// Safer anchor detection
|
|
36
|
+
const anchors = [
|
|
37
|
+
/super\.onCreate\(/,
|
|
38
|
+
/@Override\s+fun onCreate\(/,
|
|
39
|
+
/class \w+ : ReactActivity/,
|
|
40
|
+
].find((anchor) => anchor.test(originalContents));
|
|
41
|
+
if (!anchors) {
|
|
42
|
+
throw new Error('Could not find suitable insertion point in MainActivity');
|
|
43
|
+
}
|
|
44
|
+
const packageImportCodeBlock = 'import com.adgeist.AdgeistPackage';
|
|
45
|
+
const rightBeforeClassDeclaration = /import com.facebook.react.ReactPackage/;
|
|
46
|
+
const importMergeResults = (0, generateCode_1.mergeContents)({
|
|
47
|
+
tag: '@react-native-adgeist/package-import',
|
|
48
|
+
src: originalContents,
|
|
49
|
+
newSrc: packageImportCodeBlock,
|
|
50
|
+
anchor: rightBeforeClassDeclaration,
|
|
51
|
+
offset: 0,
|
|
52
|
+
comment: '// React Native Adgeist',
|
|
53
|
+
});
|
|
54
|
+
const onConfigurationChangedCodeBlock = `packages.add(AdgeistPackage())`;
|
|
55
|
+
const rightBeforeOnReturnStatement = /return packages/;
|
|
56
|
+
const implementationMergeResults = (0, generateCode_1.mergeContents)({
|
|
57
|
+
tag: '@react-native-adgeist/package-initialization',
|
|
58
|
+
src: importMergeResults.contents,
|
|
59
|
+
newSrc: onConfigurationChangedCodeBlock,
|
|
60
|
+
anchor: rightBeforeOnReturnStatement,
|
|
61
|
+
offset: 0,
|
|
62
|
+
comment: '// Package Initialization',
|
|
63
|
+
});
|
|
64
|
+
return implementationMergeResults.contents;
|
|
65
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
+
const withRNAdgeistMainApplication_1 = require("./android/withRNAdgeistMainApplication");
|
|
5
|
+
const withRNAdgeistAppDelegate_1 = require("./ios/withRNAdgeistAppDelegate");
|
|
6
|
+
/**
|
|
7
|
+
* So, expo config plugin are awesome and the documentation is well written, but I still needed to look around to see
|
|
8
|
+
* how other projects actually modify the AppDelegate. I've found react-native-firebase to implement a plugin config
|
|
9
|
+
* that changes the AppDelegate, so I'll leave their link as reference:
|
|
10
|
+
* https://github.com/invertase/react-native-firebase/blob/main/packages/app/plugin/src/ios/appDelegate.ts
|
|
11
|
+
*
|
|
12
|
+
* Kudos to them, because this stuff is hard!
|
|
13
|
+
*
|
|
14
|
+
* @param config
|
|
15
|
+
*/
|
|
16
|
+
const withRNAdgeist = (config) => {
|
|
17
|
+
return (0, config_plugins_1.withPlugins)(config, [
|
|
18
|
+
//Android
|
|
19
|
+
withRNAdgeistMainApplication_1.withRNAdgeistMainApplication,
|
|
20
|
+
//iOS
|
|
21
|
+
withRNAdgeistAppDelegate_1.withRNAdgeistAppDelegate,
|
|
22
|
+
]);
|
|
23
|
+
};
|
|
24
|
+
const pak = require('@thealteroffice/react-native-adgeist/package.json');
|
|
25
|
+
exports.default = (0, config_plugins_1.createRunOncePlugin)(withRNAdgeist, pak.name, pak.version);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type ConfigPlugin } from '@expo/config-plugins';
|
|
2
|
+
export declare const withRNAdgeistAppDelegate: ConfigPlugin;
|
|
3
|
+
export declare function swiftFileUpdater(originalContents: string): string;
|
|
4
|
+
export declare function objCFileUpdater(originalContents: string): string;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withRNAdgeistAppDelegate = void 0;
|
|
4
|
+
exports.swiftFileUpdater = swiftFileUpdater;
|
|
5
|
+
exports.objCFileUpdater = objCFileUpdater;
|
|
6
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
7
|
+
const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
|
|
8
|
+
const withRNAdgeistAppDelegate = (config) => {
|
|
9
|
+
return (0, config_plugins_1.withAppDelegate)(config, readAppDelegateFileAndUpdateContents);
|
|
10
|
+
};
|
|
11
|
+
exports.withRNAdgeistAppDelegate = withRNAdgeistAppDelegate;
|
|
12
|
+
async function readAppDelegateFileAndUpdateContents(config) {
|
|
13
|
+
const { modResults: appDelegateFile } = config;
|
|
14
|
+
const worker = getCompatibleFileUpdater(appDelegateFile.language);
|
|
15
|
+
appDelegateFile.contents = worker(appDelegateFile.contents);
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
function getCompatibleFileUpdater(language) {
|
|
19
|
+
switch (language) {
|
|
20
|
+
case 'objc':
|
|
21
|
+
case 'objcpp': {
|
|
22
|
+
return objCFileUpdater;
|
|
23
|
+
}
|
|
24
|
+
case 'swift':
|
|
25
|
+
return swiftFileUpdater;
|
|
26
|
+
default:
|
|
27
|
+
throw new Error(`Cannot add React Native Adgeist code to AppDelegate of language "${language}"`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function swiftFileUpdater(originalContents) {
|
|
31
|
+
const wantsToAddAnyCodeBlock = ``;
|
|
32
|
+
const rightBeforeLastClosingBrace = /didFinishLaunchingWithOptions:\s*launchOptions\)/g;
|
|
33
|
+
const pasteInTheListJustAfterTheClosingBracket = 2;
|
|
34
|
+
const results = (0, generateCode_1.mergeContents)({
|
|
35
|
+
tag: '@react-native-adgeist/implementation',
|
|
36
|
+
src: originalContents,
|
|
37
|
+
newSrc: wantsToAddAnyCodeBlock,
|
|
38
|
+
anchor: rightBeforeLastClosingBrace,
|
|
39
|
+
offset: pasteInTheListJustAfterTheClosingBracket,
|
|
40
|
+
comment: '// React Native Ageist',
|
|
41
|
+
});
|
|
42
|
+
return results.contents;
|
|
43
|
+
}
|
|
44
|
+
function objCFileUpdater(originalContents) {
|
|
45
|
+
const libraryHeaderImportCodeBlock = '#import "Adgeist.h"\n';
|
|
46
|
+
const rightBeforeAppDelegateImplementation = /@implementation\s+\w+/g;
|
|
47
|
+
const headerImportMergeResults = (0, generateCode_1.mergeContents)({
|
|
48
|
+
tag: '@react-native-adgeist/library-header-import',
|
|
49
|
+
src: originalContents,
|
|
50
|
+
newSrc: libraryHeaderImportCodeBlock,
|
|
51
|
+
anchor: rightBeforeAppDelegateImplementation,
|
|
52
|
+
offset: 0,
|
|
53
|
+
comment: '// React Native Ageist',
|
|
54
|
+
});
|
|
55
|
+
const wantsToAddAnyCodeBlock = ``;
|
|
56
|
+
const rightBeforeLastClosingEnd = /@end[^@]*$/g;
|
|
57
|
+
const implementationMergeResults = (0, generateCode_1.mergeContents)({
|
|
58
|
+
tag: '@react-native-adgeist/implementation',
|
|
59
|
+
src: headerImportMergeResults.contents,
|
|
60
|
+
newSrc: wantsToAddAnyCodeBlock,
|
|
61
|
+
anchor: rightBeforeLastClosingEnd,
|
|
62
|
+
offset: 0,
|
|
63
|
+
comment: '// React Native Ageist',
|
|
64
|
+
});
|
|
65
|
+
return implementationMergeResults.contents;
|
|
66
|
+
}
|