drgame-cc 1.0.21 → 1.0.23

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/drscript/Info.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import TvUi from "./core/TvUi";
2
+ import { AnalyticsAction, AnalyticsEvent } from "./GameAnalytics";
3
+ import { PlatformAdapter } from "./PlatformAdapter";
2
4
  import ToastManager from "./toast/ToastManager";
3
5
 
4
6
 
@@ -42,6 +44,7 @@ export function showRewardVideo(scene: string, rewardType: string, callback: Fun
42
44
  };
43
45
  let onSuccess = () => {
44
46
  try {
47
+ PlatformAdapter.report(AnalyticsEvent.RewardVideoAd, AnalyticsAction.Exposure);
45
48
  callback && callback.call(target);
46
49
  }
47
50
  finally {
@@ -2,15 +2,14 @@ import TvUiConfigManager from "../config/TvUiConfigManager";
2
2
  import NativeBridge from "../core/NativeBridge";
3
3
  import { TvUiAdChannelConfig } from "../config/TvUiConfig";
4
4
  import IAdProvider, { AdRuntimeData, AdShowResult } from "./IAdProvider";
5
- import { AdSdk, AdPlatform, AdType, AdErrorCode } from "../ad-sdk/ad-sdk";
5
+ import { AdErrorCode, AdPlatform, AdSdk, AdType } from "../ad-sdk/ad-sdk";
6
6
 
7
7
  export default class AggregateAdProvider implements IAdProvider {
8
8
  public type: string = "aggregate";
9
-
9
+ private GAME_VERSION: string = "1.0.0";
10
10
  private static initialized: boolean = false;
11
11
  private static initTask: Promise<void> | null = null;
12
12
  private static gameReadyNotified: boolean = false;
13
- private static GAME_VERSION: string = "1.0.0";
14
13
 
15
14
  public isAvailable(): boolean {
16
15
  return NativeBridge.hasBridge();
@@ -21,27 +20,27 @@ export default class AggregateAdProvider implements IAdProvider {
21
20
  }
22
21
 
23
22
  public show(data: AdRuntimeData): Promise<AdShowResult> {
24
- return null;
25
- // let options = data.options || {};
26
- // let mode = options.mode || data.slotConfig.mode || "popup";
27
- // if (mode == "reward") {
28
- // return this.showReward(data);
29
- // }
30
- // return this.showPopup(data);
23
+ let options = data.options || {};
24
+ let mode = options.mode || data.slotConfig.mode || "popup";
25
+ if (mode == "reward") {
26
+ return this.showReward(data);
27
+ }
28
+ return this.showPopup(data);
31
29
  }
32
30
 
33
31
  public hide(slotId: string, channel?: TvUiAdChannelConfig): void {
34
- // if (!AggregateAdProvider.initialized || !this.isAvailable()) return;
35
- // let runtime = TvUiConfigManager.getConfig();
36
- // try {
37
- // AdSdk.hidePopupAd({
38
- // cpId: runtime.cpId || "ppl",
39
- // trigger_scene: slotId || "",
40
- // placementId: (channel && channel.placementId) || ""
41
- // });
42
- // } catch (error) {
43
- // console.warn("[AggregateAdProvider] hide popup failed", error);
44
- // }
32
+ if (!AggregateAdProvider.initialized || !this.isAvailable()) return;
33
+ let runtime = TvUiConfigManager.getConfig();
34
+ try {
35
+ // TODO: fix
36
+ // AdSdk.hidePopupAd({
37
+ // cpId: runtime.cpId || "ppl",
38
+ // triggerScene: slotId || "",
39
+ // placementId: (channel && channel.placementId) || ""
40
+ // });
41
+ } catch (error) {
42
+ console.warn("[AggregateAdProvider] hide popup failed", error);
43
+ }
45
44
  }
46
45
 
47
46
  private showReward(data: AdRuntimeData): Promise<AdShowResult> {
@@ -51,8 +50,8 @@ export default class AggregateAdProvider implements IAdProvider {
51
50
  return AdSdk.requestAd({
52
51
  adType: AdType.RewardVideo,
53
52
  cpId: options.cpId || runtime.cpId || "ppl",
54
- rewardType: options.reward_type || channel.reward_type || "reward",
55
- triggerScene: options.trigger_scene || data.slotId,
53
+ rewardType: options.rewardType || "reward",
54
+ triggerScene: options.scene || data.slotId,
56
55
  extra: options.extra || {}
57
56
  }).then((result: any) => {
58
57
  if (!result || result.isCompleted !== true) {
@@ -70,28 +69,30 @@ export default class AggregateAdProvider implements IAdProvider {
70
69
  });
71
70
  }
72
71
 
73
- // private showPopup(data: AdRuntimeData): Promise<AdShowResult> {
74
- // let options = data.options || {};
75
- // let channel = data.channel || <any>{};
76
- // let runtime = TvUiConfigManager.getConfig();
77
- // return AdSdk.requestPopupAd({
78
- // adType: AdType.Interstitial,
79
- // cpId: options.cpId || runtime.cpId || "ppl",
80
- // reward_type: options.reward_type || channel.reward_type || "popup",
81
- // trigger_scene: options.trigger_scene || data.slotId,
82
- // placementId: channel.placementId || "",
83
- // extra: options.extra || {}
84
- // }).then((result: any) => {
85
- // if (result && result.isClosed) {
86
- // if (options.onClose) options.onClose(result);
87
- // return <AdShowResult>{ status: "closed", data: result };
88
- // }
89
- // if (options.onLoad) options.onLoad(result);
90
- // return <AdShowResult>{ status: "loaded", data: result };
91
- // }).catch((error: any) => {
92
- // return <AdShowResult>{ status: "failed", error: error };
93
- // });
94
- // }
72
+ private showPopup(data: AdRuntimeData): Promise<AdShowResult> {
73
+ let options = data.options || {};
74
+ let channel = data.channel || <any>{};
75
+ let runtime = TvUiConfigManager.getConfig();
76
+ return Promise.reject(new Error("Popup ad not implemented"));
77
+ // TODO: fix
78
+ // return AdSdk.requestPopupAd({
79
+ // adType: AdType.Interstitial,
80
+ // cpId: options.cpId || runtime.cpId || "ppl",
81
+ // rewardType: options.rewardType || channel.rewardType || "popup",
82
+ // triggerScene: options.scene || data.slotId,
83
+ // placementId: channel.placementId || "",
84
+ // extra: options.extra || {}
85
+ // }).then((result: any) => {
86
+ // if (result && result.isClosed) {
87
+ // if (options.onClose) options.onClose(result);
88
+ // return <AdShowResult>{ status: "closed", data: result };
89
+ // }
90
+ // if (options.onLoad) options.onLoad(result);
91
+ // return <AdShowResult>{ status: "loaded", data: result };
92
+ // }).catch((error: any) => {
93
+ // return <AdShowResult>{ status: "failed", error: error };
94
+ // });
95
+ }
95
96
 
96
97
  private ensureSdk(): Promise<void> {
97
98
  if (AggregateAdProvider.initialized) return Promise.resolve();
@@ -114,7 +115,7 @@ export default class AggregateAdProvider implements IAdProvider {
114
115
  adapters: adapters
115
116
  }).then(() => {
116
117
  AggregateAdProvider.initialized = true;
117
- this.notifyGameReady(runtime.version || AggregateAdProvider.GAME_VERSION);
118
+ this.notifyGameReady(runtime.version || this.GAME_VERSION);
118
119
  }).catch((error: any) => {
119
120
  AggregateAdProvider.initTask = null;
120
121
  throw error;
@@ -126,7 +127,7 @@ export default class AggregateAdProvider implements IAdProvider {
126
127
  if (AggregateAdProvider.gameReadyNotified) return;
127
128
  AggregateAdProvider.gameReadyNotified = true;
128
129
  try {
129
- AdSdk.onGameReady(version || AggregateAdProvider.GAME_VERSION);
130
+ AdSdk.onGameReady(version || this.GAME_VERSION);
130
131
  } catch (error) {
131
132
  console.warn("[AggregateAdProvider] onGameReady failed", error);
132
133
  }
@@ -4,8 +4,8 @@ export interface AdShowOptions {
4
4
  slotId?: string;
5
5
  mode?: string;
6
6
  cpId?: string;
7
- trigger_scene?: string;
8
- reward_type?: string;
7
+ scene?: string;
8
+ rewardType?: string;
9
9
  extra?: any;
10
10
  container?: cc.Node;
11
11
  onLoad?: (data?: any) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "drgame-cc",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "道然游戏适配包",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",