@thealteroffice/react-native-adgeist 0.0.20 → 0.0.23-qa
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/README.md +63 -522
- package/android/{generated/java/com/adgeist → app/build/generated/source/codegen/java/com/facebook/fbreact/specs}/NativeAdgeistSpec.java +12 -12
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerDelegate.java +55 -0
- package/android/app/build/generated/source/codegen/java/com/facebook/react/viewmanagers/HTML5AdNativeComponentManagerInterface.java +24 -0
- package/android/{generated → app/build/generated/source/codegen}/jni/RNAdgeistSpec-generated.cpp +12 -12
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.cpp +22 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/ComponentDescriptors.h +24 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.cpp +60 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/EventEmitters.h +49 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/Props.cpp +28 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/Props.h +52 -0
- package/android/{generated → app/build/generated/source/codegen}/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI-generated.cpp +14 -22
- package/android/{generated → app/build/generated/source/codegen}/jni/react/renderer/components/RNAdgeistSpec/RNAdgeistSpecJSI.h +36 -36
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.cpp +17 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/ShadowNodes.h +32 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/States.cpp +16 -0
- package/android/app/build/generated/source/codegen/jni/react/renderer/components/RNAdgeistSpec/States.h +29 -0
- package/android/build.gradle +4 -1
- package/android/src/main/java/com/adgeist/AdgeistPackage.kt +8 -7
- package/android/src/main/java/com/adgeist/components/HTML5AdViewManagerImpl.kt +125 -0
- package/android/src/main/java/com/adgeist/modules/AdgeistImpl.kt +114 -0
- package/android/src/main/java/com/adgeist/utils/CreativeExtensions.kt +151 -0
- package/android/src/newarch/java/com/Adgeist.kt +119 -0
- package/android/src/newarch/java/com/HTML5AdViewManager.kt +77 -0
- package/android/src/oldarch/java/com/Adgeist.kt +132 -0
- package/android/src/oldarch/java/com/HTML5AdViewManager.kt +63 -0
- package/ios/Adgeist-Bridging-Header.h +3 -0
- package/ios/Adgeist.mm +71 -65
- package/ios/AdgeistImpl.swift +127 -132
- package/ios/NativeHTML5AdManager.h +9 -0
- package/ios/NativeHTML5AdManager.mm +183 -0
- package/ios/NativeHTML5AdView.swift +136 -0
- package/lib/module/cdpclient/index.js +1 -25
- package/lib/module/cdpclient/index.js.map +1 -1
- package/lib/module/components/HTML5AdView.js +128 -0
- package/lib/module/components/HTML5AdView.js.map +1 -0
- package/lib/module/components/{BannerAd.js → deprecated/BannerAdView.js} +50 -79
- package/lib/module/components/deprecated/BannerAdView.js.map +1 -0
- package/lib/module/components/{ConsentModal.js → deprecated/ConsentModal.js} +2 -2
- package/lib/module/components/deprecated/ConsentModal.js.map +1 -0
- package/lib/module/constants.js +14 -0
- package/lib/module/constants.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/{components → providers}/AdgeistProvider.js +10 -35
- package/lib/module/providers/AdgeistProvider.js.map +1 -0
- package/lib/module/specs/HTML5AdNativeComponent.ts +46 -0
- package/lib/module/specs/NativeAdgeist.js.map +1 -0
- package/lib/module/types/AdSize.js +2 -0
- package/lib/module/types/AdSize.js.map +1 -0
- package/lib/module/types/CPMAdResponse.js +2 -0
- package/lib/module/types/CPMAdResponse.js.map +1 -0
- package/lib/module/types/FixedAdResponse.js +2 -0
- package/lib/module/types/FixedAdResponse.js.map +1 -0
- package/lib/module/types/HTML5AdNativeComponentProps.js +4 -0
- package/lib/module/types/HTML5AdNativeComponentProps.js.map +1 -0
- package/lib/module/types/Provider.js +2 -0
- package/lib/module/types/Provider.js.map +1 -0
- package/lib/typescript/src/cdpclient/index.d.ts +1 -21
- package/lib/typescript/src/cdpclient/index.d.ts.map +1 -1
- package/lib/typescript/src/components/HTML5AdView.d.ts +3 -0
- package/lib/typescript/src/components/HTML5AdView.d.ts.map +1 -0
- package/lib/typescript/src/components/deprecated/BannerAdView.d.ts +17 -0
- package/lib/typescript/src/components/deprecated/BannerAdView.d.ts.map +1 -0
- package/lib/typescript/src/components/deprecated/ConsentModal.d.ts.map +1 -0
- package/lib/typescript/src/constants.d.ts +10 -0
- package/lib/typescript/src/constants.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/providers/AdgeistProvider.d.ts +9 -0
- package/lib/typescript/src/providers/AdgeistProvider.d.ts.map +1 -0
- package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts +29 -0
- package/lib/typescript/src/specs/HTML5AdNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeAdgeist.d.ts +28 -0
- package/lib/typescript/src/specs/NativeAdgeist.d.ts.map +1 -0
- package/lib/typescript/src/types/AdSize.d.ts +5 -0
- package/lib/typescript/src/types/AdSize.d.ts.map +1 -0
- package/lib/typescript/src/types/CPMAdResponse.d.ts +25 -0
- package/lib/typescript/src/types/CPMAdResponse.d.ts.map +1 -0
- package/lib/typescript/src/types/FixedAdResponse.d.ts +50 -0
- package/lib/typescript/src/types/FixedAdResponse.d.ts.map +1 -0
- package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts +24 -0
- package/lib/typescript/src/types/HTML5AdNativeComponentProps.d.ts.map +1 -0
- package/lib/typescript/src/types/Provider.d.ts +16 -0
- package/lib/typescript/src/types/Provider.d.ts.map +1 -0
- package/package.json +8 -3
- package/react-native.config.js +2 -3
- package/src/cdpclient/index.ts +1 -21
- package/src/components/HTML5AdView.tsx +161 -0
- package/src/components/{BannerAd.tsx → deprecated/BannerAdView.tsx} +80 -115
- package/src/components/{ConsentModal.tsx → deprecated/ConsentModal.tsx} +2 -2
- package/src/constants.ts +8 -0
- package/src/index.tsx +4 -2
- package/src/{components → providers}/AdgeistProvider.tsx +26 -60
- package/src/specs/HTML5AdNativeComponent.ts +46 -0
- package/src/{NativeAdgeist.ts → specs/NativeAdgeist.ts} +26 -25
- package/src/types/AdSize.ts +4 -0
- package/src/types/CPMAdResponse.ts +26 -0
- package/src/types/FixedAdResponse.ts +51 -0
- package/src/types/HTML5AdNativeComponentProps.ts +28 -0
- package/src/types/Provider.ts +16 -0
- package/android/src/main/AndroidManifestNew.xml +0 -2
- package/android/src/main/java/com/adgeist/implementation/AdgeistModuleImpl.kt +0 -252
- package/android/src/newarch/java/com/AdgeistModule.kt +0 -135
- package/android/src/oldarch/java/com/AdgeistModule.kt +0 -148
- package/ios/adgeist-Bridging-Header.h +0 -1
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec-generated.mm +0 -116
- package/ios/generated/RNAdgeistSpec/RNAdgeistSpec.h +0 -133
- package/ios/generated/RNAdgeistSpecJSI-generated.cpp +0 -149
- package/ios/generated/RNAdgeistSpecJSI.h +0 -170
- package/lib/module/NativeAdgeist.js.map +0 -1
- package/lib/module/components/AdgeistProvider.js.map +0 -1
- package/lib/module/components/BannerAd.js.map +0 -1
- package/lib/module/components/ConsentModal.js.map +0 -1
- package/lib/typescript/src/NativeAdgeist.d.ts +0 -28
- package/lib/typescript/src/NativeAdgeist.d.ts.map +0 -1
- package/lib/typescript/src/components/AdgeistProvider.d.ts +0 -50
- package/lib/typescript/src/components/AdgeistProvider.d.ts.map +0 -1
- package/lib/typescript/src/components/BannerAd.d.ts +0 -64
- package/lib/typescript/src/components/BannerAd.d.ts.map +0 -1
- package/lib/typescript/src/components/ConsentModal.d.ts.map +0 -1
- /package/android/{generated → app/build/generated/source/codegen}/jni/CMakeLists.txt +0 -0
- /package/android/{generated → app/build/generated/source/codegen}/jni/RNAdgeistSpec.h +0 -0
- /package/lib/module/{NativeAdgeist.js → specs/NativeAdgeist.js} +0 -0
- /package/lib/typescript/src/components/{ConsentModal.d.ts → deprecated/ConsentModal.d.ts} +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
#import "NativeHTML5AdManager.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
4
|
+
#import <React/RCTConversions.h>
|
|
5
|
+
#import <React/RCTBridgeModule.h>
|
|
6
|
+
|
|
7
|
+
// Swift → ObjC header
|
|
8
|
+
#if __has_include("Adgeist-Swift.h")
|
|
9
|
+
#import "Adgeist-Swift.h"
|
|
10
|
+
#elif __has_include(<adgeist/adgeist-Swift.h>)
|
|
11
|
+
#import <Adgeist/Adgeist-Swift.h>
|
|
12
|
+
#else
|
|
13
|
+
@import adgeist;
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
#import "react/renderer/components/RNAdgeistSpec/ComponentDescriptors.h"
|
|
17
|
+
#import "react/renderer/components/RNAdgeistSpec/EventEmitters.h"
|
|
18
|
+
#import "react/renderer/components/RNAdgeistSpec/Props.h"
|
|
19
|
+
#import "react/renderer/components/RNAdgeistSpec/RCTComponentViewHelpers.h"
|
|
20
|
+
|
|
21
|
+
using namespace facebook::react;
|
|
22
|
+
|
|
23
|
+
@interface RCTNativeHTML5AdManager () <RCTHTML5AdNativeComponentViewProtocol, NativeHTML5AdDelegate>
|
|
24
|
+
@end
|
|
25
|
+
|
|
26
|
+
@implementation RCTNativeHTML5AdManager {
|
|
27
|
+
NativeHTML5AdView *_swiftView;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
- (instancetype)init
|
|
31
|
+
{
|
|
32
|
+
if (self = [super init]) {
|
|
33
|
+
_swiftView = [[NativeHTML5AdView alloc] initWithFrame:CGRectZero];
|
|
34
|
+
_swiftView.delegate = self;
|
|
35
|
+
[self addSubview:_swiftView];
|
|
36
|
+
}
|
|
37
|
+
return self;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
- (void)dealloc
|
|
41
|
+
{
|
|
42
|
+
_swiftView.delegate = nil;
|
|
43
|
+
[_swiftView destroy];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (void)prepareForRecycle
|
|
47
|
+
{
|
|
48
|
+
[super prepareForRecycle];
|
|
49
|
+
[_swiftView destroy];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
- (void)layoutSubviews
|
|
53
|
+
{
|
|
54
|
+
[super layoutSubviews];
|
|
55
|
+
_swiftView.frame = self.bounds;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
- (void)didMoveToSuperview
|
|
59
|
+
{
|
|
60
|
+
[super didMoveToSuperview];
|
|
61
|
+
if (self.superview) {
|
|
62
|
+
[_swiftView triggerViewWillAppear];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
- (void)updateProps:(const facebook::react::Props::Shared &)props
|
|
67
|
+
oldProps:(const facebook::react::Props::Shared &)oldProps
|
|
68
|
+
{
|
|
69
|
+
const auto &newProps = *std::static_pointer_cast<const HTML5AdNativeComponentProps>(props);
|
|
70
|
+
|
|
71
|
+
// Create a default old props if null (without parsing)
|
|
72
|
+
HTML5AdNativeComponentProps defaultOldProps;
|
|
73
|
+
const HTML5AdNativeComponentProps &oldPropsStruct = oldProps
|
|
74
|
+
? *std::static_pointer_cast<const HTML5AdNativeComponentProps>(oldProps)
|
|
75
|
+
: defaultOldProps;
|
|
76
|
+
|
|
77
|
+
if (oldPropsStruct.adUnitID != newProps.adUnitID) {
|
|
78
|
+
_swiftView.adUnitID = newProps.adUnitID.empty()
|
|
79
|
+
? nil
|
|
80
|
+
: [NSString stringWithUTF8String:newProps.adUnitID.c_str()];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (oldPropsStruct.adIsResponsive != newProps.adIsResponsive) {
|
|
84
|
+
_swiftView.adIsResponsive = newProps.adIsResponsive;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (oldPropsStruct.adSize.width != newProps.adSize.width ||
|
|
88
|
+
oldPropsStruct.adSize.height != newProps.adSize.height) {
|
|
89
|
+
|
|
90
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
|
91
|
+
if (newProps.adSize.width != 0.0) {
|
|
92
|
+
dict[@"width"] = @(newProps.adSize.width);
|
|
93
|
+
}
|
|
94
|
+
if (newProps.adSize.height != 0.0) {
|
|
95
|
+
dict[@"height"] = @(newProps.adSize.height);
|
|
96
|
+
}
|
|
97
|
+
_swiftView.adSize = dict.count > 0 ? dict : nil;
|
|
98
|
+
|
|
99
|
+
if (_swiftView.adUnitID != nil) {
|
|
100
|
+
[_swiftView reloadAd];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (oldPropsStruct.adType != newProps.adType) {
|
|
105
|
+
_swiftView.adType = newProps.adType.empty()
|
|
106
|
+
? nil
|
|
107
|
+
: [NSString stringWithUTF8String:newProps.adType.c_str()];
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
[super updateProps:props oldProps:oldProps];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
- (void)onAdLoaded
|
|
114
|
+
{
|
|
115
|
+
if (_eventEmitter) {
|
|
116
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
117
|
+
->onAdLoaded(HTML5AdNativeComponentEventEmitter::OnAdLoaded{});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- (void)onAdFailedToLoad:(NSString *)error
|
|
122
|
+
{
|
|
123
|
+
if (_eventEmitter) {
|
|
124
|
+
HTML5AdNativeComponentEventEmitter::OnAdFailedToLoad event{};
|
|
125
|
+
event.error = error ? std::string([error UTF8String]) : "";
|
|
126
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
127
|
+
->onAdFailedToLoad(event);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
- (void)onAdOpened
|
|
132
|
+
{
|
|
133
|
+
if (_eventEmitter) {
|
|
134
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
135
|
+
->onAdOpened(HTML5AdNativeComponentEventEmitter::OnAdOpened{});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (void)onAdClosed
|
|
140
|
+
{
|
|
141
|
+
if (_eventEmitter) {
|
|
142
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
143
|
+
->onAdClosed(HTML5AdNativeComponentEventEmitter::OnAdClosed{});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
- (void)onAdClicked
|
|
148
|
+
{
|
|
149
|
+
if (_eventEmitter) {
|
|
150
|
+
std::static_pointer_cast<const HTML5AdNativeComponentEventEmitter>(_eventEmitter)
|
|
151
|
+
->onAdClicked(HTML5AdNativeComponentEventEmitter::OnAdClicked{});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
- (void)handleCommand:(NSString const *)commandName args:(NSArray const *)args
|
|
157
|
+
{
|
|
158
|
+
RCTHTML5AdNativeComponentHandleCommand(self, commandName, args);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
- (void)loadAd:(BOOL)isTestMode
|
|
162
|
+
{
|
|
163
|
+
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
|
|
164
|
+
dict[@"isTestMode"] = @(isTestMode);
|
|
165
|
+
[_swiftView loadAd:dict];
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (void)destroy
|
|
169
|
+
{
|
|
170
|
+
[_swiftView destroy];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
174
|
+
{
|
|
175
|
+
return concreteComponentDescriptorProvider<HTML5AdNativeComponentComponentDescriptor>();
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@end
|
|
179
|
+
|
|
180
|
+
Class<RCTComponentViewProtocol> HTML5AdNativeComponentCls(void)
|
|
181
|
+
{
|
|
182
|
+
return RCTNativeHTML5AdManager.class;
|
|
183
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import AdgeistKit
|
|
3
|
+
import React
|
|
4
|
+
|
|
5
|
+
// MARK: - Delegate Protocol (Objective-C compatible)
|
|
6
|
+
@objc public protocol NativeHTML5AdDelegate: NSObjectProtocol {
|
|
7
|
+
@objc func onAdLoaded()
|
|
8
|
+
@objc(onAdFailedToLoad:) func onAdFailedToLoad(error: String)
|
|
9
|
+
@objc func onAdOpened()
|
|
10
|
+
@objc func onAdClosed()
|
|
11
|
+
@objc func onAdClicked()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// MARK: - Main Swift View (Exposed to Objective-C++)
|
|
15
|
+
@objc(NativeHTML5AdView)
|
|
16
|
+
@objcMembers
|
|
17
|
+
public class NativeHTML5AdView: UIView {
|
|
18
|
+
|
|
19
|
+
// MARK: Public Props (accessible from .mm)
|
|
20
|
+
@objc public var adUnitID: String?
|
|
21
|
+
@objc public var adSize: NSDictionary?
|
|
22
|
+
@objc public var adType: String?
|
|
23
|
+
@objc public var adIsResponsive: Bool = false
|
|
24
|
+
|
|
25
|
+
// MARK: Delegate (used to send events back to Fabric manager)
|
|
26
|
+
@objc public weak var delegate: NativeHTML5AdDelegate?
|
|
27
|
+
|
|
28
|
+
// MARK: Private Ad View & Listener
|
|
29
|
+
private var adView: AdView?
|
|
30
|
+
private var adListener: NativeHTML5AdListener?
|
|
31
|
+
private var isTestMode: Bool = false
|
|
32
|
+
|
|
33
|
+
public override init(frame: CGRect) {
|
|
34
|
+
super.init(frame: frame)
|
|
35
|
+
backgroundColor = .clear
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@available(*, unavailable)
|
|
39
|
+
required init?(coder: NSCoder) {
|
|
40
|
+
fatalError("init(coder:) has not been implemented")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public override func layoutSubviews() {
|
|
44
|
+
super.layoutSubviews()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@objc public func triggerViewWillAppear() {
|
|
48
|
+
// adView?.resume()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@objc public func reloadAd() {
|
|
52
|
+
cleanupAdView()
|
|
53
|
+
embedAdView()
|
|
54
|
+
setNeedsLayout()
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@objc public func loadAd(_ options: NSDictionary) {
|
|
58
|
+
if let testMode = options["isTestMode"] as? Bool {
|
|
59
|
+
self.isTestMode = testMode
|
|
60
|
+
}
|
|
61
|
+
reloadAd()
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@objc public func destroy() {
|
|
65
|
+
cleanupAdView()
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private func cleanupAdView() {
|
|
69
|
+
adView?.destroy()
|
|
70
|
+
adView?.removeFromSuperview()
|
|
71
|
+
adView = nil
|
|
72
|
+
adListener = nil
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private func embedAdView() {
|
|
76
|
+
guard let adUnitID = adUnitID else {
|
|
77
|
+
delegate?.onAdFailedToLoad(error: "Ad unit ID is required")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let adView = AdView()
|
|
82
|
+
adView.frame = bounds
|
|
83
|
+
adView.adUnitId = adUnitID
|
|
84
|
+
adView.adIsResposive = adIsResponsive
|
|
85
|
+
|
|
86
|
+
if let dict = adSize as? [String: Any] {
|
|
87
|
+
if let w = dict["width"] as? Int, let h = dict["height"] as? Int {
|
|
88
|
+
adView.setAdDimension(AdSize(width: w, height: h))
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if let adType = adType { adView.adType = adType }
|
|
93
|
+
|
|
94
|
+
let listener = NativeHTML5AdListener(view: self)
|
|
95
|
+
self.adListener = listener
|
|
96
|
+
adView.setAdListener(listener)
|
|
97
|
+
|
|
98
|
+
self.adView = adView
|
|
99
|
+
addSubview(adView)
|
|
100
|
+
|
|
101
|
+
let request = AdRequest.AdRequestBuilder()
|
|
102
|
+
.setTestMode(self.isTestMode)
|
|
103
|
+
.build()
|
|
104
|
+
adView.loadAd(request)
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// MARK: - Ad Listener (Bridge to delegate)
|
|
109
|
+
private class NativeHTML5AdListener: AdListener {
|
|
110
|
+
private weak var view: NativeHTML5AdView?
|
|
111
|
+
|
|
112
|
+
init(view: NativeHTML5AdView) {
|
|
113
|
+
self.view = view
|
|
114
|
+
super.init()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
override func onAdLoaded() {
|
|
118
|
+
view?.delegate?.onAdLoaded()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
override func onAdFailedToLoad(_ errorMessage: String) {
|
|
122
|
+
view?.delegate?.onAdFailedToLoad(error: errorMessage)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override func onAdClicked() {
|
|
126
|
+
view?.delegate?.onAdClicked()
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
override func onAdImpression() {
|
|
130
|
+
view?.delegate?.onAdOpened()
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
override func onAdClosed() {
|
|
134
|
+
view?.delegate?.onAdClosed()
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import Adgeist from "../NativeAdgeist.js";
|
|
3
|
+
import Adgeist from "../specs/NativeAdgeist.js";
|
|
4
4
|
class AdgeistError extends Error {
|
|
5
5
|
constructor(message, code) {
|
|
6
6
|
super(message);
|
|
@@ -9,12 +9,6 @@ class AdgeistError extends Error {
|
|
|
9
9
|
Object.setPrototypeOf(this, AdgeistError.prototype);
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Sets user details in the Adgeist SDK
|
|
15
|
-
* @param userDetails - User details object
|
|
16
|
-
* @throws AdgeistError if the operation fails
|
|
17
|
-
*/
|
|
18
12
|
export const setUserDetails = userDetails => {
|
|
19
13
|
try {
|
|
20
14
|
Adgeist.setUserDetails(userDetails);
|
|
@@ -23,12 +17,6 @@ export const setUserDetails = userDetails => {
|
|
|
23
17
|
throw new AdgeistError(err.message);
|
|
24
18
|
}
|
|
25
19
|
};
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Logs an event in the Adgeist SDK
|
|
29
|
-
* @param event - Event object to log
|
|
30
|
-
* @throws AdgeistError if the event is invalid or logging fails
|
|
31
|
-
*/
|
|
32
20
|
export const logEvent = event => {
|
|
33
21
|
if (!event || typeof event !== 'object') {
|
|
34
22
|
throw new AdgeistError('Event must be a valid object');
|
|
@@ -40,12 +28,6 @@ export const logEvent = event => {
|
|
|
40
28
|
throw new AdgeistError(err.message);
|
|
41
29
|
}
|
|
42
30
|
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Retrieves the consent status from the Adgeist SDK
|
|
46
|
-
* @returns Promise resolving to 'ACCEPTED' or 'DENIED'
|
|
47
|
-
* @throws AdgeistError if the operation fails
|
|
48
|
-
*/
|
|
49
31
|
export const getConsentStatus = async () => {
|
|
50
32
|
try {
|
|
51
33
|
const status = await Adgeist.getConsentStatus();
|
|
@@ -55,12 +37,6 @@ export const getConsentStatus = async () => {
|
|
|
55
37
|
throw new AdgeistError(err.message);
|
|
56
38
|
}
|
|
57
39
|
};
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Updates the consent status in the Adgeist SDK
|
|
61
|
-
* @param consent - Boolean indicating user consent
|
|
62
|
-
* @throws AdgeistError if the operation fails
|
|
63
|
-
*/
|
|
64
40
|
export const updateConsentStatus = consent => {
|
|
65
41
|
try {
|
|
66
42
|
Adgeist.updateConsentStatus(consent);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Adgeist","AdgeistError","Error","constructor","message","code","name","Object","setPrototypeOf","prototype","setUserDetails","userDetails","error","err","logEvent","event","getConsentStatus","status","updateConsentStatus","consent"],"sourceRoot":"../../../src","sources":["cdpclient/index.ts"],"mappings":";;AAAA,OAAOA,OAAO,MAAwC,
|
|
1
|
+
{"version":3,"names":["Adgeist","AdgeistError","Error","constructor","message","code","name","Object","setPrototypeOf","prototype","setUserDetails","userDetails","error","err","logEvent","event","getConsentStatus","status","updateConsentStatus","consent"],"sourceRoot":"../../../src","sources":["cdpclient/index.ts"],"mappings":";;AAAA,OAAOA,OAAO,MAAwC,2BAAwB;AAE9E,MAAMC,YAAY,SAASC,KAAK,CAAC;EAG/BC,WAAWA,CAACC,OAAe,EAAEC,IAAa,EAAE;IAC1C,KAAK,CAACD,OAAO,CAAC;IACd,IAAI,CAACE,IAAI,GAAG,cAAc;IAC1B,IAAI,CAACD,IAAI,GAAGA,IAAI;IAChBE,MAAM,CAACC,cAAc,CAAC,IAAI,EAAEP,YAAY,CAACQ,SAAS,CAAC;EACrD;AACF;AAEA,OAAO,MAAMC,cAAc,GAAIC,WAAwB,IAAW;EAChE,IAAI;IACFX,OAAO,CAACU,cAAc,CAACC,WAAW,CAAC;EACrC,CAAC,CAAC,OAAOC,KAAc,EAAE;IACvB,MAAMC,GAAG,GACPD,KAAK,YAAYV,KAAK,GAAGU,KAAK,GAAG,IAAIV,KAAK,CAAC,4BAA4B,CAAC;IAC1E,MAAM,IAAID,YAAY,CAACY,GAAG,CAACT,OAAO,CAAC;EACrC;AACF,CAAC;AAED,OAAO,MAAMU,QAAQ,GAAIC,KAAY,IAAW;EAC9C,IAAI,CAACA,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,MAAM,IAAId,YAAY,CAAC,8BAA8B,CAAC;EACxD;EACA,IAAI;IACFD,OAAO,CAACc,QAAQ,CAACC,KAAK,CAAC;EACzB,CAAC,CAAC,OAAOH,KAAc,EAAE;IACvB,MAAMC,GAAG,GACPD,KAAK,YAAYV,KAAK,GAAGU,KAAK,GAAG,IAAIV,KAAK,CAAC,qBAAqB,CAAC;IACnE,MAAM,IAAID,YAAY,CAACY,GAAG,CAACT,OAAO,CAAC;EACrC;AACF,CAAC;AAED,OAAO,MAAMY,gBAAgB,GAAG,MAAAA,CAAA,KAA4C;EAC1E,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMjB,OAAO,CAACgB,gBAAgB,CAAC,CAAC;IAC/C,OAAOC,MAAM,KAAK,IAAI,GAAG,UAAU,GAAG,QAAQ;EAChD,CAAC,CAAC,OAAOL,KAAc,EAAE;IACvB,MAAMC,GAAG,GACPD,KAAK,YAAYV,KAAK,GAClBU,KAAK,GACL,IAAIV,KAAK,CAAC,8BAA8B,CAAC;IAC/C,MAAM,IAAID,YAAY,CAACY,GAAG,CAACT,OAAO,CAAC;EACrC;AACF,CAAC;AAED,OAAO,MAAMc,mBAAmB,GAAIC,OAAgB,IAAW;EAC7D,IAAI;IACFnB,OAAO,CAACkB,mBAAmB,CAACC,OAAO,CAAC;EACtC,CAAC,CAAC,OAAOP,KAAc,EAAE;IACvB,MAAMC,GAAG,GACPD,KAAK,YAAYV,KAAK,GAClBU,KAAK,GACL,IAAIV,KAAK,CAAC,iCAAiC,CAAC;IAClD,MAAM,IAAID,YAAY,CAACY,GAAG,CAACT,OAAO,CAAC;EACrC;AACF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useRef, useCallback, useImperativeHandle, forwardRef, useEffect, useState, useMemo } from 'react';
|
|
4
|
+
import { useAdgeistContext } from "../providers/AdgeistProvider.js";
|
|
5
|
+
import HTML5AdNativeComponent, { Commands } from '../specs/HTML5AdNativeComponent';
|
|
6
|
+
import { AdSizes } from "../constants.js";
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
export const HTML5AdView = /*#__PURE__*/forwardRef(({
|
|
9
|
+
adUnitID,
|
|
10
|
+
adIsResponsive,
|
|
11
|
+
adSize,
|
|
12
|
+
adType,
|
|
13
|
+
onAdLoaded,
|
|
14
|
+
onAdFailedToLoad,
|
|
15
|
+
onAdOpened,
|
|
16
|
+
onAdClosed,
|
|
17
|
+
onAdClicked
|
|
18
|
+
}, ref) => {
|
|
19
|
+
const {
|
|
20
|
+
isTestEnvironment
|
|
21
|
+
} = useAdgeistContext();
|
|
22
|
+
const nativeRef = useRef(null);
|
|
23
|
+
const [isViewReady, setIsViewReady] = useState(false);
|
|
24
|
+
const pendingLoadRef = useRef(null);
|
|
25
|
+
const dimensions = useMemo(() => {
|
|
26
|
+
const width = adSize?.width ?? '100%';
|
|
27
|
+
const height = adSize?.height ?? '100%';
|
|
28
|
+
return {
|
|
29
|
+
width,
|
|
30
|
+
height
|
|
31
|
+
};
|
|
32
|
+
}, [adSize?.width, adSize?.height]);
|
|
33
|
+
const containerStyle = useMemo(() => ({
|
|
34
|
+
width: dimensions.width,
|
|
35
|
+
height: dimensions.height
|
|
36
|
+
}), [dimensions]);
|
|
37
|
+
const loadAdInternal = useCallback((request = {
|
|
38
|
+
isTestMode: isTestEnvironment
|
|
39
|
+
}) => {
|
|
40
|
+
if (!nativeRef.current) {
|
|
41
|
+
console.warn('HTML5AdView: Cannot load ad, native view not ready');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const finalRequest = {
|
|
45
|
+
...request,
|
|
46
|
+
isTestMode: request.isTestMode ?? isTestEnvironment
|
|
47
|
+
};
|
|
48
|
+
try {
|
|
49
|
+
Commands.loadAd(nativeRef.current, finalRequest.isTestMode);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (__DEV__) {
|
|
52
|
+
console.warn('HTML5AdView: Error loading ad:', error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [isTestEnvironment]);
|
|
56
|
+
const handleNativeRef = useCallback(ref => {
|
|
57
|
+
nativeRef.current = ref;
|
|
58
|
+
if (ref) {
|
|
59
|
+
// Mark as ready in the next animation frame (ensures layout pass completed)
|
|
60
|
+
requestAnimationFrame(() => {
|
|
61
|
+
setIsViewReady(true);
|
|
62
|
+
});
|
|
63
|
+
} else {
|
|
64
|
+
setIsViewReady(false);
|
|
65
|
+
}
|
|
66
|
+
}, []);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
if (isViewReady && adUnitID) {
|
|
69
|
+
const request = {
|
|
70
|
+
isTestMode: isTestEnvironment
|
|
71
|
+
};
|
|
72
|
+
if (pendingLoadRef.current) {
|
|
73
|
+
loadAdInternal(pendingLoadRef.current);
|
|
74
|
+
pendingLoadRef.current = null;
|
|
75
|
+
} else {
|
|
76
|
+
loadAdInternal(request);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, [isViewReady, adUnitID, isTestEnvironment, loadAdInternal]);
|
|
80
|
+
useImperativeHandle(ref, () => ({
|
|
81
|
+
loadAd: adRequest => {
|
|
82
|
+
const request = adRequest || {
|
|
83
|
+
isTestMode: isTestEnvironment
|
|
84
|
+
};
|
|
85
|
+
if (isViewReady && nativeRef.current) {
|
|
86
|
+
loadAdInternal(request);
|
|
87
|
+
} else {
|
|
88
|
+
pendingLoadRef.current = request;
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
destroy: () => {
|
|
92
|
+
if (nativeRef.current) {
|
|
93
|
+
try {
|
|
94
|
+
Commands.destroy(nativeRef.current);
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.warn('Error destroying ad view:', e);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}), [isViewReady, isTestEnvironment, loadAdInternal]);
|
|
101
|
+
if (__DEV__) {
|
|
102
|
+
console.log('[HTML5AdView]', {
|
|
103
|
+
adUnitID,
|
|
104
|
+
adSize,
|
|
105
|
+
adType,
|
|
106
|
+
isViewReady
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return /*#__PURE__*/_jsx(HTML5AdNativeComponent, {
|
|
110
|
+
ref: handleNativeRef,
|
|
111
|
+
style: containerStyle
|
|
112
|
+
// Required Props, it will take values from React Component props
|
|
113
|
+
,
|
|
114
|
+
adUnitID: adUnitID,
|
|
115
|
+
adSize: adIsResponsive ? AdSizes.Responsive : adSize,
|
|
116
|
+
adIsResponsive: adIsResponsive,
|
|
117
|
+
adType: adType
|
|
118
|
+
// Required Event Callbacks
|
|
119
|
+
,
|
|
120
|
+
onAdLoaded: onAdLoaded,
|
|
121
|
+
onAdFailedToLoad: onAdFailedToLoad,
|
|
122
|
+
onAdOpened: onAdOpened,
|
|
123
|
+
onAdClosed: onAdClosed,
|
|
124
|
+
onAdClicked: onAdClicked
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
HTML5AdView.displayName = 'HTML5AdView';
|
|
128
|
+
//# sourceMappingURL=HTML5AdView.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useRef","useCallback","useImperativeHandle","forwardRef","useEffect","useState","useMemo","useAdgeistContext","HTML5AdNativeComponent","Commands","AdSizes","jsx","_jsx","HTML5AdView","adUnitID","adIsResponsive","adSize","adType","onAdLoaded","onAdFailedToLoad","onAdOpened","onAdClosed","onAdClicked","ref","isTestEnvironment","nativeRef","isViewReady","setIsViewReady","pendingLoadRef","dimensions","width","height","containerStyle","loadAdInternal","request","isTestMode","current","console","warn","finalRequest","loadAd","error","__DEV__","handleNativeRef","requestAnimationFrame","adRequest","destroy","e","log","style","Responsive","displayName"],"sourceRoot":"../../../src","sources":["components/HTML5AdView.tsx"],"mappings":";;AAAA,SACEA,MAAM,EACNC,WAAW,EACXC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