Skip to content

Commit 076469e

Browse files
committed
fix: typings
1 parent abd6f80 commit 076469e

30 files changed

+1996
-2063
lines changed

packages/firebase-admob/common.ts

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
1-
import { FirebaseApp } from '@nativescript/firebase-core';
21
import { CSSType, Property, View } from '@nativescript/core';
3-
4-
export interface IMobileAd {
5-
adUnitId: string;
6-
loaded: boolean;
7-
8-
load(): void;
9-
10-
onAdEvent(listener?: AdEventListener);
11-
12-
show(showOptions?: AdShowOptions);
13-
}
14-
15-
export interface IRewardedInterstitialAd extends IInterstitialAd {
16-
setServerSideVerificationOptions(options: ServerSideVerificationOptions): void;
17-
}
18-
19-
export interface ServerSideVerificationOptions {
20-
userId: string;
21-
customData: string;
22-
}
23-
24-
export interface IInterstitialAd extends IMobileAd {}
25-
26-
export interface IRewardedAd extends IMobileAd {
27-
setServerSideVerificationOptions(options: ServerSideVerificationOptions): void;
28-
}
2+
import { IRewardedItem, RequestOptions } from '.';
293

304
export abstract class BannerAdSizeBase {
315
static get BANNER(): BannerAdSizeBase {
@@ -119,63 +93,14 @@ export enum AdEventType {
11993
FAILED_TO_LOAD_EVENT = 'adFailedToLoad',
12094
}
12195

122-
export interface AdShowOptions {
123-
immersiveModeEnabled: undefined | false | true;
124-
}
125-
126-
export interface RequestConfiguration {
127-
maxAdContentRating?: MaxAdContentRating.G | MaxAdContentRating.PG | MaxAdContentRating.T | MaxAdContentRating.MA;
128-
tagForChildDirectedTreatment?: undefined | false | true;
129-
tagForUnderAgeOfConsent?: undefined | false | true;
130-
testDevices?: string[];
131-
}
132-
133-
export interface RequestOptions {
134-
contentUrl?: undefined | string;
135-
keywords?: string[];
136-
networkExtras?: undefined | { [key: string]: string };
137-
requestAgent?: undefined | string;
138-
requestNonPersonalizedAdsOnly?: undefined | false | true;
139-
}
140-
141-
export interface ManagerRequestOptions extends RequestOptions {
142-
publisherProvidedId?: string;
143-
customTargeting?: { [key: string]: string | string[] };
144-
categoryExclusions?: string[];
145-
adString?: string;
146-
}
147-
14896
export enum RewardedAdEventType {
14997
EARNED_REWARD = 'rewarded_earned_reward',
15098
LOADED = 'rewarded_loaded',
15199
}
152100

153-
export interface IRewardedItem {
154-
amount: number;
155-
type: string;
156-
}
157-
158-
export interface TestIds {
159-
BANNER: string;
160-
INTERSTITIAL: string;
161-
REWARDED: string;
162-
}
163-
164101
export enum AdapterStatusState {
165102
NOT_READY,
166103
READY,
167104
}
168105

169-
export interface AdapterStatus {
170-
description: string;
171-
latency: number;
172-
initializationState: AdapterStatusState;
173-
}
174-
175106
export type AdEventListener = (type: AdEventType | RewardedAdEventType, error?: Error, data?: any | IRewardedItem) => void;
176-
177-
export interface IAdmob {
178-
app: FirebaseApp;
179-
180-
setRequestConfiguration(requestConfiguration: RequestConfiguration);
181-
}

packages/firebase-admob/index.android.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Application, Utils } from '@nativescript/core';
22
import lazy from '@nativescript/core/utils/lazy';
33
import { firebase, FirebaseApp, FirebaseError } from '@nativescript/firebase-core';
4-
import { IAdmob, RequestConfiguration, AdEventListener, AdShowOptions, IInterstitialAd, RequestOptions, IRewardedAd, AdEventType, BannerAdBase, IRewardedInterstitialAd, IRewardedItem, RewardedAdEventType, MaxAdContentRating, ServerSideVerificationOptions, unitIdProperty, BannerAdSizeBase, sizeProperty, AdapterStatus } from './common';
4+
import { IAdmob, RequestConfiguration, AdShowOptions, IInterstitialAd, RequestOptions, IRewardedAd, IRewardedInterstitialAd, IRewardedItem, ServerSideVerificationOptions, AdapterStatus } from '.';
5+
import { AdEventListener, AdEventType, BannerAdBase, RewardedAdEventType, MaxAdContentRating, unitIdProperty, BannerAdSizeBase, sizeProperty } from './common';
56

6-
export { MaxAdContentRating, AdEventType, AdapterStatus };
7+
export { MaxAdContentRating, AdEventType };
78

89
export * from './adsconsent';
910
export * from './nativead';

packages/firebase-admob/index.d.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,88 @@
11
import { Application } from '@nativescript/core';
22

33
import { FirebaseApp } from '@nativescript/firebase-core';
4-
import { IAdmob, RequestConfiguration, AdEventListener, AdShowOptions, IInterstitialAd, RequestOptions, IRewardedAd, AdEventType, BannerAdBase, IRewardedInterstitialAd, IRewardedItem, RewardedAdEventType, MaxAdContentRating, ServerSideVerificationOptions } from './common';
4+
import { IAdmob, AdEventListener, IInterstitialAd, IRewardedAd, AdEventType, BannerAdBase, IRewardedInterstitialAd, RewardedAdEventType, MaxAdContentRating, ServerSideVerificationOptions } from './common';
55

66
export { MaxAdContentRating, AdEventType, RewardedAdEventType };
77

88
export * from './adsconsent';
99
export * from './nativead';
1010

11+
export interface AdShowOptions {
12+
immersiveModeEnabled: undefined | false | true;
13+
}
14+
15+
export interface RequestConfiguration {
16+
maxAdContentRating?: MaxAdContentRating.G | MaxAdContentRating.PG | MaxAdContentRating.T | MaxAdContentRating.MA;
17+
tagForChildDirectedTreatment?: undefined | false | true;
18+
tagForUnderAgeOfConsent?: undefined | false | true;
19+
testDevices?: string[];
20+
}
21+
22+
export interface RequestOptions {
23+
contentUrl?: undefined | string;
24+
keywords?: string[];
25+
networkExtras?: undefined | { [key: string]: string };
26+
requestAgent?: undefined | string;
27+
requestNonPersonalizedAdsOnly?: undefined | false | true;
28+
}
29+
30+
export interface ManagerRequestOptions extends RequestOptions {
31+
publisherProvidedId?: string;
32+
customTargeting?: { [key: string]: string | string[] };
33+
categoryExclusions?: string[];
34+
adString?: string;
35+
}
36+
37+
export interface IRewardedItem {
38+
amount: number;
39+
type: string;
40+
}
41+
42+
export interface TestIds {
43+
BANNER: string;
44+
INTERSTITIAL: string;
45+
REWARDED: string;
46+
}
47+
48+
export interface IAdmob {
49+
app: FirebaseApp;
50+
51+
setRequestConfiguration(requestConfiguration: RequestConfiguration);
52+
}
53+
54+
export interface AdapterStatus {
55+
description: string;
56+
latency: number;
57+
initializationState: AdapterStatusState;
58+
}
59+
60+
export interface IMobileAd {
61+
adUnitId: string;
62+
loaded: boolean;
63+
64+
load(): void;
65+
66+
onAdEvent(listener?: AdEventListener);
67+
68+
show(showOptions?: AdShowOptions);
69+
}
70+
71+
export interface IRewardedInterstitialAd extends IInterstitialAd {
72+
setServerSideVerificationOptions(options: ServerSideVerificationOptions): void;
73+
}
74+
75+
export interface ServerSideVerificationOptions {
76+
userId: string;
77+
customData: string;
78+
}
79+
80+
export interface IInterstitialAd extends IMobileAd {}
81+
82+
export interface IRewardedAd extends IMobileAd {
83+
setServerSideVerificationOptions(options: ServerSideVerificationOptions): void;
84+
}
85+
1186
export declare class AdRequest {
1287
readonly contentUrl: string;
1388

packages/firebase-admob/index.ios.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Utils } from '@nativescript/core';
22
import { firebase, FirebaseApp, FirebaseError } from '@nativescript/firebase-core';
3-
import { IAdmob, RequestConfiguration, MaxAdContentRating, AdEventListener, AdShowOptions, IInterstitialAd, RequestOptions, IRewardedAd, AdEventType, BannerAdBase, ServerSideVerificationOptions, IRewardedInterstitialAd, IRewardedItem, RewardedAdEventType, unitIdProperty, BannerAdSizeBase, sizeProperty, AdapterStatus } from './common';
3+
import { IAdmob, RequestConfiguration, AdShowOptions, IInterstitialAd, RequestOptions, IRewardedAd, ServerSideVerificationOptions, IRewardedInterstitialAd, IRewardedItem, AdapterStatus } from '.';
4+
import { MaxAdContentRating, AdEventListener, AdEventType, BannerAdBase, RewardedAdEventType, unitIdProperty, BannerAdSizeBase, sizeProperty } from './common';
45
import { topViewController, toSerializeRequestOptions } from './utils';
56

6-
export { MaxAdContentRating, AdEventType, AdapterStatus };
7+
export { MaxAdContentRating, AdEventType };
78

89
export * from './adsconsent';
910
export * from './nativead';
Lines changed: 3 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ContainerView, CoreTypes, CSSType, Property, View } from '@nativescript/core';
2-
import { AdEventListener, AdEventType, BannerAdSizeBase, ManagerRequestOptions } from '../common';
2+
import { AdEventType } from '../common';
3+
import { IMediaContent, INativeAd } from '.';
34

