ylh-pc-ad-sdk 0.1.0 → 1.0.0-alpha

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.
Files changed (57) hide show
  1. package/dist/index.d.ts +91 -4
  2. package/dist/ylh-pc-ad-bridge.v1.0.0-alpha.esm.js +1 -0
  3. package/dist/ylh-pc-ad-bridge.v1.0.0-alpha.js +1 -0
  4. package/dist/ylh-pc-ad-sdk.v1.0.0-alpha.esm.js +1 -0
  5. package/dist/ylh-pc-ad-sdk.v1.0.0-alpha.js +1 -0
  6. package/package.json +20 -16
  7. package/dist/api/loadFeedAd.d.ts +0 -2
  8. package/dist/api/mockData.d.ts +0 -2
  9. package/dist/api/mockParams.d.ts +0 -26
  10. package/dist/api/reportClickCGI.d.ts +0 -6
  11. package/dist/api/reportExposeCGI.d.ts +0 -7
  12. package/dist/api/reportVideoCGI.d.ts +0 -6
  13. package/dist/beacon/index.d.ts +0 -15
  14. package/dist/bridge.d.ts +0 -11
  15. package/dist/common/baseAd.d.ts +0 -16
  16. package/dist/common/constants.d.ts +0 -63
  17. package/dist/common/types.d.ts +0 -157
  18. package/dist/core/BaseClickHandler.d.ts +0 -23
  19. package/dist/core/BaseExposureHandler.d.ts +0 -29
  20. package/dist/core/BeaconTracker.d.ts +0 -13
  21. package/dist/core/CacheManager.d.ts +0 -11
  22. package/dist/core/ContainerObserver.d.ts +0 -29
  23. package/dist/core/EventEmitter.d.ts +0 -10
  24. package/dist/core/EventManager.d.ts +0 -11
  25. package/dist/core/ParamsManager.d.ts +0 -17
  26. package/dist/core/WxGameSDK.d.ts +0 -11
  27. package/dist/gdt-union-bridge.esm.js +0 -1
  28. package/dist/gdt-union-bridge.esm.js.map +0 -1
  29. package/dist/gdt-union-bridge.js +0 -1
  30. package/dist/gdt-union-bridge.js.map +0 -1
  31. package/dist/gdt-union-sdk.esm.js +0 -1
  32. package/dist/gdt-union-sdk.esm.js.map +0 -1
  33. package/dist/gdt-union-sdk.js +0 -1
  34. package/dist/gdt-union-sdk.js.map +0 -1
  35. package/dist/http/adapter/FetchAdapter.d.ts +0 -5
  36. package/dist/http/adapter/JSBridgeAdapter.d.ts +0 -5
  37. package/dist/http/adapter/JSONPAdapter.d.ts +0 -20
  38. package/dist/http/adapter/XHRAdapter.d.ts +0 -5
  39. package/dist/http/http.types.d.ts +0 -24
  40. package/dist/http/index.d.ts +0 -11
  41. package/dist/http/utils.d.ts +0 -1
  42. package/dist/lib/wxgamesdk.js +0 -1
  43. package/dist/native/MsgChannel/index.d.ts +0 -15
  44. package/dist/native/VideoManager/index.d.ts +0 -28
  45. package/dist/native/constants.d.ts +0 -37
  46. package/dist/native/index.d.ts +0 -72
  47. package/dist/native/typings.d.ts +0 -52
  48. package/dist/native/utils.d.ts +0 -13
  49. package/dist/sence/banner/index.d.ts +0 -7
  50. package/dist/sence/feed/AdViewBinder.d.ts +0 -13
  51. package/dist/sence/feed/MediaViewBinder.d.ts +0 -12
  52. package/dist/sence/feed/index.d.ts +0 -30
  53. package/dist/utils/crypto.d.ts +0 -18
  54. package/dist/utils/index.d.ts +0 -31
  55. package/dist/utils/viewport.d.ts +0 -19
  56. package/dist/widgets/AdContainer.d.ts +0 -9
  57. package/dist/widgets/VideoContainer.d.ts +0 -55
package/package.json CHANGED
@@ -1,33 +1,39 @@
1
1
  {
2
2
  "name": "ylh-pc-ad-sdk",
3
- "version": "0.1.0",
3
+ "version": "1.0.0-alpha",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "registry": "https://registry.npmjs.org/"
8
8
  },
9
- "main": "dist/gdt-union-sdk.js",
10
- "module": "dist/gdt-union-sdk.esm.js",
9
+ "main": "dist/ylh-pc-ad-sdk.v1.0.0-alpha.js",
10
+ "module": "dist/ylh-pc-ad-sdk.v1.0.0-alpha.esm.js",
11
11
  "types": "dist/index.d.ts",
12
12
  "files": [
13
- "dist"
13
+ "dist/ylh-pc-ad-sdk.v1.0.0-alpha.js",
14
+ "dist/ylh-pc-ad-sdk.v1.0.0-alpha.esm.js",
15
+ "dist/ylh-pc-ad-bridge.v1.0.0-alpha.js",
16
+ "dist/ylh-pc-ad-bridge.v1.0.0-alpha.esm.js",
17
+ "dist/index.d.ts",
18
+ "dist/bridge.d.ts"
14
19
  ],
15
20
  "exports": {
16
21
  ".": {
17
- "import": "./dist/gdt-union-sdk.esm.js",
18
- "require": "./dist/gdt-union-sdk.js",
22
+ "import": "./dist/ylh-pc-ad-sdk.v1.0.0-alpha.esm.js",
23
+ "require": "./dist/ylh-pc-ad-sdk.v1.0.0-alpha.js",
19
24
  "types": "./dist/index.d.ts"
20
25
  },
21
26
  "./bridge": {
22
- "import": "./dist/gdt-union-bridge.esm.js",
23
- "require": "./dist/gdt-union-bridge.js",
27
+ "import": "./dist/ylh-pc-ad-bridge.v1.0.0-alpha.esm.js",
28
+ "require": "./dist/ylh-pc-ad-bridge.v1.0.0-alpha.js",
24
29
  "types": "./dist/bridge.d.ts"
25
30
  }
26
31
  },
