@jolibox/ads 1.1.37 → 1.1.39

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.
@@ -0,0 +1,16 @@
1
+ import { IAdsContext } from '@/type/base';
2
+ import { IAbstractAFGProvider, IAdBreakParams, IAdConfigParams } from '../ads-interface';
3
+ import { IGoogleGPTAdBreakServerParams, IGoogleGPTInitServerParams } from './type';
4
+ export declare class GoogleGPTProvider implements IAbstractAFGProvider<IGoogleGPTInitServerParams, IGoogleGPTAdBreakServerParams> {
5
+ name: string;
6
+ private context;
7
+ private contextInfo;
8
+ private initParams;
9
+ private rewardAdManager?;
10
+ private interstitialManager?;
11
+ constructor(context: IAdsContext, initParams: IGoogleGPTInitServerParams['params']);
12
+ init(): Promise<void>;
13
+ private insertScript;
14
+ adConfig(params: IAdConfigParams, serverParam: IGoogleGPTInitServerParams): void;
15
+ adBreak(params: IAdBreakParams, serverParam: IGoogleGPTAdBreakServerParams): void;
16
+ }
@@ -0,0 +1,14 @@
1
+ export interface IGoogleGPTInitServerParams {
2
+ provider: 'GOOGLE_GPT';
3
+ params: {
4
+ rewardedSlot: string;
5
+ interstitialSlot: string;
6
+ keyValue?: {
7
+ channel?: string;
8
+ };
9
+ };
10
+ }
11
+ export interface IGoogleGPTAdBreakServerParams {
12
+ provider: 'GOOGLE_GPT';
13
+ params: never;
14
+ }
@@ -1,13 +1,16 @@
1
1
  import type { IGoogleAdSenseInitServerParams, GoogleAdSenseProvider, IGoogleAdSenseAdBreakServerParams } from './adsense';
2
- import { IAppsRocketsAdBreakServerParams, IAppsRocketsInitServerParams } from './appsrockets/type';
2
+ import type { IAppsRocketsAdBreakServerParams, IAppsRocketsInitServerParams } from './appsrockets/type';
3
3
  import type { AppsRocketsForGameProvider } from './appsrockets';
4
4
  import type { IOKSpinAdBreakServerParams, IOKSpinInitServerParams } from './okspin/type';
5
5
  import type { OKSpinForGameProvider } from './okspin';
6
- export type IAFGInitServerParams = IGoogleAdSenseInitServerParams | IOKSpinInitServerParams | IAppsRocketsInitServerParams;
7
- export type IAFGAdBreakServerParams = IGoogleAdSenseAdBreakServerParams | IOKSpinAdBreakServerParams | IAppsRocketsAdBreakServerParams;
6
+ import type { IGoogleGPTAdBreakServerParams, IGoogleGPTInitServerParams } from './googlegpt/type';
7
+ import type { GoogleGPTProvider } from './googlegpt';
8
+ export type IAFGInitServerParams = IGoogleAdSenseInitServerParams | IOKSpinInitServerParams | IAppsRocketsInitServerParams | IGoogleGPTInitServerParams;
9
+ export type IAFGAdBreakServerParams = IGoogleAdSenseAdBreakServerParams | IOKSpinAdBreakServerParams | IAppsRocketsAdBreakServerParams | IGoogleGPTAdBreakServerParams;
8
10
  export interface IAFGProviders {
9
11
  ADSENSE?: GoogleAdSenseProvider;
10
12
  ADSENSE_ADMOB?: GoogleAdSenseProvider;
11
13
  OKSPIN?: OKSpinForGameProvider;
12
14
  APPSROCKETS?: AppsRocketsForGameProvider;
15
+ GOOGLE_GPT?: GoogleGPTProvider;
13
16
  }