45
@CSSType('NativeAdView')
56
export abstract class NativeAdViewBase extends ContainerView {
@@ -28,22 +29,14 @@ export abstract class NativeAdViewBase extends ContainerView {
2829
abstract storeView: View;
2930
}
3031

31-
export interface IMediaContent {
32-
aspectRatio: number;
33-
currentTime: number;
34-
duration: number;
35-
mainImage: any;
36-
hasVideoContent: boolean;
37-
}
38-
3932
export const stretchProperty = new Property<MediaViewBase, CoreTypes.ImageStretchType>({
4033
name: 'stretch',
4134
defaultValue: 'aspectFit',
4235
affectsLayout: global.isIOS,
4336
});
4437

4538
export const mediaContentProperty = new Property<MediaViewBase, IMediaContent>({
46-
name: 'mediaContent'
39+
name: 'mediaContent',
4740
});
4841

4942
@CSSType('MediaView')
@@ -62,22 +55,6 @@ export enum VideoStatus {
6255
Ended,
6356
}
6457

65-
export interface IVideoController {
66-
status: VideoStatus;
67-
68-
clickToExpandEnabled(): boolean;
69-
70-
customControlsEnabled(): boolean;
71-
72-
pause(): void;
73-
74-
play(): void;
75-
76-
mute: boolean;
77-
78-
stop(): void;
79-
}
80-
8158
export enum MediaAspectRatio {
8259
LANDSCAPE = 'landscape',
8360
PORTRAIT = 'portrait',
@@ -92,73 +69,8 @@ export enum AdChoicesPlacement {
9269
BOTTOM_LEFT = 'bottomLeft',
9370
}
9471

95-
export interface NativeAdOptions {
96-
nativeAdOptions?: {
97-
adChoicesPlacement?: AdChoicesPlacement;
98-
mediaAspectRatio?: MediaAspectRatio;
99-
customMuteThisAd?: boolean;
100-
multipleImages?: boolean;
101-
returnUrlsForImageAssets?: boolean;
102-
videoOptions?: {
103-
startMuted?: boolean;
104-
clickToExpandRequested?: boolean;
105-
customControlsRequested?: boolean;
106-
};
107-
};
108-
adSizes?: BannerAdSizeBase[];
109-
adManagerAdViewOptions?: {
110-
manualImpressionsEnabled?: boolean;
111-
shouldDelayBannerRendering?: boolean;
112-
};
113-
}
114-
115-
export interface IResponseInfo {}
116-
117-
export interface UnconfirmedClickListener {
118-
unconfirmedClickReceived?(value: string);
119-
unconfirmedClickCancelled?(): void;
120-
}
121-
122-
export interface IMuteThisAdReason {
123-
description: string;
124-
}
125-
126-
export class INativeAdImage {
127-
image: any;
128-
url: string;
129-
scale: number;
130-
}
131-
13272
export enum NativeAdEventType {
13373
LOADED = 'native_ad_loaded',
13474
}
13575

13676
export type NativeAdEventListener = (type: AdEventType | NativeAdEventType, error?: Error, data?: any | INativeAd) => void;
137-
138-
export interface INativeAdLoader {
139-
isLoading(): boolean;
140-
load(maxAdCount?: number): void;
141-
load(requestOptions?: ManagerRequestOptions): void;
142-
load(): void;
143-
onAdEvent(listener: NativeAdEventListener);
144-
}
145-
146-
export interface INativeAd {
147-
adUnitId: string;
148-
onAdEvent(listener: AdEventListener);
149-
destroy(): void;
150-
advertiser: string;
151-
body: string;
152-
callToAction: string;
153-
headline: string;
154-
price: string;
155-
isCustomClickGestureEnabled(): boolean;
156-
enableCustomClickGesture(): void;
157-
recordCustomClickGesture(): void;
158-
setUnconfirmedClickListener(listener?: UnconfirmedClickListener): void;
159-
images: INativeAdImage[];
160-
icon: INativeAdImage;
161-
store: string;
162-
starRating: number;
163-
muteThisAdReasons: IMuteThisAdReason[];
164-
}

packages/firebase-admob/nativead/index.android.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { AddChildFromBuilder, Application, CSSType, ImageSource, View } from '@nativescript/core';
1+
import { AddChildFromBuilder, Application, ImageSource, View } from '@nativescript/core';
22
import { FirebaseError } from '@nativescript/firebase-core';
3-
import { AdEventListener, AdEventType, ManagerRequestOptions, RequestOptions } from '../common';
4-
import { IMediaContent, IMuteThisAdReason, INativeAd, INativeAdImage, IVideoController, MediaViewBase, NativeAdOptions, UnconfirmedClickListener, VideoStatus, AdChoicesPlacement, MediaAspectRatio, INativeAdLoader, NativeAdEventListener, NativeAdEventType, stretchProperty, NativeAdViewBase, mediaContentProperty } from './common';
3+
import { ManagerRequestOptions, RequestOptions } from '..';
4+
import { AdEventListener, AdEventType } from '../common';
5+
import { NativeAdEventListener, NativeAdViewBase, MediaViewBase, mediaContentProperty, stretchProperty } from './common';
6+
import { IMediaContent, IMuteThisAdReason, INativeAd, INativeAdImage, IVideoController, NativeAdOptions, UnconfirmedClickListener, VideoStatus, AdChoicesPlacement, MediaAspectRatio, INativeAdLoader, NativeAdEventType } from '.';
57

68
export { VideoStatus, AdEventType, AdChoicesPlacement, MediaAspectRatio, NativeAdEventType };
79

0 commit comments

Comments
 (0)