ylh-pc-ad-sdk 1.23.23 → 1.25.25

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/dist/index.d.ts CHANGED
@@ -1,4 +1,121 @@
1
- import { GDTAdLoadConfig, NativeAdInstance, SDKConfig } from '@/common/types';
1
+ /**
2
+ * GDT SDK 的自定义错误类
3
+ */
4
+ declare class GDTError extends Error {
5
+ readonly code: ErrorCode;
6
+ constructor(code: ErrorCode, message: string);
7
+ toString(): string;
8
+ toJSON(): object;
9
+ }
10
+ declare enum ErrorCode {
11
+ INNER_ERROR = 2001,// 内部 SDK 错误
12
+ AD_INVALID_PARAM = 2002,// 无效的广告参数
13
+ NETWORK_ERROR = 3001,// 一般网络错误
14
+ NETWORK_TIMEOUT = 3002,// 网络请求超时
15
+ CLICK_REPORT_FAILED = 4002,// 点击上报失败
16
+ EXPOSURE_REPORT_FAILED = 4003,// 曝光上报失败
17
+ NO_AD_FILL = 5001,// 没有广告
18
+ AD_DATA_EXPIRE = 5002,// 广告数据过期
19
+ VIDEO_PLAYER_ERROR = 5003
20
+ }
21
+
22
+ interface ICustomInfo {
23
+ customClick?: (url: string) => void;
24
+ }
25
+ interface SDKConfig {
26
+ appId?: string;
27
+ scriptNonce?: string;
28
+ customInfo?: ICustomInfo;
29
+ cSrvInfo?: string;
30
+ }
31
+ interface NativeAdEventListener {
32
+ onExpose?: () => void;
33
+ onClick?: () => void;
34
+ onError?: (error: GDTError) => void;
35
+ }
36
+ interface BindAdToViewProps {
37
+ containerView: HTMLElement;
38
+ clickableElements: HTMLElement[];
39
+ adEventListener?: NativeAdEventListener;
40
+ }
41
+ interface NativeAdInstance {
42
+ bindAdToView: (props: BindAdToViewProps) => void;
43
+ bindMediaView(props: BindMediaViewPropsAuto): void;
44
+ bindMediaView(props: BindMediaViewPropsManual): void;
45
+ bindMediaView(props: BindMediaViewPropsManualCustom): void;
46
+ getVideoUrl: () => string | undefined;
47
+ getTitle: () => string;
48
+ getImageUrl: () => string;
49
+ getImageWidth: () => number;
50
+ getImageHeight: () => number;
51
+ getImageUrls: () => string[];
52
+ getDescription: () => string;
53
+ getIconUrl: () => string;
54
+ getAdLogoUrl: () => string;
55
+ getBtnText: () => string;
56
+ getAdPatternType: () => string;
57
+ hasVideo: () => boolean;
58
+ isValid: () => boolean;
59
+ getECPM: () => number;
60
+ destroy: () => void;
61
+ }
62
+ interface GDTAdLoadConfig {
63
+ placementId: string;
64
+ count?: number;
65
+ appId?: string;
66
+ sessionData?: string;
67
+ token?: string;
68
+ }
69
+ interface VideoOptionProps {
70
+ autoplay?: boolean;
71
+ muted?: boolean;
72
+ controls?: boolean;
73
+ width?: string | number;
74
+ height?: string | number;
75
+ poster?: string;
76
+ preload?: string;
77
+ }
78
+ interface VideoControl {
79
+ play: () => void;
80
+ pause: () => void;
81
+ replay: () => void;
82
+ }
83
+ interface NativeADMediaListener {
84
+ onPlay?: () => void;
85
+ onPause?: () => void;
86
+ onCompleted?: () => void;
87
+ onError?: (error: Error) => void;
88
+ onReady?: ($video: VideoControl) => void;
89
+ }
90
+ type EventBinders = {
91
+ pause: (handler: (props: {
92
+ currentTime: number;
93
+ duration: number;
94
+ }) => void) => void;
95
+ ended: (handler: (props: {
96
+ duration: number;
97
+ }) => void) => void;
98
+ error: (handler: (props: {
99
+ duration: number;
100
+ }) => void) => void;
101
+ };
102
+ interface BindMediaViewPropsAuto {
103
+ mediaView: HTMLElement;
104
+ renderType?: 'auto';
105
+ videoOption?: VideoOptionProps;
106
+ mediaListener?: NativeADMediaListener;
107
+ }
108
+ interface BindMediaViewPropsManual {
109
+ mediaView: HTMLVideoElement;
110
+ renderType: 'manual';
111
+ eventBinders?: EventBinders;
112
+ }
113
+ interface BindMediaViewPropsManualCustom {
114
+ mediaView: Exclude<HTMLElement, HTMLVideoElement>;
115
+ renderType: 'manual';
116
+ eventBinders: EventBinders;
117
+ }
118
+
2
119
  declare class GDTAdSDK {
3
120
  private static instance;
4
121
  private adapterReadyPromise;
@@ -12,4 +129,5 @@ declare class GDTAdSDK {
12
129
  getSDKInfo(posId: string): Promise<string>;
13
130
  }
14
131
  declare const _default: GDTAdSDK;
15
- export default _default;
132
+
133
+ export { _default as default };