cloudx-react-native 3.11.0 → 3.11.1
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 +9 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXAdInfo.kt +76 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXModuleImpl.kt +110 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXNativeAdHolder.kt +184 -0
- package/android/src/main/java/com/cloudxreactnative/CloudXNativeAdView.kt +209 -70
- package/android/src/main/java/com/cloudxreactnative/CloudXNativeAdViewManagerImpl.kt +6 -0
- package/android/src/newarch/com/cloudxreactnative/CloudXModule.kt +9 -0
- package/android/src/newarch/com/cloudxreactnative/CloudXNativeAdViewManager.kt +2 -0
- package/android/src/oldarch/com/cloudxreactnative/CloudXModule.kt +14 -0
- package/android/src/oldarch/com/cloudxreactnative/CloudXNativeAdViewManager.kt +3 -0
- package/android/src/test/java/com/cloudxreactnative/CloudXNativeAdPreloadTest.kt +351 -0
- package/android/src/test/java/com/cloudxreactnative/FakeReadable.kt +2 -2
- package/ios/CloudX.h +12 -0
- package/ios/CloudX.mm +94 -1
- package/ios/CloudXNativeAdHolder.h +66 -0
- package/ios/CloudXNativeAdHolder.mm +247 -0
- package/ios/CloudXNativeAdView.h +9 -0
- package/ios/CloudXNativeAdView.mm +308 -64
- package/ios/CloudXNativeAdViewManager.mm +7 -0
- package/lib/commonjs/CloudXNativeAd.js +178 -0
- package/lib/commonjs/CloudXNativeAd.js.map +1 -0
- package/lib/commonjs/CloudXNativeAdView.js +58 -11
- package/lib/commonjs/CloudXNativeAdView.js.map +1 -1
- package/lib/commonjs/hooks.js +203 -0
- package/lib/commonjs/hooks.js.map +1 -1
- package/lib/commonjs/index.js +13 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/CloudXNativeAdViewNativeComponent.js +2 -0
- package/lib/commonjs/specs/CloudXNativeAdViewNativeComponent.js.map +1 -1
- package/lib/commonjs/specs/NativeCloudX.js.map +1 -1
- package/lib/commonjs/types/NativeAd.js +21 -1
- package/lib/commonjs/types/NativeAd.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/CloudXNativeAd.js +170 -0
- package/lib/module/CloudXNativeAd.js.map +1 -0
- package/lib/module/CloudXNativeAdView.js +58 -11
- package/lib/module/CloudXNativeAdView.js.map +1 -1
- package/lib/module/hooks.js +202 -0
- package/lib/module/hooks.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/CloudXNativeAdViewNativeComponent.js +2 -0
- package/lib/module/specs/CloudXNativeAdViewNativeComponent.js.map +1 -1
- package/lib/module/specs/NativeCloudX.js.map +1 -1
- package/lib/module/types/NativeAd.js +26 -1
- package/lib/module/types/NativeAd.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/src/CloudXNativeAd.d.ts +58 -0
- package/lib/typescript/src/CloudXNativeAd.d.ts.map +1 -0
- package/lib/typescript/src/CloudXNativeAdView.d.ts +6 -13
- package/lib/typescript/src/CloudXNativeAdView.d.ts.map +1 -1
- package/lib/typescript/src/hooks.d.ts +30 -0
- package/lib/typescript/src/hooks.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +4 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/CloudXNativeAdViewNativeComponent.d.ts +23 -2
- package/lib/typescript/src/specs/CloudXNativeAdViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeCloudX.d.ts +13 -0
- package/lib/typescript/src/specs/NativeCloudX.d.ts.map +1 -1
- package/lib/typescript/src/types/NativeAd.d.ts +76 -13
- package/lib/typescript/src/types/NativeAd.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/CloudXNativeAd.ts +177 -0
- package/src/CloudXNativeAdView.tsx +82 -15
- package/src/hooks.ts +236 -0
- package/src/index.ts +14 -1
- package/src/specs/CloudXNativeAdViewNativeComponent.ts +27 -2
- package/src/specs/NativeCloudX.ts +20 -0
- package/src/types/NativeAd.ts +85 -18
- package/src/types/index.ts +4 -0
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CloudXNativeAdViewNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/specs/CloudXNativeAdViewNativeComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EACR,MAAM,EACN,KAAK,EACL,kBAAkB,EAClB,WAAW,EACd,MAAM,2CAA2C,CAAC;AAInD;;;;;;;;;GASG;AACH,MAAM,MAAM,uBAAuB,GAAG,QAAQ,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAAC;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,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T: string;
|
|
51
|
+
ON_NATIVE_AD_CLOSED_EVENT: string;
|
|
52
|
+
ON_NATIVE_AD_REVENUE_PAID: string;
|
|
49
53
|
};
|
|
50
54
|
isInitialized(): Promise<boolean>;
|
|
51
55
|
initialize(pluginVersion: string, appKey: string): Promise<CloudXConfiguration>;
|
|
@@ -103,6 +107,15 @@ export interface Spec extends TurboModule {
|
|
|
103
107
|
isAppOpenReady(adUnitId: string): Promise<boolean>;
|
|
104
108
|
showAppOpen(adUnitId: string, placement?: string | null, customData?: string | null): void;
|
|
105
109
|
destroyAppOpen(adUnitId: string): void;
|
|
110
|
+
/**
|
|
111
|
+
* Loads a native ad with no view attached. Resolves with
|
|
112
|
+
* `{ nativeAdId, adInfo }` once an ad is held natively; rejects with the
|
|
113
|
+
* CloudX error code as the promise code. The ad stays held until
|
|
114
|
+
* `destroyNativeAd`, expiry, or module invalidation.
|
|
115
|
+
*/
|
|
116
|
+
loadNativeAd(adUnitId: string, options: UnsafeObject): Promise<UnsafeObject>;
|
|
117
|
+
/** Releases a held native ad. Idempotent; unknown ids are ignored. */
|
|
118
|
+
destroyNativeAd(nativeAdId: string): void;
|
|
106
119
|
addListener(eventName: string): void;
|
|
107
120
|
removeListeners(count: number): void;
|
|
108
121
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeCloudX.d.ts","sourceRoot":"","sources":["../../../../src/specs/NativeCloudX.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AAE9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,WAAW,IAAK,SAAQ,WAAW;IAKrC,QAAQ,CAAC,YAAY,EAAE,MAAM;QAEzB,yBAAyB,EAAE,MAAM,CAAC;QAClC,8BAA8B,EAAE,MAAM,CAAC;QACv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|
4
|
-
import type { CloudXExtraParameterValue } from './ExtraParameters';
|
|
4
|
+
import type { CloudXExtraParameters, CloudXExtraParameterValue } from './ExtraParameters';
|
|
5
|
+
import type { CloudXNativeAd } from '../CloudXNativeAd';
|
|
5
6
|
/**
|
|
6
7
|
* Built-in native ad template variants rendered by the SDK's view component.
|
|
7
8
|
*
|
|
@@ -75,40 +76,102 @@ export type CloudXLocalExtraParameters = {
|
|
|
75
76
|
[key: string]: CloudXExtraParameterValue;
|
|
76
77
|
};
|
|
77
78
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* `onAdClicked`, `onAdRevenuePaid`) receive unwrapped payloads, not synthetic events.
|
|
79
|
+
* Load-time options for {@link CloudXNativeAd.load}. These configure the
|
|
80
|
+
* auction and the loader, so they are fixed once the ad is loaded; the view
|
|
81
|
+
* that later renders the ad only chooses the layout.
|
|
82
82
|
*/
|
|
83
|
-
export type
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
export type CloudXNativeAdLoadOptions = {
|
|
84
|
+
placement?: string | null;
|
|
85
|
+
customData?: string | null;
|
|
86
|
+
extraParameters?: CloudXExtraParameters | null;
|
|
87
|
+
localExtraParameters?: CloudXLocalExtraParameters | null;
|
|
86
88
|
disableVideoFullScreen?: boolean;
|
|
87
89
|
startVideoUnmuted?: boolean;
|
|
88
90
|
hideVideoMediaControls?: boolean;
|
|
91
|
+
};
|
|
92
|
+
/** Events a preloaded {@link CloudXNativeAd} reports on its own handle. */
|
|
93
|
+
export type CloudXNativeAdEventType = 'clicked' | 'revenuePaid' | 'expired' | 'closed';
|
|
94
|
+
/** Props every native-ad view accepts, whichever way the ad was loaded. */
|
|
95
|
+
type CloudXNativeAdViewRenderProps = ViewProps & {
|
|
96
|
+
template?: CloudXNativeTemplate;
|
|
89
97
|
/** Selects between the SDK's bundled template layouts and manual asset binding. */
|
|
90
98
|
renderMode?: 'template' | 'manual';
|
|
91
99
|
/**
|
|
92
|
-
* Called
|
|
100
|
+
* Called each time the ad is rendered into this view and registered for
|
|
101
|
+
* click and impression tracking. Fires again after a re-bind.
|
|
102
|
+
*/
|
|
103
|
+
onAdDisplayed?: (adInfo: CloudXAdInfo) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Called when an ad fails to display or track in this view.
|
|
93
106
|
*
|
|
94
107
|
* Emitted on both platforms. Android fires it for post-load
|
|
95
108
|
* adapter/render errors and when click/impression registration fails in
|
|
96
|
-
* manual mode. iOS fires it on the
|
|
97
|
-
*
|
|
109
|
+
* manual mode. iOS fires it on the manual-mode failure paths: render
|
|
110
|
+
* requested before load, expired ad, and registration refused. With
|
|
111
|
+
* `nativeAd`, it also fires when the handle is destroyed or expired.
|
|
98
112
|
*/
|
|
99
113
|
onAdDisplayFailed?: (errorInfo: CloudXAdDisplayFailedInfo) => void;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* Props for a native-ad view that loads its own ad when it attaches and
|
|
117
|
+
* destroys it on unmount. This is the shape `CloudXNativeAdView` has always
|
|
118
|
+
* taken, so wrappers that extend, `Omit` or `Pick` it keep compiling.
|
|
119
|
+
*
|
|
120
|
+
* Callbacks inherited from {@link CloudXAdProps} (`onAdLoaded`, `onAdLoadFailed`,
|
|
121
|
+
* `onAdClicked`, `onAdRevenuePaid`) receive unwrapped payloads, not synthetic events.
|
|
122
|
+
*/
|
|
123
|
+
export type CloudXNativeAdViewProps = CloudXNativeAdViewRenderProps & CloudXAdProps & {
|
|
124
|
+
localExtraParameters?: CloudXLocalExtraParameters;
|
|
125
|
+
disableVideoFullScreen?: boolean;
|
|
126
|
+
startVideoUnmuted?: boolean;
|
|
127
|
+
hideVideoMediaControls?: boolean;
|
|
100
128
|
onAdExpired?: (adInfo: CloudXAdInfo) => void;
|
|
101
129
|
onAdClosed?: (adInfo: CloudXAdInfo) => void;
|
|
130
|
+
nativeAd?: never;
|
|
102
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* The view renders an ad loaded earlier with {@link CloudXNativeAd.load}. It
|
|
134
|
+
* never loads and never destroys the ad. Clicks, revenue, expiry and close
|
|
135
|
+
* are reported once, on the handle (`nativeAd.addListener`), never on the
|
|
136
|
+
* view, so revenue cannot be counted twice.
|
|
137
|
+
*/
|
|
138
|
+
export type CloudXNativeAdViewPreloadedProps = CloudXNativeAdViewRenderProps & {
|
|
139
|
+
nativeAd: CloudXNativeAd;
|
|
140
|
+
adUnitId?: never;
|
|
141
|
+
placement?: never;
|
|
142
|
+
customData?: never;
|
|
143
|
+
extraParameters?: never;
|
|
144
|
+
localExtraParameters?: never;
|
|
145
|
+
disableVideoFullScreen?: never;
|
|
146
|
+
startVideoUnmuted?: never;
|
|
147
|
+
hideVideoMediaControls?: never;
|
|
148
|
+
onAdLoaded?: never;
|
|
149
|
+
onAdLoadFailed?: never;
|
|
150
|
+
onAdClicked?: never;
|
|
151
|
+
onAdRevenuePaid?: never;
|
|
152
|
+
onAdExpired?: never;
|
|
153
|
+
onAdClosed?: never;
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Everything `CloudXNativeAdView` accepts: either it loads its own ad
|
|
157
|
+
* ({@link CloudXNativeAdViewProps}) or it renders one loaded earlier
|
|
158
|
+
* ({@link CloudXNativeAdViewPreloadedProps}). Mixing the two is a type error.
|
|
159
|
+
*/
|
|
160
|
+
export type CloudXNativeAdViewComponentProps = CloudXNativeAdViewProps | CloudXNativeAdViewPreloadedProps;
|
|
103
161
|
export type CloudXNativeAdViewHandle = {
|
|
104
162
|
/**
|
|
105
|
-
* Requests a load.
|
|
163
|
+
* Requests a load. No-op when the view renders a preloaded `nativeAd`.
|
|
164
|
+
* This does NOT force a new auction: both native SDKs
|
|
106
165
|
* re-serve the ad they already hold while it is neither expired nor
|
|
107
166
|
* destroyed, including after its impression. Changed targeting is
|
|
108
167
|
* therefore not picked up. Call `destroyAd()` first for a fresh ad.
|
|
109
168
|
*/
|
|
110
169
|
loadAd: () => void;
|
|
111
|
-
/**
|
|
170
|
+
/**
|
|
171
|
+
* Releases the native ad and its resources. No-op when the view renders a
|
|
172
|
+
* preloaded `nativeAd`: the handle owns that ad, so call `nativeAd.destroy()`.
|
|
173
|
+
*/
|
|
112
174
|
destroyAd: () => void;
|
|
113
175
|
};
|
|
176
|
+
export {};
|
|
114
177
|
//# sourceMappingURL=NativeAd.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeAd.d.ts","sourceRoot":"","sources":["../../../../src/types/NativeAd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeAd.d.ts","sourceRoot":"","sources":["../../../../src/types/NativeAd.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,yBAAyB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,oBAAoB;IAC5B,6DAA6D;IAC7D,KAAK,mBAAmB;IAExB,wBAAwB;IACxB,MAAM,oBAAoB;IAE1B,sCAAsC;IACtC,YAAY,0BAA0B;IAEtC;;;;OAIG;IACH,cAAc,4BAA4B;CAC7C;AAED;;GAEG;AACH,oBAAY,qBAAqB;IAC7B,KAAK,cAAc;IACnB,UAAU,m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sB,CAAC,EAAE,KAAK,CAAC;IAC/B,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,cAAc,CAAC,EAAE,KAAK,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,eAAe,CAAC,EAAE,KAAK,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC;IACpB,UAAU,CAAC,EAAE,KAAK,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,GAAG,uBAAuB,GAAG,gCAAgC,CAAC;AAE1G,MAAM,MAAM,wBAAwB,GAAG;IACnC;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB;;;OAGG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;CACzB,CAAC"}
|
|
@@ -14,6 +14,6 @@ export type { CloudXMRECAdType } from './MRECAd';
|
|
|
14
14
|
export type { CloudXAdProps } from './AdProps';
|
|
15
15
|
export type { CloudXAdEventObject, CloudXAdEventListener } from './AdEvent';
|
|
16
16
|
export type { CloudXExtraParameterValue, CloudXExtraParameters } from './ExtraParameters';
|
|
17
|
-
export type { CloudXNativeAdMetadata, CloudXNativeAdViewHandle, CloudXNativeAdViewProps, CloudXLocalExtraParameters, } from './NativeAd';
|
|
17
|
+
export type { CloudXNativeAdMetadata, CloudXNativeAdViewHandle, CloudXNativeAdViewProps, CloudXNativeAdViewComponentProps, CloudXNativeAdViewPreloadedProps, CloudXNativeAdLoadOptions, CloudXNativeAdEventType, CloudXLocalExtraParameters, } from './NativeAd';
|
|
18
18
|
export { CloudXNativeTemplate, CloudXNativeAssetType } from './NativeAd';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,UAAU,C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C7B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const PLUGIN_VERSION = "3.11.
|
|
1
|
+
export declare const PLUGIN_VERSION = "3.11.1";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import type { EventSubscription } from 'react-native';
|
|
2
|
+
import { emitter } from './EventEmitter';
|
|
3
|
+
import { toNativeExtraParameterEntries } from './extraParameters';
|
|
4
|
+
import NativeCloudX from './specs/NativeCloudX';
|
|
5
|
+
import type { CloudXErrorCode } from './CloudXErrorCode';
|
|
6
|
+
import type { CloudXAdInfo, CloudXAdLoadFailedInfo } from './types/AdInfo';
|
|
7
|
+
import type { CloudXNativeAdEventType, CloudXNativeAdLoadOptions, CloudXNativeAdMetadata } from './types/NativeAd';
|
|
8
|
+
|
|
9
|
+
const {
|
|
10
|
+
ON_NATIVE_AD_CLICKED_EVENT,
|
|
11
|
+
ON_NATIVE_AD_EXPIRED_EVENT,
|
|
12
|
+
ON_NATIVE_AD_CLOSED_EVENT,
|
|
13
|
+
ON_NATIVE_AD_REVENUE_PAID,
|
|
14
|
+
} = NativeCloudX.getConstants();
|
|
15
|
+
|
|
16
|
+
type NativeAdEventPayload = Partial<CloudXAdInfo> & { nativeAdId?: string };
|
|
17
|
+
type NativeAdListener = (adInfo: CloudXAdInfo) => void;
|
|
18
|
+
|
|
19
|
+
const toAdInfo = (payload: NativeAdEventPayload, adUnitId: string): CloudXAdInfo => ({
|
|
20
|
+
adUnitId: payload.adUnitId ?? adUnitId,
|
|
21
|
+
adFormat: payload.adFormat ?? 'NATIVE',
|
|
22
|
+
networkName: payload.networkName ?? '',
|
|
23
|
+
networkPlacement: payload.networkPlacement ?? null,
|
|
24
|
+
placement: payload.placement ?? null,
|
|
25
|
+
creativeId: payload.creativeId ?? null,
|
|
26
|
+
revenue: payload.revenue ?? 0,
|
|
27
|
+
adValues: payload.adValues ?? {},
|
|
28
|
+
nativeAd: payload.nativeAd ?? null,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Live handles by native id. Native events arrive on the module-wide emitter
|
|
32
|
+
// and are routed here, so a handle never hears another ad's events.
|
|
33
|
+
const liveAds = new Map<string, CloudXNativeAd>();
|
|
34
|
+
let routingSubscriptions: EventSubscription[] | null = null;
|
|
35
|
+
|
|
36
|
+
const ensureEventRouting = (): void => {
|
|
37
|
+
if (routingSubscriptions) return;
|
|
38
|
+
const route = (type: CloudXNativeAdEventType) => (payload: NativeAdEventPayload) => {
|
|
39
|
+
const ad = payload.nativeAdId ? liveAds.get(payload.nativeAdId) : undefined;
|
|
40
|
+
ad?._handleNativeEvent(type, payload);
|
|
41
|
+
};
|
|
42
|
+
// Subscribe on the shared emitter directly: the module-level
|
|
43
|
+
// addEventListener helper keeps one listener per event name and would
|
|
44
|
+
// replace a publisher's own subscription.
|
|
45
|
+
routingSubscriptions = [
|
|
46
|
+
emitter.addListener(ON_NATIVE_AD_CLICKED_EVENT, route('clicked')),
|
|
47
|
+
emitter.addListener(ON_NATIVE_AD_REVENUE_PAID, route('revenuePaid')),
|
|
48
|
+
emitter.addListener(ON_NATIVE_AD_EXPIRED_EVENT, route('expired')),
|
|
49
|
+
emitter.addListener(ON_NATIVE_AD_CLOSED_EVENT, route('closed')),
|
|
50
|
+
];
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const toLoadFailedInfo = (adUnitId: string, error: unknown): CloudXAdLoadFailedInfo => {
|
|
54
|
+
const { code, message } = (error ?? {}) as { code?: unknown; message?: unknown };
|
|
55
|
+
const numeric = Number(code);
|
|
56
|
+
return {
|
|
57
|
+
adUnitId,
|
|
58
|
+
code: (Number.isFinite(numeric) ? numeric : 0) as CloudXErrorCode,
|
|
59
|
+
message: typeof message === 'string' ? message : null,
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* A native ad loaded ahead of its view.
|
|
65
|
+
*
|
|
66
|
+
* Load it whenever it suits the app, then render it with
|
|
67
|
+
* `<CloudXNativeAdView nativeAd={ad} />`. The handle owns the ad: unmounting a
|
|
68
|
+
* view never destroys it, and its impression is counted once. Clicks, revenue,
|
|
69
|
+
* expiry and close are reported here, not on the view.
|
|
70
|
+
*
|
|
71
|
+
* Moving an ad to another view differs by platform:
|
|
72
|
+
* - iOS: mount another view with the same ad and it shows there; the latest
|
|
73
|
+
* view wins.
|
|
74
|
+
* - Android: once the ad has been shown in a view, it stays with that view.
|
|
75
|
+
* Any other view, including a remounted list cell or a reopened screen,
|
|
76
|
+
* reports `onAdDisplayFailed` with `AD_ALREADY_SHOWING`. Load a fresh ad
|
|
77
|
+
* for each new view.
|
|
78
|
+
*
|
|
79
|
+
* An ad that expires before its impression (its `revenuePaid` event) reports
|
|
80
|
+
* `expired` on both platforms, even if it was already shown in a view.
|
|
81
|
+
*
|
|
82
|
+
* Call `destroy()` when the ad is no longer needed.
|
|
83
|
+
*/
|
|
84
|
+
export class CloudXNativeAd {
|
|
85
|
+
readonly id: string;
|
|
86
|
+
readonly adUnitId: string;
|
|
87
|
+
/** Ad info as of load. Revenue callbacks carry the impression-time values. */
|
|
88
|
+
readonly info: CloudXAdInfo;
|
|
89
|
+
/** Asset metadata for manual layouts; `null` if the network reported none. */
|
|
90
|
+
readonly metadata: CloudXNativeAdMetadata | null;
|
|
91
|
+
|
|
92
|
+
private expired = false;
|
|
93
|
+
private destroyed = false;
|
|
94
|
+
private readonly listeners = new Map<CloudXNativeAdEventType, Set<NativeAdListener>>();
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Loads a native ad without a view. Resolves once the ad is held natively;
|
|
98
|
+
* rejects with a `CloudXAdLoadFailedInfo`.
|
|
99
|
+
*
|
|
100
|
+
* Loads per ad unit are limited, so preload several ads one after another
|
|
101
|
+
* rather than all at once.
|
|
102
|
+
*/
|
|
103
|
+
static async load(adUnitId: string, options: CloudXNativeAdLoadOptions = {}): Promise<CloudXNativeAd> {
|
|
104
|
+
ensureEventRouting();
|
|
105
|
+
// Extra parameters cross the bridge as {key, value} entries, the same
|
|
106
|
+
// wire format CloudXNativeAdView sends, so both native load paths
|
|
107
|
+
// configure the loader through one helper.
|
|
108
|
+
const wireOptions = {
|
|
109
|
+
...options,
|
|
110
|
+
extraParameters: toNativeExtraParameterEntries(options.extraParameters),
|
|
111
|
+
localExtraParameters: toNativeExtraParameterEntries(options.localExtraParameters),
|
|
112
|
+
};
|
|
113
|
+
let result: { nativeAdId?: string; adInfo?: NativeAdEventPayload };
|
|
114
|
+
try {
|
|
115
|
+
result = (await NativeCloudX.loadNativeAd(adUnitId, wireOptions)) as typeof result;
|
|
116
|
+
} catch (error) {
|
|
117
|
+
throw toLoadFailedInfo(adUnitId, error);
|
|
118
|
+
}
|
|
119
|
+
if (!result?.nativeAdId) {
|
|
120
|
+
throw toLoadFailedInfo(adUnitId, { code: 0, message: 'Native module returned no native ad id' });
|
|
121
|
+
}
|
|
122
|
+
return new CloudXNativeAd(result.nativeAdId, adUnitId, result.adInfo ?? {});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
private constructor(id: string, adUnitId: string, payload: NativeAdEventPayload) {
|
|
126
|
+
this.id = id;
|
|
127
|
+
this.adUnitId = adUnitId;
|
|
128
|
+
this.info = toAdInfo(payload, adUnitId);
|
|
129
|
+
this.metadata = this.info.nativeAd ?? null;
|
|
130
|
+
liveAds.set(id, this);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
get isExpired(): boolean {
|
|
134
|
+
return this.expired;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get isDestroyed(): boolean {
|
|
138
|
+
return this.destroyed;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
addListener(type: CloudXNativeAdEventType, listener: NativeAdListener): { remove: () => void } {
|
|
142
|
+
if (this.destroyed) {
|
|
143
|
+
console.warn(`CloudXNativeAd(${this.id}): addListener('${type}') after destroy() never fires.`);
|
|
144
|
+
return { remove: () => undefined };
|
|
145
|
+
}
|
|
146
|
+
let set = this.listeners.get(type);
|
|
147
|
+
if (!set) {
|
|
148
|
+
set = new Set();
|
|
149
|
+
this.listeners.set(type, set);
|
|
150
|
+
}
|
|
151
|
+
set.add(listener);
|
|
152
|
+
return { remove: () => this.listeners.get(type)?.delete(listener) };
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Releases the native ad. Safe to call more than once. */
|
|
156
|
+
destroy(): void {
|
|
157
|
+
if (this.destroyed) return;
|
|
158
|
+
this.destroyed = true;
|
|
159
|
+
liveAds.delete(this.id);
|
|
160
|
+
this.listeners.clear();
|
|
161
|
+
NativeCloudX.destroyNativeAd(this.id);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** @internal Routed from the module emitter; not part of the public API. */
|
|
165
|
+
_handleNativeEvent(type: CloudXNativeAdEventType, payload: NativeAdEventPayload): void {
|
|
166
|
+
if (this.destroyed) return;
|
|
167
|
+
if (type === 'expired') this.expired = true;
|
|
168
|
+
const adInfo = toAdInfo(payload, this.adUnitId);
|
|
169
|
+
this.listeners.get(type)?.forEach((listener) => {
|
|
170
|
+
try {
|
|
171
|
+
listener(adInfo);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error(`CloudXNativeAd(${this.id}): '${type}' listener threw`, error);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -6,7 +6,7 @@ import NativeCloudXNativeAdView, { Commands } from './specs/CloudXNativeAdViewNa
|
|
|
6
6
|
import type { CloudXNativeAdInfoEvent, CloudXNativeAdLoadFailedEvent } from './specs/CloudXNativeAdViewNativeComponent';
|
|
7
7
|
import { toNativeExtraParameterEntries } from './extraParameters';
|
|
8
8
|
import { CloudXNativeAssetType } from './types/NativeAd';
|
|
9
|
-
import type { CloudXNativeAdMetadata, CloudXNativeAdViewHandle,
|
|
9
|
+
import type { CloudXNativeAdMetadata, CloudXNativeAdViewHandle, CloudXNativeAdViewComponentProps } from './types/NativeAd';
|
|
10
10
|
import type { CloudXAdDisplayFailedInfo, CloudXAdInfo, CloudXAdLoadFailedInfo } from './types/AdInfo';
|
|
11
11
|
import type { CloudXErrorCode } from './CloudXErrorCode';
|
|
12
12
|
import { CloudXNativeAdViewContext, CloudXNativeAdViewProvider } from './CloudXNativeAdViewProvider';
|
|
@@ -59,18 +59,54 @@ const toLoadFailedInfo = (event: CloudXNativeAdLoadFailedEvent): CloudXAdLoadFai
|
|
|
59
59
|
message: event.message || null,
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
+
// Props that only mean something when the view loads its own ad. Passing one
|
|
63
|
+
// next to `nativeAd` is a type error, but plain-JS callers can still do it.
|
|
64
|
+
const AUTO_LOAD_ONLY_PROPS = [
|
|
65
|
+
'adUnitId',
|
|
66
|
+
'placement',
|
|
67
|
+
'customData',
|
|
68
|
+
'extraParameters',
|
|
69
|
+
'localExtraParameters',
|
|
70
|
+
'disableVideoFullScreen',
|
|
71
|
+
'startVideoUnmuted',
|
|
72
|
+
'hideVideoMediaControls',
|
|
73
|
+
'onAdLoaded',
|
|
74
|
+
'onAdLoadFailed',
|
|
75
|
+
'onAdClicked',
|
|
76
|
+
'onAdRevenuePaid',
|
|
77
|
+
'onAdExpired',
|
|
78
|
+
'onAdClosed',
|
|
79
|
+
] as const;
|
|
80
|
+
|
|
62
81
|
/**
|
|
63
82
|
* Renders a native ad. Defaults to the SDK's bundled template layouts;
|
|
64
83
|
* set `renderMode="manual"` to drive layout through the pre-built asset
|
|
65
84
|
* components (`CloudXTitleView`, `CloudXMediaView`, etc.) instead.
|
|
66
85
|
*
|
|
86
|
+
* Pass `adUnitId` and the view loads its own ad on attach. Pass `nativeAd`
|
|
87
|
+
* (from `CloudXNativeAd.load`) and it renders that ad instead, without
|
|
88
|
+
* loading or destroying it.
|
|
89
|
+
*
|
|
67
90
|
* Manual mode is never inferred from the presence of children — `renderMode`
|
|
68
91
|
* is always explicit so a publisher's intent is visible at the call site.
|
|
69
92
|
*/
|
|
70
|
-
export const CloudXNativeAdView = forwardRef<CloudXNativeAdViewHandle,
|
|
93
|
+
export const CloudXNativeAdView = forwardRef<CloudXNativeAdViewHandle, CloudXNativeAdViewComponentProps>(
|
|
71
94
|
function CloudXNativeAdView(props, ref) {
|
|
72
95
|
const { renderMode = 'template', style, testID, children } = props;
|
|
73
96
|
|
|
97
|
+
const warnedMixedProps = useRef(false);
|
|
98
|
+
if (__DEV__ && props.nativeAd && !warnedMixedProps.current) {
|
|
99
|
+
const ignored = AUTO_LOAD_ONLY_PROPS.filter((name) => Reflect.get(props, name) != null);
|
|
100
|
+
if (ignored.length > 0) {
|
|
101
|
+
warnedMixedProps.current = true;
|
|
102
|
+
console.warn(
|
|
103
|
+
`CloudXNativeAdView: ${ignored.join(', ')} ignored because nativeAd is set. ` +
|
|
104
|
+
'Pass load options to CloudXNativeAd.load() and subscribe to clicks, revenue, ' +
|
|
105
|
+
'expiry and close with nativeAd.addListener().'
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
74
110
|
/*
|
|
75
111
|
* Gate native ad-view creation on SDK initialization; shared with
|
|
76
112
|
* CloudXAdViewBase (banner/MREC) via useCloudXSdkInitializationGate.
|
|
@@ -114,8 +150,11 @@ export const CloudXNativeAdView = forwardRef<CloudXNativeAdViewHandle, CloudXNat
|
|
|
114
150
|
);
|
|
115
151
|
}
|
|
116
152
|
|
|
153
|
+
// Keyed by the bound handle: swapping `nativeAd` remounts the provider
|
|
154
|
+
// and native view, so the previous ad's metadata and asset bindings
|
|
155
|
+
// can never be shown under the new ad's click and impression tracking.
|
|
117
156
|
return (
|
|
118
|
-
<CloudXNativeAdViewProvider onAssetRoleRegistered={handleAssetRoleRegistered}>
|
|
157
|
+
<CloudXNativeAdViewProvider key={props.nativeAd?.id} onAssetRoleRegistered={handleAssetRoleRegistered}>
|
|
119
158
|
<CloudXNativeAdViewImpl {...props} ref={ref} />
|
|
120
159
|
</CloudXNativeAdViewProvider>
|
|
121
160
|
);
|
|
@@ -124,7 +163,7 @@ export const CloudXNativeAdView = forwardRef<CloudXNativeAdViewHandle, CloudXNat
|
|
|
124
163
|
|
|
125
164
|
export default CloudXNativeAdView;
|
|
126
165
|
|
|
127
|
-
const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle,
|
|
166
|
+
const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNativeAdViewComponentProps>(
|
|
128
167
|
function CloudXNativeAdViewImpl(props, ref) {
|
|
129
168
|
const {
|
|
130
169
|
adUnitId,
|
|
@@ -137,8 +176,10 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
137
176
|
extraParameters,
|
|
138
177
|
localExtraParameters,
|
|
139
178
|
renderMode = 'template',
|
|
179
|
+
nativeAd,
|
|
140
180
|
onAdLoaded,
|
|
141
181
|
onAdLoadFailed,
|
|
182
|
+
onAdDisplayed,
|
|
142
183
|
onAdDisplayFailed,
|
|
143
184
|
onAdClicked,
|
|
144
185
|
onAdExpired,
|
|
@@ -151,6 +192,7 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
151
192
|
} = props;
|
|
152
193
|
|
|
153
194
|
const isManual = renderMode === 'manual';
|
|
195
|
+
const isPreloaded = nativeAd != null;
|
|
154
196
|
|
|
155
197
|
const {
|
|
156
198
|
setNativeAd,
|
|
@@ -175,12 +217,14 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
175
217
|
const [bindTick, setBindTick] = useState(0);
|
|
176
218
|
|
|
177
219
|
const loadAd = useCallback(() => {
|
|
178
|
-
if (nativeRef.current) {
|
|
220
|
+
if (nativeRef.current && !isPreloaded) {
|
|
179
221
|
Commands.loadAd(nativeRef.current);
|
|
180
222
|
}
|
|
181
|
-
}, []);
|
|
223
|
+
}, [isPreloaded]);
|
|
182
224
|
|
|
183
225
|
const destroyAd = useCallback(() => {
|
|
226
|
+
// A preloaded ad belongs to its handle, not to this view.
|
|
227
|
+
if (isPreloaded) return;
|
|
184
228
|
if (nativeRef.current) {
|
|
185
229
|
Commands.destroyAd(nativeRef.current);
|
|
186
230
|
}
|
|
@@ -189,7 +233,7 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
189
233
|
pendingMetadata.current = null;
|
|
190
234
|
lastAdInfoRef.current = null;
|
|
191
235
|
setNativeAd(null);
|
|
192
|
-
}, [setNativeAd]);
|
|
236
|
+
}, [isPreloaded, setNativeAd]);
|
|
193
237
|
|
|
194
238
|
/**
|
|
195
239
|
* Escape hatch for imperative control. The native view auto-loads on
|
|
@@ -222,15 +266,33 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
222
266
|
const adInfo = toAdInfo(event.nativeEvent);
|
|
223
267
|
lastAdInfoRef.current = adInfo;
|
|
224
268
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
269
|
+
// A preloaded ad's metadata travelled with the handle, so a
|
|
270
|
+
// bind event that omits it still has assets to lay out.
|
|
271
|
+
const metadata = adInfo.nativeAd ?? nativeAd?.metadata ?? null;
|
|
272
|
+
if (isManual && metadata) {
|
|
273
|
+
pendingMetadata.current = metadata;
|
|
274
|
+
setNativeAd(metadata);
|
|
228
275
|
setBindTick((n) => n + 1);
|
|
229
276
|
}
|
|
230
277
|
|
|
231
278
|
onAdLoaded?.(adInfo);
|
|
232
279
|
},
|
|
233
|
-
[isManual, setNativeAd, onAdLoaded]
|
|
280
|
+
[isManual, nativeAd, setNativeAd, onAdLoaded]
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
// Native released the preloaded ad this view showed (destroy, expiry,
|
|
284
|
+
// or a newer view took it). Its React-rendered text and images must
|
|
285
|
+
// go with it, and any asset binds still pending must stop. Silent:
|
|
286
|
+
// a transfer to another view is not a publisher lifecycle event.
|
|
287
|
+
const handleBindingCleared = useCallback(() => {
|
|
288
|
+
pendingMetadata.current = null;
|
|
289
|
+
lastAdInfoRef.current = null;
|
|
290
|
+
setNativeAd(null);
|
|
291
|
+
}, [setNativeAd]);
|
|
292
|
+
|
|
293
|
+
const handleAdDisplayed = useCallback(
|
|
294
|
+
(event: NativeSyntheticEvent<CloudXNativeAdInfoEvent>) => onAdDisplayed?.(toAdInfo(event.nativeEvent)),
|
|
295
|
+
[onAdDisplayed]
|
|
234
296
|
);
|
|
235
297
|
|
|
236
298
|
const handleAdLoadFailed = useCallback(
|
|
@@ -248,8 +310,10 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
248
310
|
// failure if it describes the ad unit that actually failed. A
|
|
249
311
|
// display failure arriving after a re-target would otherwise
|
|
250
312
|
// report the previous unit's network, placement and revenue.
|
|
251
|
-
|
|
252
|
-
|
|
313
|
+
// A preloaded ad can fail before it ever rendered here (e.g. the
|
|
314
|
+
// handle was destroyed), so fall back to its load-time info.
|
|
315
|
+
const cached = lastAdInfoRef.current ?? nativeAd?.info ?? null;
|
|
316
|
+
const base = cached && (!failedAdUnitId || cached.adUnitId === failedAdUnitId) ? cached : null;
|
|
253
317
|
const displayFailedInfo: CloudXAdDisplayFailedInfo = {
|
|
254
318
|
// The event's own adUnitId is authoritative.
|
|
255
319
|
adUnitId: failedAdUnitId || base?.adUnitId || '',
|
|
@@ -265,7 +329,7 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
265
329
|
};
|
|
266
330
|
onAdDisplayFailed(displayFailedInfo);
|
|
267
331
|
},
|
|
268
|
-
[onAdDisplayFailed]
|
|
332
|
+
[nativeAd, onAdDisplayFailed]
|
|
269
333
|
);
|
|
270
334
|
|
|
271
335
|
const handleAdClicked = useCallback(
|
|
@@ -392,7 +456,8 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
392
456
|
ref={(r) => {
|
|
393
457
|
nativeRef.current = r;
|
|
394
458
|
}}
|
|
395
|
-
adUnitId={adUnitId}
|
|
459
|
+
adUnitId={isPreloaded ? null : adUnitId}
|
|
460
|
+
nativeAdId={nativeAd?.id ?? null}
|
|
396
461
|
templateName={template}
|
|
397
462
|
placement={placement ?? null}
|
|
398
463
|
customData={customData ?? null}
|
|
@@ -404,7 +469,9 @@ const CloudXNativeAdViewImpl = forwardRef<CloudXNativeAdViewHandle, CloudXNative
|
|
|
404
469
|
manualRender={isManual}
|
|
405
470
|
onAdLoadedEvent={handleAdLoaded}
|
|
406
471
|
onAdLoadFailedEvent={handleAdLoadFailed}
|
|
472
|
+
onAdDisplayedEvent={handleAdDisplayed}
|
|
407
473
|
onAdDisplayFailedEvent={handleAdDisplayFailed}
|
|
474
|
+
onAdBindingClearedEvent={handleBindingCleared}
|
|
408
475
|
onAdClickedEvent={handleAdClicked}
|
|
409
476
|
onAdExpiredEvent={handleAdExpired}
|
|
410
477
|
onAdClosedEvent={handleAdClosed}
|