cloudx-react-native 3.4.5 → 3.4.7
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/android/build.gradle +1 -1
- package/android/src/main/java/com/cloudxreactnative/CloudXAdEvents.kt +10 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXAdView.kt +244 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXAdViewEvent.kt +28 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXAdViewManagerImpl.kt +54 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXExtraParameters.kt +101 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXModuleImpl.kt +5 -57
- package/android/src/main/java/com/cloudxreactnative/CloudXPackage.kt +1 -1
- package/android/src/newarch/com/cloudxreactnative/CloudXAdViewManager.kt +52 -0
- package/android/src/oldarch/com/cloudxreactnative/CloudXAdViewManager.kt +46 -0
- package/ios/CloudX.mm +13 -57
- package/ios/CloudXAdView.h +35 -0
- package/ios/CloudXAdView.mm +505 -0
- package/ios/CloudXAdViewManager.h +12 -0
- package/ios/CloudXAdViewManager.mm +38 -0
- package/ios/CloudXExtraParameters.h +27 -0
- package/ios/CloudXExtraParameters.mm +117 -0
- package/lib/commonjs/CloudXAdViewBase.js +248 -0
- package/lib/commonjs/CloudXAdViewBase.js.map +1 -0
- package/lib/commonjs/CloudXBannerView.js +27 -0
- package/lib/commonjs/CloudXBannerView.js.map +1 -0
- package/lib/commonjs/CloudXMRECView.js +27 -0
- package/lib/commonjs/CloudXMRECView.js.map +1 -0
- package/lib/commonjs/index.js +16 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/CloudXAdViewNativeComponent.js +30 -0
- package/lib/commonjs/specs/CloudXAdViewNativeComponent.js.map +1 -0
- package/lib/commonjs/version.js +5 -2
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/CloudXAdViewBase.js +240 -0
- package/lib/module/CloudXAdViewBase.js.map +1 -0
- package/lib/module/CloudXBannerView.js +19 -0
- package/lib/module/CloudXBannerView.js.map +1 -0
- package/lib/module/CloudXMRECView.js +19 -0
- package/lib/module/CloudXMRECView.js.map +1 -0
- package/lib/module/index.js +3 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/CloudXAdViewNativeComponent.js +27 -0
- package/lib/module/specs/CloudXAdViewNativeComponent.js.map +1 -0
- package/lib/module/version.js +5 -2
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/CloudXAdViewBase.d.ts +28 -0
- package/lib/typescript/src/CloudXAdViewBase.d.ts.map +1 -0
- package/lib/typescript/src/CloudXBannerView.d.ts +16 -0
- package/lib/typescript/src/CloudXBannerView.d.ts.map +1 -0
- package/lib/typescript/src/CloudXMRECView.d.ts +16 -0
- package/lib/typescript/src/CloudXMRECView.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/CloudXAdViewNativeComponent.d.ts +62 -0
- package/lib/typescript/src/specs/CloudXAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/src/types/AdProps.d.ts +3 -0
- package/lib/typescript/src/types/AdProps.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/lib/typescript/src/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CloudXAdViewBase.tsx +293 -0
- package/src/CloudXBannerView.tsx +20 -0
- package/src/CloudXMRECView.tsx +20 -0
- package/src/index.ts +5 -0
- package/src/specs/CloudXAdViewNativeComponent.ts +84 -0
- package/src/types/AdProps.ts +4 -0
- package/src/version.ts +5 -2
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import type { NativeSyntheticEvent, StyleProp, ViewProps, ViewStyle } from 'react-native';
|
|
4
|
+
import NativeCloudXAdView from './specs/CloudXAdViewNativeComponent';
|
|
5
|
+
import type {
|
|
6
|
+
CloudXAdInfoEvent,
|
|
7
|
+
CloudXAdLoadFailedEvent,
|
|
8
|
+
NativeExtraParameterEntry,
|
|
9
|
+
} from './specs/CloudXAdViewNativeComponent';
|
|
10
|
+
import NativeCloudX from './specs/NativeCloudX';
|
|
11
|
+
import type { CloudXAdInfo, CloudXAdLoadFailedInfo } from './types/AdInfo';
|
|
12
|
+
import type { CloudXAdProps } from './types/AdProps';
|
|
13
|
+
import type { CloudXErrorCode } from './CloudXErrorCode';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Ad format rendered by the in-tree view component.
|
|
17
|
+
*/
|
|
18
|
+
export type CloudXAdViewFormat = 'BANNER' | 'MREC';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Props shared by CloudXBannerView and CloudXMRECView.
|
|
22
|
+
*/
|
|
23
|
+
export type CloudXAdViewProps = CloudXAdProps & ViewProps;
|
|
24
|
+
|
|
25
|
+
/** Internal props: the shared base additionally needs the concrete ad format. */
|
|
26
|
+
type CloudXAdViewBaseProps = CloudXAdViewProps & {
|
|
27
|
+
adFormat: CloudXAdViewFormat;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const AD_SIZE = {
|
|
31
|
+
banner: { width: 320, height: 50 },
|
|
32
|
+
leader: { width: 728, height: 90 },
|
|
33
|
+
mrec: { width: 300, height: 250 },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/*
|
|
37
|
+
* Tablet status is a device constant, but NativeCloudX.isTablet() is async.
|
|
38
|
+
* Cache it at module level so only the first banner in a session can flash
|
|
39
|
+
* phone->leader; every later mount reads the resolved value synchronously.
|
|
40
|
+
*/
|
|
41
|
+
let cachedIsTablet: boolean | null = null;
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* Once the SDK reports initialized it stays initialized for the JS VM's life,
|
|
45
|
+
* so cache it module-wide: only the first ad view mounted before init has to
|
|
46
|
+
* poll + show a placeholder; every later mount renders the native view
|
|
47
|
+
* immediately. Mirrors cachedIsTablet above.
|
|
48
|
+
*/
|
|
49
|
+
let cachedIsInitialized = false;
|
|
50
|
+
|
|
51
|
+
const parseAdValues = (json?: string | null): Record<string, string> => {
|
|
52
|
+
if (!json) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(json);
|
|
57
|
+
return parsed && typeof parsed === 'object' && !Array.isArray(parsed)
|
|
58
|
+
? parsed
|
|
59
|
+
: {};
|
|
60
|
+
} catch {
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const toAdInfo = (event: CloudXAdInfoEvent): CloudXAdInfo => ({
|
|
66
|
+
adUnitId: event.adUnitId,
|
|
67
|
+
adFormat: event.adFormat,
|
|
68
|
+
networkName: event.networkName,
|
|
69
|
+
networkPlacement: event.networkPlacement || null,
|
|
70
|
+
placement: event.placement || null,
|
|
71
|
+
revenue: event.revenue ?? 0,
|
|
72
|
+
adValues: parseAdValues(event.adValuesJson),
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const toLoadFailedInfo = (event: CloudXAdLoadFailedEvent): CloudXAdLoadFailedInfo => ({
|
|
76
|
+
adUnitId: event.adUnitId,
|
|
77
|
+
code: event.code as CloudXErrorCode,
|
|
78
|
+
message: event.message || null,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const warnIgnoredUndefinedExtraParameter = (keyPath: string): void => {
|
|
82
|
+
console.warn(
|
|
83
|
+
`CloudXAdView ignored extra parameter "${keyPath}" because ` +
|
|
84
|
+
'undefined values are not supported. Use null when a value is intentional.'
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const normalizeExtraParameterValue = (
|
|
89
|
+
keyPath: string,
|
|
90
|
+
value: unknown
|
|
91
|
+
): NativeExtraParameterEntry['value'] | undefined => {
|
|
92
|
+
if (value === undefined) {
|
|
93
|
+
warnIgnoredUndefinedExtraParameter(keyPath);
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (Array.isArray(value)) {
|
|
98
|
+
return value.reduce<unknown[]>((items, item, index) => {
|
|
99
|
+
const normalized = normalizeExtraParameterValue(`${keyPath}[${index}]`, item);
|
|
100
|
+
if (normalized !== undefined) {
|
|
101
|
+
items.push(normalized);
|
|
102
|
+
}
|
|
103
|
+
return items;
|
|
104
|
+
}, []);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (value !== null && typeof value === 'object') {
|
|
108
|
+
return Object.entries(value as Record<string, unknown>).reduce<Record<string, unknown>>(
|
|
109
|
+
(object, [childKey, childValue]) => {
|
|
110
|
+
const normalized = normalizeExtraParameterValue(`${keyPath}.${childKey}`, childValue);
|
|
111
|
+
if (normalized !== undefined) {
|
|
112
|
+
object[childKey] = normalized;
|
|
113
|
+
}
|
|
114
|
+
return object;
|
|
115
|
+
},
|
|
116
|
+
{}
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return value;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const toNativeExtraParameterEntries = (
|
|
124
|
+
extraParameters?: CloudXAdProps['extraParameters']
|
|
125
|
+
): ReadonlyArray<NativeExtraParameterEntry> => {
|
|
126
|
+
if (!extraParameters) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return Object.entries(extraParameters as Record<string, unknown>).reduce<NativeExtraParameterEntry[]>(
|
|
131
|
+
(entries, [key, value]) => {
|
|
132
|
+
const normalizedValue = normalizeExtraParameterValue(key, value);
|
|
133
|
+
if (normalizedValue === undefined) {
|
|
134
|
+
return entries;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
entries.push({ key, value: normalizedValue });
|
|
138
|
+
return entries;
|
|
139
|
+
},
|
|
140
|
+
[]
|
|
141
|
+
);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Shared implementation for the in-tree banner/MREC view component. Resolves a
|
|
146
|
+
* default fixed size (overridable via `style`), wires the native per-view direct
|
|
147
|
+
* events to the public CloudXAdProps callbacks, and hosts the native ad view.
|
|
148
|
+
*
|
|
149
|
+
* Note: overriding `style` with a non-IAB size resizes the host frame, not the
|
|
150
|
+
* creative - iOS pins the ad view to the host bounds and Android measures the
|
|
151
|
+
* creative from the host, so the served creative keeps its own standard
|
|
152
|
+
* dimensions inside the resized frame.
|
|
153
|
+
*/
|
|
154
|
+
export const CloudXAdViewBase: React.FC<CloudXAdViewBaseProps> = ({
|
|
155
|
+
adFormat,
|
|
156
|
+
adUnitId,
|
|
157
|
+
placement,
|
|
158
|
+
customData,
|
|
159
|
+
extraParameters,
|
|
160
|
+
onAdLoaded,
|
|
161
|
+
onAdLoadFailed,
|
|
162
|
+
onAdClicked,
|
|
163
|
+
onAdRevenuePaid,
|
|
164
|
+
style,
|
|
165
|
+
...viewProps
|
|
166
|
+
}) => {
|
|
167
|
+
const [isTablet, setIsTablet] = useState(cachedIsTablet ?? false);
|
|
168
|
+
const nativeViewProps = viewProps;
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* Gate native ad-view creation on SDK initialization. A view mounted before
|
|
172
|
+
* CloudX.initialize() completes would create the ad against an uninitialized
|
|
173
|
+
* SDK - on iOS createBannerWithAdUnitId: returns nil and the view is
|
|
174
|
+
* permanently dead (no retry, no load-failed event). There is no init event
|
|
175
|
+
* to subscribe to, so poll isInitialized() until ready, then mount the
|
|
176
|
+
* native view (which is what delivers adUnitId/adFormat and triggers create).
|
|
177
|
+
* Mirrors CloudXNativeAdView. Cached module-wide so only the first pre-init
|
|
178
|
+
* mount pays the placeholder + poll.
|
|
179
|
+
*/
|
|
180
|
+
const [isInitialized, setIsInitialized] = useState(cachedIsInitialized);
|
|
181
|
+
|
|
182
|
+
useEffect(() => {
|
|
183
|
+
if (cachedIsInitialized) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
let cancelled = false;
|
|
187
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
188
|
+
let warnedOnce = false;
|
|
189
|
+
const check = () => {
|
|
190
|
+
NativeCloudX.isInitialized()
|
|
191
|
+
.then((ready) => {
|
|
192
|
+
if (cancelled) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (ready) {
|
|
196
|
+
cachedIsInitialized = true;
|
|
197
|
+
setIsInitialized(true);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (!warnedOnce) {
|
|
201
|
+
warnedOnce = true;
|
|
202
|
+
console.warn(
|
|
203
|
+
'CloudXAdView mounted before CloudX SDK initialization; will render once initialize() completes.'
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
timer = setTimeout(check, 1000);
|
|
207
|
+
})
|
|
208
|
+
.catch((error) => {
|
|
209
|
+
if (cancelled) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
console.warn('CloudXAdView failed to read initialization state:', error);
|
|
213
|
+
timer = setTimeout(check, 1000);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
check();
|
|
217
|
+
return () => {
|
|
218
|
+
cancelled = true;
|
|
219
|
+
if (timer) {
|
|
220
|
+
clearTimeout(timer);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}, []);
|
|
224
|
+
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
if (adFormat !== 'BANNER' || cachedIsTablet !== null) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
let cancelled = false;
|
|
230
|
+
NativeCloudX.isTablet()
|
|
231
|
+
.then((tablet) => {
|
|
232
|
+
cachedIsTablet = tablet;
|
|
233
|
+
if (!cancelled) {
|
|
234
|
+
setIsTablet(tablet);
|
|
235
|
+
}
|
|
236
|
+
})
|
|
237
|
+
.catch(() => {
|
|
238
|
+
/* keep phone default on failure */
|
|
239
|
+
});
|
|
240
|
+
return () => {
|
|
241
|
+
cancelled = true;
|
|
242
|
+
};
|
|
243
|
+
}, [adFormat]);
|
|
244
|
+
|
|
245
|
+
const defaultSize = useMemo<ViewStyle>(() => {
|
|
246
|
+
if (adFormat === 'MREC') {
|
|
247
|
+
return AD_SIZE.mrec;
|
|
248
|
+
}
|
|
249
|
+
return isTablet ? AD_SIZE.leader : AD_SIZE.banner;
|
|
250
|
+
}, [adFormat, isTablet]);
|
|
251
|
+
|
|
252
|
+
const resolvedStyle = useMemo<StyleProp<ViewStyle>>(
|
|
253
|
+
() => [defaultSize, style],
|
|
254
|
+
[defaultSize, style]
|
|
255
|
+
);
|
|
256
|
+
const nativeExtraParameters = useMemo(
|
|
257
|
+
() => toNativeExtraParameterEntries(extraParameters),
|
|
258
|
+
[extraParameters]
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
/*
|
|
262
|
+
* Until the SDK is initialized, render a sized placeholder that reserves
|
|
263
|
+
* the ad slot's layout but does NOT mount the native view (so no pre-init
|
|
264
|
+
* create). Swaps to the real ad view once isInitialized flips true.
|
|
265
|
+
*/
|
|
266
|
+
if (!isInitialized) {
|
|
267
|
+
return <View style={resolvedStyle} {...nativeViewProps} />;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
return (
|
|
271
|
+
<NativeCloudXAdView
|
|
272
|
+
{...nativeViewProps}
|
|
273
|
+
style={resolvedStyle}
|
|
274
|
+
adUnitId={adUnitId}
|
|
275
|
+
adFormat={adFormat}
|
|
276
|
+
placement={placement ?? null}
|
|
277
|
+
customData={customData ?? null}
|
|
278
|
+
extraParameters={nativeExtraParameters}
|
|
279
|
+
onAdLoadedEvent={(e: NativeSyntheticEvent<CloudXAdInfoEvent>) =>
|
|
280
|
+
onAdLoaded?.(toAdInfo(e.nativeEvent))
|
|
281
|
+
}
|
|
282
|
+
onAdLoadFailedEvent={(e: NativeSyntheticEvent<CloudXAdLoadFailedEvent>) =>
|
|
283
|
+
onAdLoadFailed?.(toLoadFailedInfo(e.nativeEvent))
|
|
284
|
+
}
|
|
285
|
+
onAdClickedEvent={(e: NativeSyntheticEvent<CloudXAdInfoEvent>) =>
|
|
286
|
+
onAdClicked?.(toAdInfo(e.nativeEvent))
|
|
287
|
+
}
|
|
288
|
+
onAdRevenuePaidEvent={(e: NativeSyntheticEvent<CloudXAdInfoEvent>) =>
|
|
289
|
+
onAdRevenuePaid?.(toAdInfo(e.nativeEvent))
|
|
290
|
+
}
|
|
291
|
+
/>
|
|
292
|
+
);
|
|
293
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CloudXAdViewBase } from './CloudXAdViewBase';
|
|
3
|
+
import type { CloudXAdViewProps } from './CloudXAdViewBase';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* In-tree banner ad component.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the imperative `CloudXBannerAd` API (a native overlay above the whole
|
|
9
|
+
* RN view tree), this renders the banner as an ordinary React Native view, so
|
|
10
|
+
* app overlays such as toasts layer above it via normal RN z-ordering.
|
|
11
|
+
*
|
|
12
|
+
* Defaults to 320x50 on phones and 728x90 on tablets; override via `style`.
|
|
13
|
+
* Overriding `style` to a non-standard size resizes the host frame, not the
|
|
14
|
+
* creative - the served banner keeps its own IAB dimensions inside that frame.
|
|
15
|
+
*/
|
|
16
|
+
export const CloudXBannerView: React.FC<CloudXAdViewProps> = (props) => (
|
|
17
|
+
<CloudXAdViewBase adFormat="BANNER" {...props} />
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default CloudXBannerView;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CloudXAdViewBase } from './CloudXAdViewBase';
|
|
3
|
+
import type { CloudXAdViewProps } from './CloudXAdViewBase';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* In-tree MREC ad component.
|
|
7
|
+
*
|
|
8
|
+
* Unlike the imperative `CloudXMRECAd` API (a native overlay above the whole RN
|
|
9
|
+
* view tree), this renders the MREC as an ordinary React Native view, so app
|
|
10
|
+
* overlays such as toasts layer above it via normal RN z-ordering.
|
|
11
|
+
*
|
|
12
|
+
* Fixed size of 300x250; override via `style`.
|
|
13
|
+
* Overriding `style` to a non-standard size resizes the host frame, not the
|
|
14
|
+
* creative - the served MREC keeps its own dimensions inside that frame.
|
|
15
|
+
*/
|
|
16
|
+
export const CloudXMRECView: React.FC<CloudXAdViewProps> = (props) => (
|
|
17
|
+
<CloudXAdViewBase adFormat="MREC" {...props} />
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export default CloudXMRECView;
|
package/src/index.ts
CHANGED
|
@@ -10,6 +10,11 @@ export { CloudXBannerAd } from './CloudXBannerAd';
|
|
|
10
10
|
export { CloudXMRECAd } from './CloudXMRECAd';
|
|
11
11
|
export { CloudXAdPosition } from './CloudXAdPosition';
|
|
12
12
|
|
|
13
|
+
// Ad View Components (in-tree; layer correctly under app overlays)
|
|
14
|
+
export { CloudXBannerView } from './CloudXBannerView';
|
|
15
|
+
export { CloudXMRECView } from './CloudXMRECView';
|
|
16
|
+
export type { CloudXAdViewProps, CloudXAdViewFormat } from './CloudXAdViewBase';
|
|
17
|
+
|
|
13
18
|
// Error Codes
|
|
14
19
|
export { CloudXErrorCode } from './CloudXErrorCode';
|
|
15
20
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import type {
|
|
3
|
+
Double,
|
|
4
|
+
DirectEventHandler,
|
|
5
|
+
UnsafeMixed,
|
|
6
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
7
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Payload for ad lifecycle events (load, click, revenue).
|
|
11
|
+
*
|
|
12
|
+
* Codegen cannot express `Record<string, string>`, so the SDK-owned ad values
|
|
13
|
+
* are delivered as a JSON-encoded string in `adValuesJson` and re-parsed into a
|
|
14
|
+
* map by the JS wrapper before surfacing a CloudXAdInfo to the publisher.
|
|
15
|
+
*/
|
|
16
|
+
export type CloudXAdInfoEvent = Readonly<{
|
|
17
|
+
adUnitId: string;
|
|
18
|
+
adFormat: string;
|
|
19
|
+
networkName: string;
|
|
20
|
+
networkPlacement?: string | null;
|
|
21
|
+
placement?: string | null;
|
|
22
|
+
revenue: Double;
|
|
23
|
+
adValuesJson?: string | null;
|
|
24
|
+
}>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Payload for ad load-failure events.
|
|
28
|
+
*/
|
|
29
|
+
export type CloudXAdLoadFailedEvent = Readonly<{
|
|
30
|
+
adUnitId: string;
|
|
31
|
+
code: Double;
|
|
32
|
+
message?: string | null;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
export type NativeExtraParameterEntry = Readonly<{
|
|
36
|
+
key: string;
|
|
37
|
+
value: UnsafeMixed;
|
|
38
|
+
}>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Props for the native CloudXAdView component (banner + MREC).
|
|
42
|
+
*
|
|
43
|
+
* This is the in-tree view component: the ad renders as an ordinary React
|
|
44
|
+
* Native view, so publisher overlays (toasts, modals) layer above it via
|
|
45
|
+
* normal RN z-ordering - unlike the imperative overlay banner API.
|
|
46
|
+
*/
|
|
47
|
+
export interface NativeProps extends ViewProps {
|
|
48
|
+
/** Ad unit ID used to load the ad. */
|
|
49
|
+
adUnitId: string;
|
|
50
|
+
|
|
51
|
+
/*
|
|
52
|
+
* Ad format: "BANNER" or "MREC". Typed as a plain string because codegen
|
|
53
|
+
* cannot express union literals ('BANNER' | 'MREC') on native props; the
|
|
54
|
+
* literal type is enforced upstream at the wrapper layer (CloudXAdViewBase /
|
|
55
|
+
* CloudXBannerView / CloudXMRECView).
|
|
56
|
+
*/
|
|
57
|
+
adFormat: string;
|
|
58
|
+
|
|
59
|
+
/** Optional placement name for reporting. */
|
|
60
|
+
placement?: string | null;
|
|
61
|
+
|
|
62
|
+
/** Optional custom data string. */
|
|
63
|
+
customData?: string | null;
|
|
64
|
+
|
|
65
|
+
/** Extra parameters applied to the underlying ad view. */
|
|
66
|
+
extraParameters: ReadonlyArray<NativeExtraParameterEntry>;
|
|
67
|
+
|
|
68
|
+
/** Called when an ad is successfully loaded. */
|
|
69
|
+
onAdLoadedEvent: DirectEventHandler<CloudXAdInfoEvent>;
|
|
70
|
+
|
|
71
|
+
/** Called when the SDK fails to load an ad. */
|
|
72
|
+
onAdLoadFailedEvent: DirectEventHandler<CloudXAdLoadFailedEvent>;
|
|
73
|
+
|
|
74
|
+
/** Called when the ad is clicked. */
|
|
75
|
+
onAdClickedEvent: DirectEventHandler<CloudXAdInfoEvent>;
|
|
76
|
+
|
|
77
|
+
/** Called when ad revenue is paid. */
|
|
78
|
+
onAdRevenuePaidEvent: DirectEventHandler<CloudXAdInfoEvent>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Native in-tree view component backing CloudXBannerView / CloudXMRECView.
|
|
83
|
+
*/
|
|
84
|
+
export default codegenNativeComponent<NativeProps>('CloudXAdView') as HostComponent<NativeProps>;
|
package/src/types/AdProps.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CloudXAdInfo, CloudXAdLoadFailedInfo } from './AdInfo';
|
|
2
|
+
import type { CloudXExtraParameters } from './ExtraParameters';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Base props shared by ad UI components.
|
|
@@ -13,6 +14,9 @@ export type CloudXAdProps = {
|
|
|
13
14
|
/** Custom data string. */
|
|
14
15
|
customData?: string | null;
|
|
15
16
|
|
|
17
|
+
/** Extra parameters applied to the underlying ad view. */
|
|
18
|
+
extraParameters?: CloudXExtraParameters | null;
|
|
19
|
+
|
|
16
20
|
/** Called when a new ad is successfully loaded. */
|
|
17
21
|
onAdLoaded?: (adInfo: CloudXAdInfo) => void;
|
|
18
22
|
|
package/src/version.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
// Keep PLUGIN_VERSION in sync with the `version` field in package.json.
|
|
2
|
-
// Phase 1
|
|
3
|
-
|
|
2
|
+
// RELEASE.md Phase 1 bumps both together (see the Version Files table).
|
|
3
|
+
// This value is reported to the native SDK in CloudX.initialize() and is used
|
|
4
|
+
// for wrapper-version telemetry/attribution, so a stale value mis-attributes
|
|
5
|
+
// installs to the wrong release.
|
|
6
|
+
export const PLUGIN_VERSION = '3.4.7';
|