@@ -0,0 +1,14 @@
1
+ import { IAdsContext } from '../../type/base';
2
+ import { IAbstractAFVProvider, IAFVRequestAdParams } from '../ads-interface';
3
+ import { IGoogleGPTForVideoInitServerParams, IGoogleGPTForVideoRequestAdServerParams } from './type';
4
+ export declare class GoogleGPTForVideoProvider implements IAbstractAFVProvider {
5
+ name: string;
6
+ private context;
7
+ private contextInfo;
8
+ private rewardAdManager?;
9
+ constructor(context: IAdsContext);
10
+ init: (serverParams: IGoogleGPTForVideoInitServerParams) => Promise<void>;
11
+ private insertScript;
12
+ destroy: () => void;
13
+ requestAd: (clientParams: IAFVRequestAdParams<any>, _serverParam: IGoogleGPTForVideoRequestAdServerParams) => void;
14
+ }
@@ -0,0 +1,13 @@
1
+ export interface IGoogleGPTForVideoInitServerParams {
2
+ provider: 'GOOGLE_GPT';
3
+ params: {
4
+ rewardedSlot: string;
5
+ keyValue?: {
6
+ channel?: string;
7
+ };
8
+ };
9
+ }
10
+ export interface IGoogleGPTForVideoRequestAdServerParams {
11
+ provider: 'GOOGLE_GPT';
12
+ params: never;
13
+ }
@@ -4,10 +4,13 @@ import type { OKSpinForVideoProvider } from './okspin';
4
4
  import type { IOKSpinForVideoInitServerParams, IOKSpinForVideoRequestAdServerParams } from './okspin/type';
5
5
  import type { IAppsRocketsForVideoInitServerParams, IAppsRocketsForVideoRequestAdServerParams } from './appsrockets/type';
6
6
  import type { AppsRocketsForVideoProvider } from './appsrockets';
7
- export type IAFVInitServerParams = IGoogleIMAInitServerParams | IOKSpinForVideoInitServerParams | IAppsRocketsForVideoInitServerParams;
8
- export type IAFVRequestAdServerParams = IGoogleIMARequestAdServerParams | IOKSpinForVideoRequestAdServerParams | IAppsRocketsForVideoRequestAdServerParams;
7
+ import type { IGoogleGPTForVideoInitServerParams, IGoogleGPTForVideoRequestAdServerParams } from './googlegpt/type';
8
+ import { GoogleGPTForVideoProvider } from './googlegpt';
9
+ export type IAFVInitServerParams = IGoogleIMAInitServerParams | IOKSpinForVideoInitServerParams | IAppsRocketsForVideoInitServerParams | IGoogleGPTForVideoInitServerParams;
10
+ export type IAFVRequestAdServerParams = IGoogleIMARequestAdServerParams | IOKSpinForVideoRequestAdServerParams | IAppsRocketsForVideoRequestAdServerParams | IGoogleGPTForVideoRequestAdServerParams;
9
11
  export interface IAFVProviders {
10
12
  GOOGLE_IMA?: GoogleIMAProvider;
11
13
  OKSPIN?: OKSpinForVideoProvider;
12
14
  APPSROCKETS?: AppsRocketsForVideoProvider;
15
+ GOOGLE_GPT?: GoogleGPTForVideoProvider;
13
16
  }