27
32
  "scripts": {
28
- "build": "cross-env NODE_ENV=production BUILD_ENV=production rollup -c",
29
- "build:test": "cross-env NODE_ENV=production BUILD_ENV=test rollup -c",
30
- "build:dev": "cross-env NODE_ENV=development BUILD_ENV=development rollup -c",
33
+ "clean": "rimraf dist",
34
+ "build": "npm run clean && cross-env NODE_ENV=production BUILD_ENV=production rollup -c && node scripts/update-package.js",
35
+ "build:dev": "npm run clean && cross-env NODE_ENV=development BUILD_ENV=development rollup -c && node scripts/update-package.js",
36
+ "build:test": "npm run clean && cross-env NODE_ENV=production BUILD_ENV=test rollup -c && node scripts/update-package.js",
31
37
  "dev": "cross-env NODE_ENV=development BUILD_ENV=development rollup -c -w",
32
38
  "prepublishOnly": "npm run build",
33
39
  "publish:npm": "npm publish --access public"
@@ -39,16 +45,14 @@
39
45
  "@rollup/plugin-replace": "^6.0.2",
40
46
  "@rollup/plugin-terser": "^0.4.4",
41
47
  "@rollup/plugin-typescript": "^11.1.5",
42
- "@types/crypto-js": "^4.2.2",
43
48
  "@types/node": "^22.13.4",
44
49
  "cross-env": "^7.0.3",
50
+ "rimraf": "^5.0.0",
45
51
  "rollup": "^4.1.4",
46
52
  "rollup-plugin-analyzer": "^4.0.0",
53
+ "rollup-plugin-dts": "^6.1.1",
47
54
  "rollup-plugin-filesize": "^10.0.0",
48
55
  "tslib": "^2.6.2",
49
56
  "typescript": "^5.2.2"
50
- },
51
- "dependencies": {
52
- "crypto-js": "^4.2.0"
53
57
  }
54
- }
58
+ }
@@ -1,2 +0,0 @@
1
- import { GDTAdLoadConfig, AdLoadEvent } from '../common/types';
2
- export default function loadFeedAdService(query: GDTAdLoadConfig, customParams?: Record<string, any>): Promise<AdLoadEvent>;
@@ -1,2 +0,0 @@
1
- import { AdData } from '../common/types';
2
- export declare const mockAdData: Record<string, AdData>;
@@ -1,26 +0,0 @@
1
- declare const mockParams: {
2
- ext: {
3
- debug: boolean;
4
- req: {
5
- long_aid: number;
6
- nomatch: boolean;
7
- c_w: number;
8
- c_h: number;
9
- c_os: string;
10
- c_hl: string;
11
- url: string;
12
- sdk_src: string;
13
- tmpallpt: boolean;
14
- click_ext: string;
15
- inline_full_screen: number;
16
- webp: string;
17
- support_video: boolean;
18
- appid: string;
19
- rst: string;
20
- };
21
- pos: {
22
- '0': {};
23
- };
24
- };
25
- };
26
- export default mockParams;
@@ -1,6 +0,0 @@
1
- interface ReportClickParams {
2
- url: string;
3
- params?: Record<string, any>;
4
- }
5
- export default function reportClickCGI({ url }: ReportClickParams): Promise<import("../http/http.types").HttpResponse>;
6
- export {};
@@ -1,7 +0,0 @@
1
- interface ReportExposeParams {
2
- url: string;
3
- params?: Record<string, any>;
4
- }
5
- export default function reportExposeCGI({ url, params }: ReportExposeParams): Promise<import("../http/http.types").HttpResponse>;
6
- export declare function reportExposeCGIByImg({ url, params }: ReportExposeParams): Promise<void>;
7
- export {};
@@ -1,6 +0,0 @@
1
- interface ReportVideoParams {
2
- params: Record<string, any>;
3
- url: string;
4
- }
5
- export default function reportVideoCGI({ url, params }: ReportVideoParams): Promise<any>;
6
- export {};
@@ -1,15 +0,0 @@
1
- interface IReportData {
2
- [keys: string]: string | number;
3
- }
4
- declare class BeaconTracker {
5
- private static instance;
6
- private beacon;
7
- private cacheList;
8
- private isInitializing;
9
- static getInstance: () => BeaconTracker;
10
- init: () => void;
11
- report: (event: string, data: IReportData) => void;
12
- private cache;
13
- private flush;
14
- }
15
- export default BeaconTracker;
package/dist/bridge.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import NativeBridge from './native';
2
- declare class CreateNativeBridgeInStance {
3
- private nativeBridge;
4
- constructor(nativeBridge: typeof NativeBridge);
5
- loadFeedAdData(): void;
6
- executeClickCGI(): void;
7
- executeExposeCGI(): void;
8
- executebindMediaView(): void;
9
- }
10
- declare const GDTNativeBridge: CreateNativeBridgeInStance;
11
- export default GDTNativeBridge;
@@ -1,16 +0,0 @@
1
- import { BaseAdConfig, AdData, GDTAdLoadConfig, AdError, AdLoadEvent } from './types';
2
- import EventManager from '../core/EventManager';
3
- declare abstract class GDTBaseAd {
4
- protected readonly props: BaseAdConfig;
5
- protected readonly eventManager: EventManager;
6
- protected readonly adInfo: AdData;
7
- protected readonly adConfig: GDTAdLoadConfig;
8
- protected readonly traceid: string;
9
- constructor(props: BaseAdConfig);
10
- getTraceId(): string;
11
- onLoad(callback: (event: AdLoadEvent) => void): void;
12
- onError(callback: (error: AdError) => void): void;
13
- onExpose(callback: (id: string) => void): void;
14
- onClick(callback: () => void): void;
15
- }
16
- export default GDTBaseAd;
@@ -1,63 +0,0 @@
1
- export declare const AD_LOAD = "ad_load";
2
- export declare const AD_CLOSE = "ad_close";
3
- export declare const AD_ERROR = "on_error";
4
- export declare const AD_EXPOSE = "ad_expose";
5
- export declare const AD_CLICK = "ad_click";
6
- export declare const AD_REWARD = "ad_reward";
7
- export declare const AD_VIDEO_FINISH = "ad_video_finish";
8
- export declare const ERROR_CODES: {
9
- readonly INVALID_PLACEMENT: 1001;
10
- readonly BINDING_FAILED: 1002;
11
- readonly LOAD_FAILED: 1003;
12
- readonly INVALID_AD_DATA: 1004;
13
- readonly INVALID_CLICK_DATA: 1005;
14
- readonly CONTAINER_NOT_FOUND: 1006;
15
- readonly INVALID_PARAMS: 1007;
16
- readonly INVALID_OPERATION: 1008;
17
- readonly CLICK_FAILED: 1009;
18
- readonly EXPOSURE_FAILED: 1010;
19
- readonly AD_EXPIRED: 1011;
20
- readonly MEDIA_BINDING_FAILED: 3001;
21
- readonly INVALID_MEDIA_DATA: 3002;
22
- readonly INVALID_MEDIA_VIEW: 3003;
23
- readonly INVALID_CONTAINER: 10010;
24
- };
25
- export declare const ERROR_MESSAGES: {
26
- readonly AD_INFO_NOT_EXIST: "广告信息不存在";
27
- readonly AD_INSTANCE_DESTROYED: "广告实例已销毁";
28
- readonly AD_EXPIRED: "广告已过期";
29
- readonly AD_CONTAINER_MISSING: "缺少广告容器";
30
- readonly AD_CONTAINER_TYPE_ERROR: "广告容器类型错误";
31
- readonly AD_ID_NOT_EXIST: "广告ID不存在";
32
- readonly MEDIA_CONTAINER_MISSING: "缺少媒体容器";
33
- readonly MEDIA_CONTAINER_NOT_IN_AD: "媒体容器不在广告容器中";
34
- readonly VIDEO_URL_NOT_EXIST: "视频地址不存在";
35
- readonly VIDEO_SIZE_INVALID: "视频尺寸参数无效";
36
- readonly CLICK_ELEMENTS_NOT_EXIST: "点击元素不存在";
37
- readonly CLICK_ELEMENTS_NOT_IN_CONTAINER: "点击元素必须在容器内";
38
- readonly CLICK_URL_NOT_EXIST: "点击链接不存在";
39
- readonly CLICK_REPORT_FAILED: "点击上报失败";
40
- readonly EXPOSURE_CONTAINER_NOT_EXIST: "广告容器不存在";
41
- readonly EXPOSURE_ID_EMPTY: "id不能为空";
42
- readonly EXPOSURE_LINK_EMPTY: "eLink不能为空";
43
- readonly EXPOSURE_ID_TYPE_ERROR: "id必须是字符串类型";
44
- readonly EXPOSURE_LINK_TYPE_ERROR: "eLink必须是字符串类型";
45
- readonly EXPOSURE_REPORT_FAILED: "曝光上报失败";
46
- readonly CONTAINER_INIT_FAILED: "广告容器初始化失败";
47
- readonly VIEW_BINDING_FAILED: "广告视图绑定失败";
48
- };
49
- export declare const PRODBASEURL = "https://mi.gdt.qq.com/gdt_mview.fcg";
50
- export declare const TESTBASRURL = "http://test.mi.gdt.qq.com:8080";
51
- export declare const BEACON_EVENTS: {
52
- readonly SDK_INIT: "sdk_init";
53
- readonly AD_CLICK: "ad_click";
54
- readonly AD_EXPOSE: "ad_expose";
55
- readonly BRIDGE_INIT: "bridge_init";
56
- readonly BRIDGE_METHOD: "bridge_method";
57
- };
58
- export declare const BEACON_STATUS: {
59
- readonly SUCCESS: 1;
60
- readonly FAIL: 0;
61
- };
62
- export declare const ICONURLKEY = "2025";
63
- export declare const ADLOGOURL = "https://qzs.gdtimg.com/union/res/union_cdn/page/ams_icon/ad_logo_light.png";
@@ -1,157 +0,0 @@
1
- import GDTFeedAd from '../sence/feed';
2
- export interface AdError {
3
- message: string;
4
- error?: unknown;
5
- }
6
- export interface SDKConfig {
7
- appId?: string;
8
- sessionData?: any;
9
- }
10
- export interface BindAdToViewProps {
11
- containerView: HTMLElement;
12
- clickableElements?: HTMLElement[];
13
- onExpose?: (placementId: string) => void;
14
- onClick?: (event: MouseEvent) => void;
15
- onError?: (error: AdError) => void;
16
- }
17
- export interface AdInterface {
18
- bindAdToView: (props: BindAdToViewProps) => void;
19
- bindMediaView: (props: BindMediaViewProps) => void;
20
- getTitle: () => string;
21
- getImageUrl: () => string;
22
- getImageWidth: () => number;
23
- getImageHeight: () => number;
24
- getImageUrls: () => string[];
25
- getDescription: () => string;
26
- getIconUrl: () => string;
27
- getAdLogoUrl: () => string;
28
- getAdPatternType: () => string;
29
- hasVideo: () => boolean;
30
- isValid: () => boolean;
31
- getECPM: () => number;
32
- destroy: () => void;
33
- }
34
- export interface AdLoadEvent {
35
- success: boolean;
36
- data: AdData[] | AdInterface[];
37
- message?: string;
38
- }
39
- export interface AdData {
40
- traceid?: string;
41
- imageUrl: string;
42
- title: string;
43
- description: string;
44
- txt: string;
45
- desc: string;
46
- img?: string;
47
- iconUrl?: string;
48
- button_txt?: string;
49
- instance?: GDTFeedAd;
50
- clickUrl?: string;
51
- rl?: string;
52
- universal_link?: string;
53
- customized_invoke_url?: string;
54
- apurl?: string;
55
- ecpm?: number;
56
- cta?: string;
57
- advertiser?: string;
58
- video?: string;
59
- video_report_url?: string;
60
- img_list?: string;
61
- pic_width?: number;
62
- pic_height?: number;
63
- ext?: AdExtInfo;
64
- [key: string]: unknown;
65
- }
66
- export interface GDTAdLoadConfig {
67
- placementId: string;
68
- count?: number;
69
- appId?: string;
70
- }
71
- export interface ClickCoordinates {
72
- down_x: string;
73
- down_y: string;
74
- up_x: string;
75
- up_y: string;
76
- }
77
- export interface NativeAdContainerOptions {
78
- logoPosition?: {
79
- top?: number;
80
- right?: number;
81
- bottom?: number;
82
- left?: number;
83
- };
84
- logoSize?: {
85
- width: number;
86
- height: number;
87
- };
88
- }
89
- export type ErrorCallback = (error: AdError) => void;
90
- export type ExposeCallback = (id: string) => void;
91
- export type ClickCallback = () => void;
92
- export type LoadCallback = (event: AdLoadEvent) => void;
93
- export type ViewabilityCallback = (isVisible: boolean) => void;
94
- export declare const ERROR_CODES: {
95
- readonly INVALID_PLACEMENT: 1001;
96
- readonly BINDING_FAILED: 1002;
97
- readonly LOAD_FAILED: 1003;
98
- readonly INVALID_AD_DATA: 1004;
99
- readonly INVALID_CLICK_DATA: 1005;
100
- };
101
- export interface GDTBaseAdInterface {
102
- destroy(): void;
103
- isValid(): boolean;
104
- emitError(error: AdError): void;
105
- cleanupEventListeners(): void;
106
- getECPM(): number;
107
- }
108
- export interface BaseAdConfig {
109
- loadConfig: GDTAdLoadConfig;
110
- adInfo: AdData;
111
- }
112
- export interface FeedAdOptions extends BaseAdConfig {
113
- exposureThreshold?: number;
114
- exposureDuration?: number;
115
- }
116
- export interface VideoOption {
117
- autoplay?: boolean;
118
- muted?: boolean;
119
- controls?: boolean;
120
- width?: string | number;
121
- height?: string | number;
122
- poster?: string;
123
- preload?: string;
124
- }
125
- export interface AdEventListeners {
126
- onExpose?: (placementId: string) => void;
127
- onClick?: (event: MouseEvent) => void;
128
- onError?: (error: AdError) => void;
129
- }
130
- export interface VideoControl {
131
- play: () => void;
132
- pause: () => void;
133
- replay: () => void;
134
- }
135
- export interface NativeADMediaListener {
136
- onPlay?: () => void;
137
- onPause?: () => void;
138
- onCompleted?: () => void;
139
- onError?: (error: Error) => void;
140
- onTimeUpdate?: (currentTime: number, duration: number) => void;
141
- onReady?: ($video: VideoControl) => void;
142
- }
143
- export interface BindMediaViewProps {
144
- mediaView: HTMLElement;
145
- videoOptions?: VideoOption;
146
- mediaListener?: NativeADMediaListener;
147
- }
148
- export interface AdExtIconInfo {
149
- iconurl: string;
150
- [key: string]: unknown;
151
- }
152
- export interface AdExtInfo {
153
- alist: {
154
- [key: string]: AdExtIconInfo;
155
- };
156
- [key: string]: unknown;
157
- }
@@ -1,23 +0,0 @@
1
- import { ClickCoordinates } from '../common/types';
2
- import EventManager from './EventManager';
3
- export interface ClickHandlerOptions {
4
- containerView: HTMLElement;
5
- clickableElements?: HTMLElement[];
6
- id: string | undefined;
7
- cLink: string | undefined;
8
- }
9
- declare class BaseClickHandler {
10
- private readonly eventManager;
11
- protected id: string | undefined;
12
- protected clickURL: string | undefined;
13
- protected container: HTMLElement;
14
- protected clickableElements: HTMLElement[];
15
- protected coordinates: ClickCoordinates;
16
- constructor(eventManager: EventManager, options: ClickHandlerOptions);
17
- protected validateClickableElements(): boolean;
18
- private clickableElementsEventHandler;
19
- private clickableElementsBindEvent;
20
- destroy(): void;
21
- private emitError;
22
- }
23
- export default BaseClickHandler;
@@ -1,29 +0,0 @@
1
- import EventManager from './EventManager';
2
- export interface ExposureTrackerOptions {
3
- containerView: HTMLElement;
4
- id?: string;
5
- eLink?: string;
6
- }
7
- declare class BaseExposureHandler {
8
- private readonly eventManager;
9
- protected id?: string;
10
- protected eLink?: string;
11
- protected container: HTMLElement;
12
- private observer;
13
- private exposureTimeout;
14
- private readonly threshold;
15
- private readonly exposureDuration;
16
- private validateOptions;
17
- constructor(eventManager: EventManager, options: ExposureTrackerOptions);
18
- initExposureTracking(): void;
19
- private setupIntersectionObserver;
20
- private clearExposureCheck;
21
- private finalVisibilityCheck;
22
- private scheduleExposureCheck;
23
- private setupFallbackTracking;
24
- private hasExposed;
25
- private handleVisibilityChange;
26
- destroy(): void;
27
- private emitError;
28
- }
29
- export default BaseExposureHandler;
@@ -1,13 +0,0 @@
1
- declare class BeaconTracker {
2
- private static instance;
3
- private beacon;
4
- private cacheList;
5
- private isInitializing;
6
- static getInstance: () => BeaconTracker;
7
- init: () => void;
8
- report: (event: string, data: Record<string, any>) => void;
9
- private cache;
10
- private flush;
11
- }
12
- declare const _default: BeaconTracker;
13
- export default _default;
@@ -1,11 +0,0 @@
1
- interface AdCacheData {
2
- adExpireTimestamp?: number;
3
- [key: string]: any;
4
- }
5
- interface CacheData {
6
- [key: string]: AdCacheData | null;
7
- }
8
- export declare function setAdDataInCacheManager(id: string, data: AdCacheData): void;
9
- export declare function removeAdDataInCacheManager(id: string | undefined): void;
10
- export declare function getAdsDataFromCacheManager(id: string): CacheData;
11
- export {};
@@ -1,29 +0,0 @@
1
- export interface ContainerObserverOptions {
2
- /** 容器内容就绪时的回调函数 */
3
- onReady?: (isReady: boolean) => void;
4
- /** 防抖延迟时间(毫秒) */
5
- debounceTime?: number;
6
- /** 容器大小阈值 */
7
- minSize?: {
8
- width: number;
9
- height: number;
10
- };
11
- }
12
- export declare class ContainerObserver {
13
- private resizeObserver;
14
- private mutationObserver;
15
- private checkTimer;
16
- private isDestroyed;
17
- private readonly container;
18
- private readonly readyCallback;
19
- private readonly debounceTime;
20
- private readonly options;
21
- constructor(container: HTMLElement, options?: ContainerObserverOptions);
22
- private startObserving;
23
- private initResizeObserver;
24
- private initMutationObserver;
25
- private debounceCheck;
26
- private checkContainerContent;
27
- private validateContainer;
28
- destroy(): void;
29
- }
@@ -1,10 +0,0 @@
1
- type EventCallback = (...args: any[]) => void;
2
- declare class EventEmitter {
3
- private events;
4
- constructor();
5
- on(event: string, callback: EventCallback): void;
6
- off(event: string, callback: EventCallback): void;
7
- emit(event: string, ...args: any[]): void;
8
- removeAllListeners(): void;
9
- }
10
- export default EventEmitter;
@@ -1,11 +0,0 @@
1
- declare class EventManager {
2
- private static instance;
3
- private eventEmitter;
4
- constructor();
5
- static getInstance(): EventManager;
6
- on(event: string, callback: (...args: any[]) => void): void;
7
- off(event: string, callback: (...args: any[]) => void): void;
8
- emit(event: string, ...args: any[]): void;
9
- removeAllListeners(): void;
10
- }
11
- export default EventManager;
@@ -1,17 +0,0 @@
1
- import { GDTAdLoadConfig } from '../common/types';
2
- declare class ParamsManager {
3
- private static instance;
4
- static getInstance(): ParamsManager;
5
- getRequestParams({ count, placementId, appId, }: GDTAdLoadConfig): Record<string, string | number | boolean | object>;
6
- mergeParams(params: Record<string, any>, customParams: Record<string, any>): Record<string, any>;
7
- private getBaseParams;
8
- private filterEmptyValues;
9
- private getExtReqParams;
10
- private getIfSupportH265;
11
- private getOS;
12
- private getOSVersion;
13
- private getVerticalScreenSize;
14
- private getDeviceType;
15
- private _getNetworkType;
16
- }
17
- export default ParamsManager;
@@ -1,11 +0,0 @@
1
- export declare class WxGameSDK {
2
- private static instance;
3
- private wxGameSDK?;
4
- static getInstance(): WxGameSDK;
5
- load(): Promise<any>;
6
- getSDK(): any;
7
- getGameSession(appId: string): Promise<any>;
8
- init(): Promise<void>;
9
- }
10
- declare const _default: WxGameSDK;
11
- export default _default;
@@ -1 +0,0 @@
1
- function t(t){const i="[object Number]"===Object.prototype.toString.call(t);return!i||i&&0>=t?0:60*t*1e3}function i(){return`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`}function e(t){const i=decodeURIComponent(t);let e="";const s=/viewid=([^&]+)/;return s.test(i)&&([,e=""]=i.match(s)||[]),e}navigator.userAgent.toLowerCase(),navigator.userAgent.toLowerCase();class s{static getInstance(){return this.instance||(this.instance=new s),this.instance}getRequestParams({count:t,placementId:i,appId:e}){return{...this.getBaseParams({count:t,placementId:i,appId:e}),...this.getExtReqParams()}}mergeParams(t,i){return Object.keys(i).forEach((e=>{"object"==typeof i[e]?this.mergeParams(t[e],i[e]):t[e]=i[e]})),t}getBaseParams({appId:t,count:i=1,placementId:e=""}){return this.filterEmptyValues({appid:t,adposcount:1,count:i,posid:e,datatype:"jsonp",support_https:1,charset:"utf8",r:Math.random(),datafmt:"jsonp"})}filterEmptyValues(t){return Object.entries(t).reduce(((t,[i,e])=>(""!==e&&null!=e&&(t[i]=e),t)),{})}getExtReqParams(){const{physicalWidth:t,physicalHeight:i}=this.getVerticalScreenSize(),e={oaid:"",m10:"",m11:"",m12:"",conn:this.t(),carrier:0,c_os:this.getOS()||"",c_osver:this.getOSVersion()||"",c_device:navigator.userAgent||"",c_devicetype:this.getDeviceType(),c_mf:"",c_ori:window.screen.orientation.angle||0,c_w:t||0,c_h:i||0,c_sdfree:"",c_hl:navigator.language||"zh",sdkver:"0.1.0",c_pkgname:"",hostver:"",sdk_st:1,sdk_cnl:1,sdk_src:"windows",support_features:0,s_hd:this.getIfSupportH265(),deep_link_version:0,placement_type:9,postype:"",render_type:1,tmpallpt:!0,support_video:!0,istopr:0,appid:"",support_tpl2:"",prld:"",c_webua:navigator.userAgent,support_container:!0,max_duration:61,min_duration:5};return{ext:{req:this.filterEmptyValues(e)}}}getIfSupportH265(){const t=document.createElement("video");return["hev1.1.6.L93.90","hvc1.1.6.L93.90","hev1.2.4.L153.B0","hvc1.2.4.L153.B0"].some((i=>"probably"===t.canPlayType(`video/mp4; codecs="${i}"`)))}getOS(){const t=navigator.userAgent;return/Mac OS X/.test(t)?"mac":/iPhone|iPad|iPod/.test(t)?"ios":/Android/.test(t)?"android":/Windows/.test(t)?"windows":"Unknown"}getOSVersion(){const t=navigator.userAgent,i=this.getOS();if("android"===i){const i=t.match(/Android\s+([\d.]+)/);return i?i[1]:"Unknown"}if("ios"===i){const i=t.match(/OS\s+([\d._]+)/);return i?i[1].replace(/_/g,"."):"Unknown"}if("windows"===i){const i=t.match(/Windows NT\s+([\d.]+)/);return i?i[1]:"Unknown"}if("mac"===i){const i=t.match(/(?:Mac OS X |Version\/)(\d+(?:[._]\d+)+)/i);return i?i[1].replace(/_/g,"."):"Unknown"}return"Unknown"}getVerticalScreenSize(){const t=window.screen.width,i=window.screen.height,e=window.screen.orientation.angle,s=0===e||180===e;return{physicalWidth:s?i:t,physicalHeight:s?t:i}}getDeviceType(){const t=navigator.userAgent.toLowerCase();return/ipad/.test(t)?2:/mobile/.test(t)?1:0}t(){try{const t=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(!t)return 0;const{effectiveType:i="",type:e="unknown",downlink:s=0}=t;if(s>1||"wifi"===e||"ethernet"===e)return 1;if("cellular"===e||"mobile"===e)switch(i){case"4g":case"5g":return 4;case"3g":return 3;case"2g":return 2}return 0}catch(t){return 0}}}class n{constructor(){this.defaultTimeout=5e3,this.timer=null,this.callbackPrefix="_",this.isCallbackCalled=!1}async execute(t){const{url:i,params:e={},jsonpCallbackName:s,timeout:n=this.defaultTimeout}=t;if(!i)throw Error("URL is required");const r=!!s,o=s||this.generateCallbackName();return new Promise(((t,s)=>{const a=this.createScriptElement();this.isCallbackCalled=!1,window[o]=i=>{this.handleResponse(i,{script:a,callbackName:o,useHardcodedCallback:r,resolve:t,reject:s})};const d=this.buildQueryString({...e,callback:o,i:Date.now()});this.setupTimeout(n,a,o,r,s),a.onerror=()=>{this.handleError(a,o,r,s)},a.src=`${i}${i.includes("?")?"&":"?"}${d}`,document.body.appendChild(a)}))}generateCallbackName(){const t=Date.now().toString(36).slice(-6),i=Math.floor(1296*Math.random()).toString(36).padStart(2,"0");return`${this.callbackPrefix}${t}${i}`}createScriptElement(){const t=document.createElement("script");return t.type="text/javascript",t.async=!0,t}buildQueryString(t){return Object.entries(t).map((([t,i])=>{const e="object"==typeof i?JSON.stringify(i):i+"";return`${encodeURIComponent(t)}=${encodeURIComponent(e)}`})).join("&")}handleResponse(t,i){var e,s;if(this.isCallbackCalled)return;const{script:n,callbackName:r,useHardcodedCallback:o,resolve:a,reject:d}=i;this.isCallbackCalled=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),0===(null==t?void 0:t.ret)?a({status:200,data:t}):d({status:500,data:{ret:null!==(e=null==t?void 0:t.ret)&&void 0!==e?e:-1,msg:null!==(s=null==t?void 0:t.msg)&&void 0!==s?s:"Unknown error"}}),this.cleanup(n,r,o)}handleError(t,i,e,s){this.isCallbackCalled||(this.isCallbackCalled=!0,this.timer&&(clearTimeout(this.timer),this.timer=null),s({status:404,data:{ret:-1,msg:"Script load failed"}}),this.cleanup(t,i,e))}setupTimeout(t,i,e,s,n){this.timer=setTimeout((()=>{this.isCallbackCalled||(this.isCallbackCalled=!0,n({status:408,data:{ret:-1,msg:`Timeout after ${t}ms`}}),this.cleanup(i,e,s))}),t)}cleanup(t,i,e){var s;t.parentNode&&t.parentNode.removeChild(t),s=()=>{try{e||delete window[i]}catch(t){}this.isCallbackCalled=!1},"function"==typeof queueMicrotask?queueMicrotask(s):Promise.resolve().then(s)}}class r{constructor(){this.adapter=this.createAdapter()}static getInstance(){return this.instance||(this.instance=new r),this.instance}createAdapter(){return"undefined"!=typeof window&&window.chrome,new n}async request(t){return this.adapter.execute({...t,params:t.params||{}})}}var o=r.getInstance();const a=new class{constructor(){this.cache=new Map}set(t,i){const e=this.get(t)||{},s=Object.fromEntries(Object.entries(i).filter((([t,i])=>null!==i)));this.cache.set(t,{...e,...s})}get(t){return this.cache.get(t)}remove(t){this.cache.delete(t)}clear(){this.cache.clear()}};async function d({url:t,params:i}){return await o.request({url:t,params:{datatype:"jsonp",...i}})}const h=(()=>{let t=!1;return()=>new Promise(((i,e)=>{if(t)return i();t=!0;const s=document.createElement("script");s.src="https://beacon.cdn.qq.com/sdk/4.5.30/beacon_web.min.js",s.type="text/javascript",s.onerror=i=>{s.remove(),t=!1,e(Error("Load Error"))},s.onload=()=>{i()},document.body.appendChild(s)}))})();class u{constructor(){this.cacheList=[],this.isInitializing=!1,this.init=()=>{this.isInitializing||this.beacon||(this.isInitializing=!0,h().then((()=>{this.beacon=new window.BeaconAction({appkey:"JS05KY1G393HQI",delay:1e3,sessionDuration:6e4,onReportFail:t=>{}}),this.flush()})).catch((t=>{})).finally((()=>{this.isInitializing=!1})))},this.report=(t,i)=>{this.beacon?this.beacon.onDirectUserAction(t,i):this.cache(t,i)},this.cache=(t,i)=>{this.cacheList.push({event:t,data:i})},this.flush=()=>{if(this.cacheList.length)for(;this.cacheList.length;){const{event:t,data:i}=this.cacheList.shift();this.report(t,i)}}}}u.getInstance=()=>(u.instance||(u.instance=new u),u.instance);var c,l,v,p,m=u.getInstance();!(function(t){t.INVOKE="invoke"})(c||(c={})),(function(t){t.INIT="sdk_initialized",t.RETURN="return",t.INVALID_MESSAGE="invalid_message",t.VIDEO_PLAY="video_play",t.VIDEO_PAUSE="video_pause",t.VIDEO_ENDED="video_ended",t.VIDEO_ERROR="video_error",t.VIDEO_TIMEUPDATE="video_timeupdate",t.VIDEO_READY="video_ready"})(l||(l={})),(function(t){t[t.PARSE_ERROR=-32700]="PARSE_ERROR",t[t.INVALID_REQUEST=-32600]="INVALID_REQUEST",t[t.METHOD_NOT_FOUND=-32601]="METHOD_NOT_FOUND",t[t.INVALID_PARAMS=-32602]="INVALID_PARAMS",t[t.INTERNAL_ERROR=-32603]="INTERNAL_ERROR",t[t.UNKNOWN=-32e3]="UNKNOWN",t[t.INVALID_APPID=-32001]="INVALID_APPID",t[t.AD_NOT_FOUND=-32002]="AD_NOT_FOUND",t[t.CONTAINER_NOT_FOUND=-32003]="CONTAINER_NOT_FOUND"})(v||(v={})),(function(t){t.PARSE_ERROR="Parse error: JSON解析错误",t.INVALID_REQUEST="Invalid request: 无效的请求",t.METHOD_NOT_FOUND="Method not found: 方法不存在",t.INVALID_PARAMS="Invalid params: 无效的参数",t.INTERNAL_ERROR="Internal error: 内部错误",t.UNKNOWN="Unknown error: 未知错误",t.INVALID_APPID="Invalid AppID: 无效的AppID",t.AD_NOT_FOUND="Ad not found: 广告数据不存在",t.CONTAINER_NOT_FOUND="Container not found: 容器不存在"})(p||(p={}));class w{constructor(){this.setuped=!1,this.setupMessageListener=()=>{var t,i;this.setuped||(null===(i=null===(t=window.chrome)||void 0===t?void 0:t.webview)||void 0===i||i.addEventListener("message",(({data:t})=>{const{event:i,data:e}=t;if(i===c.INVOKE){const{method:t,params:i,id:s,targetId:n}=e;this.handleInvokeMessage(t,i,s,n)}else this.handleSystemMessage(i,e)})),this.setuped=!0)},this.registerHandler=t=>{this.invokeHandler=t},this.send=async(t,i)=>{var e,s;null===(s=null===(e=window.chrome)||void 0===e?void 0:e.webview)||void 0===s||s.postMessage({event:t,data:i})},this.sendInvokeResult=async t=>{this.send(l.RETURN,t)},this.handleInvokeMessage=async(t,i,e,s)=>{var n;const r=await(null===(n=this.invokeHandler)||void 0===n?void 0:n.call(this,t,i,s));this.sendInvokeResult(r.result?{id:e,result:r.result}:{id:e,error:r.error})},this.handleSystemMessage=(t,i)=>{}}}function f(t,i={},e){const s=(function(t,i={}){const{viewId:e,duration:s=0,currentTime:n=0,pauseCount:r=0}=t,o=Math.round(s);return{viewid:e,datatype:"jsonp",video:{bt:"0",et:""+("1"===i.ef?o:Math.round(n)),bf:"1",ef:"0",pp:"3",pa:r>0?"2":"1",pb:"1",ps:"0",vt:""+o,...i}}})(t,i);return(async function({url:t,params:i}){return await d({url:t,params:i})})({url:"https:/vr.gdt.qq.com/gdt_mview.fcg",params:s}).catch((t=>{e&&e(Error(t.msg||"视频上报失败"))}))}w.getInstance=()=>(w.instance||(w.instance=new w),w.instance);class _{constructor(t){this.videoElement=null,this.pauseCount=0,this.eventHandlers={},this.props=t,this.element=document.createElement("div"),this.setupContainer()}formatDimensionValue(t,i){if(void 0===t)return i;if("number"==typeof t)return t+"px";const e=t.trim();if(/^(auto|inherit|initial|unset)$/.test(e))return e;const s=e.match(/^(\d+\.?\d*)([%a-z]*)$/);if(s){const[,t,i]=s;if(i&&["%","px","em","rem","vw","vh","vmin","vmax"].includes(i))return e;if(!i)return t+"px"}return i}setupContainer(){var t,i,e;Object.assign(this.element.style,{position:(null===(t=this.props.containerStyle)||void 0===t?void 0:t.position)||"relative",width:this.formatDimensionValue(null===(i=this.props.containerStyle)||void 0===i?void 0:i.width,"100%"),height:this.formatDimensionValue(null===(e=this.props.containerStyle)||void 0===e?void 0:e.height,"100%"),overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center"}),this.cleanupVideoElement(),this.createVideoElement()}cleanupVideoElement(){this.videoElement&&(this.unbindVideoEvents(),this.videoElement.pause(),this.videoElement.removeAttribute("src"),this.videoElement.load(),this.videoElement.remove(),this.videoElement=null)}createVideoElement(){var t,e,s,n,r,o,a,d,h,u;this.videoElement=document.createElement("video");const{videoInfo:c}=this.props;Object.assign(this.videoElement,{id:"video-"+i(),playsInline:!0,webkitPlaysinline:"true",preload:(null===(t=this.props.videoOptions)||void 0===t?void 0:t.preload)||"metadata",muted:null===(s=null===(e=this.props.videoOptions)||void 0===e?void 0:e.muted)||void 0===s||s,controls:null!==(r=null===(n=this.props.videoOptions)||void 0===n?void 0:n.controls)&&void 0!==r&&r,autoplay:null!==(a=null===(o=this.props.videoOptions)||void 0===o?void 0:o.autoplay)&&void 0!==a&&a});const l=(null===(d=this.props.videoOptions)||void 0===d?void 0:d.width)||(null==c?void 0:c.video_width),v=(null===(h=this.props.videoOptions)||void 0===h?void 0:h.height)||(null==c?void 0:c.video_height);Object.assign(this.videoElement.style,{width:this.formatDimensionValue(l,"100%"),height:this.formatDimensionValue(v,"auto"),objectFit:(null===(u=this.props.videoOptions)||void 0===u?void 0:u.objectFit)||"contain",maxWidth:"100%",maxHeight:"100%"}),(null==c?void 0:c.video)&&(this.videoElement.src=c.video),(null==c?void 0:c.video_report_url)&&(this.videoElement.poster=c.video_report_url),this.bindVideoEvents(),this.element.appendChild(this.videoElement)}bindVideoEvents(){var t;if(!this.videoElement)return;const{callbacks:i}=this.props,e={viewId:null===(t=this.props.videoInfo)||void 0===t?void 0:t.viewId,pauseCount:this.pauseCount};this.eventHandlers={loadedmetadata:()=>{var t;const e={play:()=>{var t;return null===(t=this.videoElement)||void 0===t?void 0:t.play()},pause:()=>{var t;return null===(t=this.videoElement)||void 0===t?void 0:t.pause()},replay:()=>{this.videoElement&&(this.videoElement.currentTime=0,this.videoElement.play())}};null===(t=null==i?void 0:i.onReady)||void 0===t||t.call(i,e,this.videoElement.id)},play:()=>{var t;null===(t=null==i?void 0:i.onPlay)||void 0===t||t.call(i,this.videoElement.id)},pause:()=>{var t;this.pauseCount++,null===(t=null==i?void 0:i.onPause)||void 0===t||t.call(i,this.videoElement.id),f({...e},{},null==i?void 0:i.onError)},ended:()=>{var t;null===(t=null==i?void 0:i.onEnded)||void 0===t||t.call(i,this.videoElement.id),f({...e},{},null==i?void 0:i.onError)},error:()=>{var t;const s=Error(this.getVideoErrorMessage());null===(t=null==i?void 0:i.onError)||void 0===t||t.call(i,s,this.videoElement.id),f({...e},{},null==i?void 0:i.onError)},timeupdate:()=>{var t;null===(t=null==i?void 0:i.onTimeUpdate)||void 0===t||t.call(i,this.videoElement.currentTime,this.videoElement.duration,this.videoElement.id)}},Object.entries(this.eventHandlers).forEach((([t,i])=>{this.videoElement.addEventListener(t,i)}))}unbindVideoEvents(){this.videoElement&&(Object.entries(this.eventHandlers).forEach((([t,i])=>{this.videoElement.removeEventListener(t,i)})),this.eventHandlers={})}getVideoErrorMessage(){var t;if(!this.videoElement)return"Video element not initialized";switch(null===(t=this.videoElement.error)||void 0===t?void 0:t.code){case 1:return"MEDIA_ERR_ABORTED";case 2:return"MEDIA_ERR_NETWORK";case 3:return"MEDIA_ERR_DECODE";case 4:return"MEDIA_ERR_SRC_NOT_SUPPORTED";default:return"UNKNOWN_ERROR"}}mount(t){var i,e;t.appendChild(this.element),(null===(i=this.props.videoOptions)||void 0===i?void 0:i.autoplay)&&(null===(e=this.videoElement)||void 0===e||e.play().catch((t=>{var i,e;null===(e=null===(i=this.props.callbacks)||void 0===i?void 0:i.onError)||void 0===e||e.call(i,Error("Autoplay failed: "+t.message))})))}destroy(){this.cleanupVideoElement(),this.element.parentElement&&this.element.parentElement.removeChild(this.element)}getVideoElement(){return this.videoElement}togglePlayback(){this.videoElement&&(this.videoElement.paused?this.videoElement.play().catch(console.error):this.videoElement.pause())}}const g=(t,i)=>({error:{code:t,message:i}}),y=t=>({result:t}),I=(t,i)=>null!=t&&("object"!=typeof t||!(null==i?void 0:i.some((i=>null==t[i]))));class b{constructor(){this.eventCallback=()=>{},this.videoElement=null,this.registerEventCallback=t=>{this.eventCallback=t},this.createVideoAd=async t=>{const{containerId:i,adData:e,videoOptions:s={}}=t,n=document.getElementById(i);if(!n)return g(v.CONTAINER_NOT_FOUND,p.CONTAINER_NOT_FOUND);const r=new _({videoInfo:{traceid:e.traceid||"",video:e.video,viewId:e.viewId||"",video_report_url:e.video_report_url,video_duration:Number(e.video_duration),video_file_size:Number(e.video_file_size),video_width:Number(e.video_width),video_height:Number(e.video_height)},videoOptions:s,containerStyle:{width:"100%",height:"100%"},callbacks:this.createVideoCallbacks()});return r.mount(n),this.videoElement=r.getVideoElement(),y({videoId:r.getVideoElement().id})},this.play=()=>{var t;return null===(t=this.videoElement)||void 0===t||t.play(),y({videoId:this.videoElement.id})},this.pause=()=>{var t;return null===(t=this.videoElement)||void 0===t||t.pause(),y({videoId:this.videoElement.id})},this.replay=()=>{var t;return this.videoElement.currentTime=0,null===(t=this.videoElement)||void 0===t||t.play(),y({videoId:this.videoElement.id})},this.createVideoCallbacks=()=>({onPlay:t=>{this.eventCallback(l.VIDEO_PLAY,{videoId:t})},onPause:t=>{this.eventCallback(l.VIDEO_PAUSE,{videoId:t})},onEnded:t=>{this.eventCallback(l.VIDEO_ENDED,{videoId:t})},onError:(t,i)=>{this.eventCallback(l.VIDEO_ERROR,{message:t.message||"",videoId:i})},onTimeUpdate:(t,i,e)=>{this.eventCallback(l.VIDEO_TIMEUPDATE,{currentTime:t,duration:i,videoId:e})},onReady:(t,i)=>{this.eventCallback(l.VIDEO_READY,{videoId:i})}})}}b.getInstance=()=>(b.instance||(b.instance=new b),b.instance);class E{constructor(){this.adDataMap=new Map,this.init=t=>{const{appId:i}=null!=t?t:{};if(null===(s=null===(e=window.window.chrome)||void 0===e?void 0:e.webview)||void 0===s?void 0:s.hostObjects)if(m.init(),this.channel=w.getInstance(),this.channel.setupMessageListener(),this.channel.registerHandler(this.handleNativeInvoke),i)this.appId=i,this.channel.send(l.INIT,{result:{}}),m.report("bridge_init_success",{});else{const t={code:v.INVALID_APPID,message:p.INVALID_APPID};this.channel.send(l.INIT,{error:t}),m.report("bridge_init_fail",t)}var e,s},this.loadFeedAdData=async({params:n})=>{if(!I(n[0],["placementId","count"]))return g(v.INVALID_PARAMS,p.INVALID_PARAMS);try{const{placementId:r,count:d,ext:h={}}=n[0],{data:u}=await(async function(n,r){if(!n.placementId)throw Error("[GDTSDK Request]: 缺少广告位ID");try{const d=s.getInstance();let h=await d.getRequestParams(n);r&&(h=d.mergeParams(h,r));const{status:u,data:{data:c}}=await o.request({url:"https://mi.gdt.qq.com/gdt_mview.fcg",params:h});if(200!==u)throw{code:u,message:"Network error"};const[l]=Object.keys(c);if(!l||!c[l])throw Error("No ad data available");const{ret:v,msg:p}=c[l];if(0!==v)throw{code:v,message:p||"Unknown error"};return{success:!0,data:(c[l].list||[]).map((s=>{const r={...s,traceid:s.traceid||""+i(),placementId:n.placementId,viewId:e(s.apurl),adExpireTimestamp:Date.now()+t(s.ad_expire||1)};return(function(t,i){t&&a.set("ads_data",{[t]:i})})(s.traceid,r),r}))}}catch(t){throw{message:t.message||"Failed to load ad data",error:t}}})({placementId:r,count:d,appId:this.appId},{ext:h});return u.forEach((t=>{t.traceid&&this.adDataMap.set(t.traceid,t)})),y(u)}catch(t){return g(t.code||v.UNKNOWN,t.message||p.UNKNOWN)}},this.doExpose=async({targetId:t})=>{var i;const e=this.adDataMap.get(t);if(!e)return g(v.AD_NOT_FOUND,p.AD_NOT_FOUND);try{const{data:t}=await d({url:null!==(i=e.apurl)&&void 0!==i?i:"",params:{}});return 0!==t.ret?g(t.ret,t.msg||"曝光上报失败"):y(t.data)}catch(t){return g(t.code||v.UNKNOWN,t.message||"曝光上报失败")}},this.doClick=async({targetId:t,params:i})=>{var e;if(!I(i[0],["x","y"]))return g(v.INVALID_PARAMS,p.INVALID_PARAMS);const s=this.adDataMap.get(t);if(!s)return g(v.AD_NOT_FOUND,p.AD_NOT_FOUND);try{const{data:t}=await(async function({url:t}){return await o.request({url:t,params:{rsptype:1,datatype:"jsonp"}})})({url:null!==(e=s.rl)&&void 0!==e?e:""});return 0!==t.ret?g(t.ret,t.msg||"点击上报失败"):y(t.data)}catch(t){return g(t.code||v.UNKNOWN,t.message||"点击上报失败")}},this.createVideoAd=async({params:t})=>I(t[0],["containerId","adData"])?(this.videoMananger=b.getInstance(),this.videoMananger.registerEventCallback(((t,i)=>{var e;null===(e=this.channel)||void 0===e||e.send(t,i)})),this.videoMananger.createVideoAd(t[0])):g(v.INVALID_PARAMS,p.INVALID_PARAMS),this.playVideo=()=>{var t;return null===(t=this.videoMananger)||void 0===t?void 0:t.play()},this.pauseVideo=()=>{var t;return null===(t=this.videoMananger)||void 0===t?void 0:t.pause()},this.replayVideo=()=>{var t;return null===(t=this.videoMananger)||void 0===t?void 0:t.replay()},this.destroy=({targetId:t})=>this.adDataMap.delete(t)?y({}):g(v.AD_NOT_FOUND,p.AD_NOT_FOUND),this.isValid=({targetId:t})=>this.adDataMap.has(t)?y(Date.now()<Number(this.adDataMap.get(t).adExpireTimestamp)):g(v.AD_NOT_FOUND,p.AD_NOT_FOUND),this.handleNativeInvoke=async(t,i,e)=>{if(Object.prototype.hasOwnProperty.call(this,s=t)&&"function"==typeof this[s]){const s=await this[t]({params:i,targetId:e});return"result"in s?null==m||m.report(`bridge_${t}_success`,{}):null==m||m.report(`bridge_${t}_fail`,s.error),s}return g(v.METHOD_NOT_FOUND,p.METHOD_NOT_FOUND);var s}}}E.getInstance=()=>(E.instance||(E.instance=new E),E.instance);var O=E.getInstance();export{O as default};