@@ -0,0 +1 @@
1
+ export declare const initGPTServices: () => void;
@@ -0,0 +1,52 @@
1
+ type EndReason = 'notReady' | 'timeout' | 'error' | 'noAdPreloaded' | 'frequencyCapped' | 'ignored' | 'other' | 'dismissed' | 'viewed';
2
+ interface IInterstitialAdContext {
3
+ beforeAd?: () => void;
4
+ afterAd?: () => void;
5
+ onEnd?: (endReason: EndReason) => void;
6
+ }
7
+ /**
8
+ * InterstitialAdManager class for managing Google GPT interstitial ads.
9
+ *
10
+ * This class handles the lifecycle of interstitial ads, including initialization,
11
+ * requesting ads, handling events, and cleaning up resources.
12
+ * For every execution of googletag function, it must be wrapped with googletag.cmd.push(() => {});
13
+ */
14
+ export declare class InterstitialAdManager {
15
+ private adUnit;
16
+ private project;
17
+ private keyValue;
18
+ private adsContext;
19
+ private gamingInterstitialSlot;
20
+ private readyEvent;
21
+ constructor(adUnit: string, project: 'minigame-h5' | 'minidrama-h5' | 'minigame-app' | 'minidrama-app', keyValue?: Record<string, string>);
22
+ withCommand: (...itmes: (() => void)[]) => void;
23
+ /**
24
+ * Initializes the interstitial ad slot and sets up event listeners.
25
+ *
26
+ * The init function will potentially request an ad in the background.
27
+ */
28
+ private init;
29
+ destroy: (endReason: EndReason) => void;
30
+ /**
31
+ * Destroy the interstitial ad and cleans up resources.
32
+ *
33
+ * This method is called when the ad is no longer needed. It cleans up the resources associated with the interstitial ad slot,
34
+ * such as removing event listeners and destroying the slot.
35
+ *
36
+ * @param endReason The reason for ending the ad.
37
+ */
38
+ reinit: (endReason: EndReason) => void;
39
+ private handleSlotReady;
40
+ private handleSlotClosed;
41
+ /**
42
+ * Request ads for the interstitial ad.
43
+ *
44
+ * This method requests ads for the interstitial ad slot. If the interstitial ad slot is not initialized, it initializes it.
45
+ * If the previous request is not closed, it destroys and ignores the previous request.
46
+ * If the interstitial ad slot is already initialized, it calls makeGameManualInterstitialVisible to show the ad.
47
+ *
48
+ * @param context The context for the interstitial ad, containing callbacks for ad events.
49
+ */
50
+ requestAds: (context: IInterstitialAdContext) => void;
51
+ }
52
+ export {};
@@ -0,0 +1,58 @@
1
+ type BreakStatus = 'notReady' | 'timeout' | 'error' | 'noAdPreloaded' | 'frequencyCapped' | 'ignored' | 'other' | 'dismissed' | 'viewed';
2
+ interface IRewardAdContext {
3
+ beforeAd?: () => void;
4
+ beforeReward: (showAdFn: () => void) => void;
5
+ adDismissed: () => void;
6
+ adViewed: () => void;
7
+ afterAd?: () => void;
8
+ adBreakDone?: (breakStatus: BreakStatus) => void;
9
+ }
10
+ /**
11
+ * RewardAdManager class for managing Google GPT rewarded ads.
12
+ *
13
+ * This class handles the lifecycle of rewarded ads, including initialization,
14
+ * requesting ads, handling events, and cleaning up resources.
15
+ * For every execution of googletag function, it must be wrapped with googletag.cmd.push(() => {});
16
+ */
17
+ export declare class RewardAdManager {
18
+ private adUnit;
19
+ private project;
20
+ private keyValue;
21
+ private adsContext;
22
+ private rewardedSlot;
23
+ private rewardedPayload;
24
+ private readyEvent;
25
+ constructor(adUnit: string, project: 'minigame-h5' | 'minidrama-h5' | 'minigame-app' | 'minidrama-app', keyValue?: Record<string, string>);
26
+ withCommand: (...itmes: (() => void)[]) => void;
27
+ /**
28
+ * Initializes the rewarded ad slot and sets up event listeners.
29
+ *
30
+ * The init function will potentially request an ad in the background.
31
+ */
32
+ private init;
33
+ destroy: (breakStatus: BreakStatus) => void;
34
+ /**
35
+ * Destroy the rewarded ad and cleans up resources.
36
+ *
37
+ * This method is called when the ad is no longer needed. It cleans up the resources associated with the rewarded ad slot,
38
+ * such as removing event listeners and destroying the slot.
39
+ *
40
+ * @param breakStatus The reason for ending the ad.
41
+ */
42
+ reinit: (breakStatus: BreakStatus) => void;
43
+ private handleSlotReady;
44
+ private handleSlotClosed;
45
+ private handleSlotGranted;
46
+ private handleSlotRenderEnded;
47
+ /**
48
+ * Request ads for the rewarded ad.
49
+ *
50
+ * This method requests ads for the rewarded ad slot. If the rewarded ad slot is not initialized, it initializes it.
51
+ * If the previous request is not closed, it destroys and ignores the previous request.
52
+ * If the rewarded ad slot is already initialized, it refreshes the slot to request new ads.
53
+ *
54
+ * @param context The context for the rewarded ad, containing callbacks for ad events.
55
+ */
56
+ requestAds: (context: IRewardAdContext) => void;
57
+ }
58
+ export {};